Hi PhilippThank you for the input and the heads up on the volatile keyword. I 
Have changed all interrupt modified variables as "char volatile" and checked 
again.
However, my problem is not yet solved. The input port bit is not being read 
after the first time.

At the lines you pointed, the loop is completed, the system works well, and 
goes beyond that part of the code. It stops working when it reaches the port 
read in the keypress function below. 

Am I missing setting some condition required to read input ports, or any other 
sequential step required to be done before I read port?The system worked the 
first time, so why not after?
Thanks and Warm Regards
Shiv

On Wednesday, October 23, 2019, 03:10:27 PM GMT+5:30, Philipp Klaus Krause 
<p...@spth.de> wrote: 
 
 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
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user
  
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to