Skip to content

Commit

Permalink
armv7-a timer:fix timer overflow.
Browse files Browse the repository at this point in the history
Signed-off-by: yangguangcai <[email protected]>
  • Loading branch information
yangguangcai1 committed Aug 26, 2024
1 parent ab92b7d commit d396daa
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion arch/arm/src/armv7-a/arm_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ static inline void arm_timer_set_cval(uint64_t cval)

static inline uint64_t nsec_from_count(uint64_t count, uint32_t freq)
{
return (uint64_t)count * NSEC_PER_SEC / freq;
uint64_t sec = count / freq;
uint64_t nsec = (count % freq) * NSEC_PER_SEC / freq;
return sec * NSEC_PER_SEC + nsec;
}

static inline uint64_t nsec_to_count(uint32_t nsec, uint32_t freq)
Expand Down

0 comments on commit d396daa

Please sign in to comment.