You will need to maintain your own time. When you need an absolute time stamping have a look at the RTC Component.
When only a relative time is needed a Timer component which fires an interrupt to update the current time will do.
Thanks for the reply Bob!
My problem is that I need to measure time between the start of the function and each reading of my data in the loop. RTC is not precise enough to do the job as the first time stamp should be something like 10 milliseconds and the last one something like 3500 mmilliseconds.
Do you have any example on how to create my timestamps with a timer without using any external PIN? The problem when I try to do it is that the function MyTimer_ReadCounter() will always return the same value.
Well, you also need to make sure the timer is running. If the timer is stopped, then the read counter function will return the same value.
Also, you can create an interrupt that handles a timer with, say, a 1 ms interrupt, and then increment a custom timer variable on each count.
Then, just clear the count when you want to reset it.
If you create a new project, and select "code example", then filter by "time", there should be a "SysTick_Example" project that demonstrates using an internal timer to count timing. This should be useful for you.
Thank you very much for your replies!
After many hours I finally found a way to get my timestamps. This what I have done to settle this problem:
1) Add a timer in my topdesign.cysh and feed it with a 1kHz clock. I also wired it's interrupt to ISR_interrupt.
2) The Code:
if (Counter_1_GetInterruptSource() == Counter_1_INTR_MASK_CC_MATCH)
if (Counter_1_GetInterruptSource() == Counter_1_INTR_MASK_TC)
void My_funtion(uint32 (*data), uint32 (*timestamp))
temp1=BLE_AFE4403_ReadData(0x2A,0x00); // Data aquisition
(*timestamp)[n] = counter; //Timestamp in ms
I hope this code will help next person having problems to create timestamps.
The function calls:
Are redundant. The first one starts the ISR with the default interrupt routine handling it (which is in generated code in the IDE), whereas the second one attaches the ISR to send execution to your "Routine" code when an interrupt occurs.
If you use only the second line (ISR_Counter_StartEx(Routine);) it will still work well and will have the useless instructions removed.