This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hello
I want to measure a execution time of a function. For that reason, I have used in Mcal driver the following functions before and after the function to calculate the timer ticks:
void Start_Timer(void) { HW_WR_REG32(0x52181000, 0x00000000);//GCTRL HW_WR_REG32(0x52181008, 0x00000000);//Capture Control HW_WR_REG32(0x5218100C, 0x00000000);//COMP CTRL HW_WR_REG32(0x52181010, 0x00000000);//FRC0 HW_WR_REG32(0x52181014, 0x00000000);//UP Counter HW_WR_REG32(0x52181018, 0x00000001);//Compare Up Counter HW_WR_REG32(0x52181084, 0x00070F0F);//Clear Interrupt HW_WR_REG32(0x52181000, 0x00000001);//GCTRL Start Timer } uint32 Stop_Timer(void) { uint32 frc; frc = HW_RD_REG32(0x52181010); HW_WR_REG32(0x52181000, 0x00000000);//GCTRL Stop Timer return frc; }
After the tick is calculated; the time is in milliseconds calculated so:
uint32 Time_MiliSeconds(uint32 Tick_Duration, uint32 Tick_Frequency) { uint32 Duration_ms; Duration_ms = (Tick_Duration * 1000) / Tick_Frequency; return Duration_ms; }
the resolution for timer is 1000 Ticks per second, so I get a time in millisecond.
My question is, how can I set the resolution in microsecond?
HW_WR_REG32(0x52181018, 0x000003E8);//Compare Up Counter ---> is this right way ?
hex 348 is in decimal 1000
Thank you in advance
Best regards
What I want is simply instead of 1000 ticks per second 1 000 000 Ticks per second. How can i do that directly within start function above?
Hi panda Bear,
Yes you can directly change the Compare up counter value to match and generate the interrupt. This basically pre-scales the RTI frequency.
Hi Panda,
These API's are used as part of example utils and are not recommended to use it in your application.
Can you use Gpt module from MCAL?
Thanks And Regards,
Sunil Kumar M S