ArmArchTimerDisableTimer ();\r
\r
if (TimerPeriod != 0) {\r
- // Convert TimerPeriod to micro sec units\r
- TimerTicks = DivU64x32 (TimerPeriod, 10);\r
+ // TimerTicks = TimerPeriod in 1ms unit x Frequency.10^-3\r
+ // = TimerPeriod.10^-4 x Frequency.10^-3\r
+ // = (TimerPeriod x Frequency) x 10^-7\r
+ TimerTicks = MultU64x32 (TimerPeriod, FixedPcdGet32 (PcdArmArchTimerFreqInHz));\r
+ TimerTicks = DivU64x32 (TimerTicks, 10000000U);\r
\r
- TimerTicks = MultU64x32 (TimerTicks, (PcdGet32(PcdArmArchTimerFreqInHz)/1000000));\r
-\r
- ArmArchTimerSetTimerVal((UINTN)TimerTicks);\r
+ ArmArchTimerSetTimerVal ((UINTN)TimerTicks);\r
\r
// Enable the timer\r
ArmArchTimerEnableTimer ();\r
UINT64 TimerTicks64;\r
UINT64 SystemCounterVal;\r
\r
- // Calculate counter ticks that can represent requested delay\r
- TimerTicks64 = MultU64x32 (MicroSeconds, TICKS_PER_MICRO_SEC);\r
+ // Calculate counter ticks that can represent requested delay:\r
+ // = MicroSeconds x TICKS_PER_MICRO_SEC\r
+ // = MicroSeconds x Frequency.10^-6\r
+ TimerTicks64 = (MicroSeconds * PcdGet32 (PcdArmArchTimerFreqInHz)) / 1000000U;\r
\r
// Read System Counter value\r
SystemCounterVal = ArmArchTimerGetSystemCount ();\r