Hi Philipp
My Problem is no more! :-)
I am using Notepad++ as my code editor, and compiling and running 'packihx' in 
a Dosbox. My pcb is a custom one that has been running since about a month.I 
had checked, rechecked and re-re-re-re-re checked the source, list file and hex 
file in Notepad++ as well as in STVP, and could not find any probable cause or 
bug or wrong mnemonic or wrong instruction in any file, whether source, or lst 
or hex. Frustrated, and finding no other way out, I simply rewrote ( no copy 
pasted) the c function (keypress) in the c source file in exactly the same way 
it was in the original. Using Notepad++ again. Saved, Compiled and packihx in 
my dosbox. Programmed the same card with STVP. It worked like a charm. No other 
change required. At all.I still haven't found out the cause of the problem, but 
the program now works completely. I have repeated the same keypress key sense 
code for three more keys within a time frame, LEDs toggling etc.No issues now.
Thank you for your help. 
Thanks and Warm Regards
Shiv

On Wednesday, October 23, 2019, 06:20:15 PM GMT+5:30, Shivakumar R via 
Sdcc-user <sdcc-user@lists.sourceforge.net> wrote:


 
 
 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
  
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to