Am 23.10.19 um 10:14 schrieb Shivakumar R via Sdcc-user: > Hi > I have been using STM8 and SDCC for about 2 months now. > I'm facing an issue these last two days that I can't seem to figure out. > The code is supposed to read an input port, confirm the key is pressed > for 8 seconds, then call another routine for further 3 key inputs. > There's a tim2 interrupt(overflow) - not shown in the code below - that > runs every 125 mS. The interrupt is used to keep track of key pressed > duration and to flash an LED when needed. > > […] > char tixnow, ticks, itix, six8cnt, ticker8, keyval; > […] > while(tixnow==ticks); /*/ticks increases 8 times a second, in a > […]
I guess SDCC optimizes that by just checking tixnow==ticks once, before the loop. After all, the value of these two variables cannot change in the loop. Looks like you forgot to use the volatile keyword when declaring variables that are used to communicate between the normal program and the interrupt handler. Philipp
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user