Spin help - What am I missing
Paul Sr.
Posts: 435
I'm finally spending some serious time with Spin so I can stop fumbling, and have encountered something that has been kicking me around, but I have been reluctant to mention because it seems TOO simple to be asking - but here goes anyway!
I am rewriting a serial LCD driver for different hardware, and I have the following code in it:
and although I clearly have "linecnt := 4", the statement "If linecnt == 4" never evaluates true!
I have the same issue in the driver (same variable that is passed in through the call). I put a statement in that displays the value on the LCD and it SAYS it is equal to 4, but again, doesn't evaluate as 4.
What on earth did I miss???
Thanks,
Paul
I am rewriting a serial LCD driver for different hardware, and I have the following code in it:
Var byte linecnt OBJ LCD : "Serial_LCD_PWS" DELAY : "Clock" PUB Demo | temp DELAY.Init(8_000_000) linecnt := 4 LCD.start(18, 9600, linecnt) REPEAT LCD.CLS delay.PauseSec(1) LCD.cursor(2) delay.PauseSec(1) LCD.str(string("Starting...")) delay.PauseSec(1) ' LCD.backlight(ON,$FF) ' delay.pausesec(1) LCD.cursor(3) delay.pausesec(1) LCD.gotoxy(2,1) LCD.str(string("Line 2")) delay.PauseSec(1) LCD.backlight(ON,$00) delay.PauseSec(1) ' LCD.cursor(2) If linecnt == 4 LCD.gotoxy(4,2) LCD.str(string("Line 3")) delay.PauseSec(1) LCD.gotoxy(6,3) LCD.str(string("Line 4")) delay.PauseSec(1)
and although I clearly have "linecnt := 4", the statement "If linecnt == 4" never evaluates true!
I have the same issue in the driver (same variable that is passed in through the call). I put a statement in that displays the value on the LCD and it SAYS it is equal to 4, but again, doesn't evaluate as 4.
What on earth did I miss???
Thanks,
Paul
Comments
There may be something in your driver that's overwriting part of memory and may be changing the value stored in linecnt.
Thanks for the fast response!
I thought of that and I created a new variable, unique to the object and set it equal to linecnt - same results. I also have tried it on two different machines (really stretching here), but it acts the same.
In the driver, I tried the following
The CASE statement appears to be evaluating lcdlines as expected, but the commented IF statement NEVER evaluates it correctly.
I even tried obscure [noparse][[/noparse]for a simple IF statement] things like forcing absolute values, etc. to no avail.
I'm really baffled!
Paul
Define "linecnt" not as VAR but as local variable; it then will be a long, but never mind... It most likely will work now...
(2) Why could it have ben overwritten? BYTEs are always arranged at the the end of all VARs... You did not give your main program, but I imagine you will have the stack for some of your objects defined just before it. The size of stack is generally underestimated... Set your stacks to 100 LONGs and see what happens.
Common thread here is the STACK - which could very well be it - guess I better understand that better first off.
Thanks again.
Turns out, the issue seems to only exist on the uOled-96-Prop!
I put together another "breadboard" system using a Prop-Stick and the code runs and performs exactly as it should - all IF statements (or more accurately evaluations) are now working correctly!
This all started out when I was working on "polishing up" the Circle method I wrote for the uOled-96. I was getting unexpected results so I decided I wanted an LCD hooked up to pump values out to while things were happening. I have a bunch of the Wulfden/PHAnderson Serial LCD modules around (great little devices!) so I decided to rewrite the Parallax Serial driver to work with them. This is where I ran into the broken evaluations - which apparently explains why I was having trouble with the Circle method. Perhaps the Circle function needs to be in assembly!
So Mike, what was it you were saying "The uOLED-96-Prop cannot "run properly at 128MHz""??? Could this be proof?
When I bump it back up to 16X, it gets unpredictable. Sometimes the evaluations in the main object don't work, then other times, it moves to the driver.
When at 8X, it works correctly/stably and the same as it does on the Prop Stick (at 80Mhz).
From an earlier comment it seems you've read these, but for others, see previous discussions at -
http://forums.parallax.com/showthread.php?p=687140
http://forums.parallax.com/showthread.php?p=679308