|
Forum Index : Microcontroller and PC projects : Eating Humble Pie
| Author | Message | ||||
| OA47 Guru Joined: 11/04/2012 Location: AustraliaPosts: 1013 |
Nearly 12 months ago I posted this, headed "Need Help With Armmite F4" As it turns out the problem was not with the hardware as I kept wanting to blame but it was me (the programmer) Here is a bit of the code that has caused the problems: StartTime=Timer Do Loop Until Timer = StartTime + TxTime Or Loc(#1) > 12 RCMsg$="" If Loc(#1) > 12 Then 'At least 12 characters in Rx Buffer Pause 150 'Allow time for the rest of the message RCMsg$=Input$(72,#1) 'Have reply And how did I find the problem you ask? Good old TRACE ON It showed that there is a very tiny possibility that due to external software jobs that Timer would never be equal to StartTime + TxTime and the software would be in the continual loop. The answer to the problem: Loop Until Timer > StartTime + TxTime Or Loc(#1) > 12 Thought I would post this as an apology to the Mites. 0A47 |
||||
| Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3308 |
This is one of the old habits of experienced programmers. Rather than check for equality check for greater (or less) than a value. Geoff Geoff Graham - http://geoffg.net |
||||
| Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 8307 |
I messed that reply up and Geoff got in. :) Well spotted! It's a particularly nasty error if you are using floats and discover that 5 isn't equal to 5.000000000001 too! Edited 2023-10-05 17:24 by Mixtel90 Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
| circuit Senior Member Joined: 10/01/2016 Location: United KingdomPosts: 293 |
Do not apologise; learning from such helpful examples of mistakes spotted and corrected is of immense value. Thanks for taking the time to post this explanation with such clarity. |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |