Part Number: AM2634
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