We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
uint64_t J1939_PortGetTick(void)
这里你把 sys tick 强制转换成 uint64_t ,我知道你的意思是担心溢出。 1ms 中断,大概49天以后就会发生 uint32_t 溢出,
在stm32 平台上: 第一种情况: 溢出之前: uint32 tick1 = 2^32 -1 溢出之后2ms, uint32 tick2 = 1 那么: tick2 - tick1 = 2
第二种情况: 溢出之前: uint64 tick1 = 2^32 -1 溢出之后2ms, uint64 tick2 = 1 那么: tick2 - tick1 = 很大的64bit 整数
所以,这里是不需要强制转换为 uint64 的 ( 因为你的代码里只关心 tick2 和 tick1 的差值 )。 你可以了解下二进制的原码,反码,补码
The text was updated successfully, but these errors were encountered:
No branches or pull requests
uint64_t J1939_PortGetTick(void)
这里你把 sys tick 强制转换成 uint64_t ,我知道你的意思是担心溢出。
1ms 中断,大概49天以后就会发生 uint32_t 溢出,
在stm32 平台上:
第一种情况:
溢出之前: uint32 tick1 = 2^32 -1
溢出之后2ms, uint32 tick2 = 1
那么: tick2 - tick1 = 2
第二种情况:
溢出之前: uint64 tick1 = 2^32 -1
溢出之后2ms, uint64 tick2 = 1
那么: tick2 - tick1 = 很大的64bit 整数
所以,这里是不需要强制转换为 uint64 的 ( 因为你的代码里只关心 tick2 和 tick1 的差值 )。 你可以了解下二进制的原码,反码,补码
The text was updated successfully, but these errors were encountered: