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.

AM2634: Resolution in microseconds for timer

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:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

After the tick is calculated; the time is in milliseconds calculated so:

Fullscreen
1
2
3
4
5
6
uint32 Time_MiliSeconds(uint32 Tick_Duration, uint32 Tick_Frequency)
{
uint32 Duration_ms;
Duration_ms = (Tick_Duration * 1000) / Tick_Frequency;
return Duration_ms;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

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