STM32CUBEMX and Systick problem
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-10-27 1:24 PM
Posted on October 27, 2016 at 22:24
Hello,
does anybody faced some problems with STM32CubeMX generated code when systick overflows? Normally ir overflows every 50 days (uint32) if set to 1ms... As all Cube drivers have the same style with delays (if (getSystick() < ...) ) some strange things can happen on overflow... I did not experienced any problems for now, but would like to hear what do you do to prevent such situations, maybe change Systick type to uint64 or something else?Thank You.
4 REPLIES 4
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-10-28 9:21 AM
Posted on October 28, 2016 at 18:21
Hi mikalajunas.vaidas,
It seems a time base issue.I recommend to take allok to '' 4.11.6 Setting HAL timebase source'' inside the STM32CubeMX User manual .-Hannibal-Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-10-28 2:17 PM
Posted on October 28, 2016 at 23:17
the unsigned arithmetic guarantees that the time difference calculation is correct even if
the tick value wraps around.e.g. if time value would be only 8 bituint8_t t0,t1;uint8_t td ;t0 = 230;t1 = 250;td = t1 - t0;printf(''t0: %d t1:%d td: %d\r\n'', t0, t1, td); // output: t0: 230 t1:250 td: 20t1 = t1+20; // 20ms later t1 wraps aroundtd = t1 - t0; printf(''t0: %d t1:%d td: %d\r\n'', t0, t1, td); // output: t0: 240 t1:14 td: 40Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-10-28 3:42 PM
Posted on October 29, 2016 at 00:42
Thought this was addressed a long while ago, I hope stuff hasn't crept back in.
Show the actual failing code snippet, not an edited one. [DEAD LINK /public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/%5bbug%20report%5d%20Bug%20in%20HAL%20%28SPL%29%20delay%20function&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B¤tviews=3127]https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2Fcortex%5Fmx%5Fstm32%2F%5Bbug%20report%5D%20Bug%20in%20HAL%20%28SPL%29%20delay%20function&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B¤tviews=3127 [DEAD LINK /public/STe2ecommunities/mcu/Lists/STM32Java/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/STM32Java/False%20HAL_Delay%20computation%20when%20uwTick%20overflows&FolderCTID=0x01200200770978C69A1141439FE559EB459D758000F9A0E3A95BA69146A17C2E80209ADC21¤tviews=75]https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Java/Flat.aspx?RootFolder=%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2FSTM32Java%2FFalse%20HAL_Delay%20computation%20when%20uwTick%20overflows&FolderCTID=0x01200200770978C69A1141439FE559EB459D758000F9A0E3A95BA69146A17C2E80209ADC21¤tviews=75
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Up vote any posts that you find helpful, it shows what's working..
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-10-28 11:43 PM
Posted on October 29, 2016 at 08:43Thank You all for the help, now I see. that there is no problem with systick overflow, my bad...
