Skip to content

[SAMR34] RtcMs2Tick conversion not precise #1045

Answered by mluis1
KaDw asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks for reporting this issue.

I would propose the following

uint32_t RtcMs2Tick( uint32_t milliseconds )
{
    return ( uint32_t )( ( ( ( uint64_t )milliseconds ) << 10 ) / 1000 );
}

By applying the shift left by ten the result may not fit in a uint32_t type.

Could you please create a pull request?

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@KaDw
Comment options

@KaDw
Comment options

@Tom1278
Comment options

Answer selected by mluis1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants