Shop OBEX P1 Docs P2 Docs Learn Events
LCD Appmod - weird stuff — Parallax Forums

LCD Appmod - weird stuff

sylvie369sylvie369 Posts: 1,622
edited 2007-10-28 22:49 in BASIC Stamp
Ok, I'm pretty new at this, so it could easily be my lack of knowledge, but I've got what seems to me to be a really weird problem. I'm trying to use the LCD Appmod with a 2px and the Parallax GPS receiver. I'm getting data fine from the receiver, and using DEBUG I can display the time, latitude, longitude, etc. on my computer screen. I'm trying to get those data to appear on the LCD as well.

I used the initialization code from the documentation (below). When I tried to write the digits making up the time of day, I got Japanese characters instead. I put some debug statements into the code to try to find the problem, and by accident found that a certain debug statement at a certain point made the code work properly. It was this
LCD_Command:··································· ' write command to LCD
· #IF _LcdReady #THEN
··· LCDCMD E, char
··· RETURN
· #ELSE
· DEBUG "here2"······························ ' <- why the hell this makes
··· LOW RS····································· ' a difference is beyond me.
··· GOTO LCD_Write_Char
· #ENDIF
When I put in that Debug "here2", the time of day started displaying properly. When I comment it out, I get weird results (digits shifted over, Japanese characters, etc.). When I replace "here2" with other text, I get weird results. But with Debug "here2" in there, it works fine. It's happily displaying the time of day right now.

Why in the world would a DEBUG statement affect what is displayed on the LCD? And why would the content of that DEBUG statement make a difference? FWIW, I'm nowhere near filling my program memory, so that's not it, I don't think.

Here's the Init routine I'm using: I believe that the only change I made from the demo program was to make it a subroutine.
===============================
Main:
· GOSUB LCDInit
(program code here)

End
(snip)

LCDInit:
· NAP 50······································· ' let LCD self-initialize
· DIRL = %11111110····························· ' setup pins for LCD
· #IF _LcdReady #THEN
··· LCDCMD E, %00110000 : PAUSE 5·············· ' 8-bit mode
··· LCDCMD E, %00110000 : PAUSE 0
··· LCDCMD E, %00110000 : PAUSE 0
··· LCDCMD E, %00100000 : PAUSE 0·············· ' 4-bit mode
··· LCDCMD E, %00101000 : PAUSE 0·············· ' 2-line mode
··· LCDCMD E, %00001100 : PAUSE 0·············· ' no crsr, no blink
··· LCDCMD E, %00000110························ ' inc crsr, no disp shift
· #ELSE
··· LcdBusOut = %0011·························· ' 8-bit mode
··· PULSOUT E, 3 : PAUSE 5
··· PULSOUT E, 3 : PAUSE 0
··· PULSOUT E, 3 : PAUSE 0
··· LcdBusOut = %0010·························· ' 4-bit mode
··· PULSOUT E, 3
··· char = %00101000··························· ' 2-line mode
··· GOSUB LCD_Command
··· char = %00001100··························· ' on, no crsr, no blink
··· GOSUB LCD_Command
··· char = %00000110··························· ' inc crsr, no disp shift
··· GOSUB LCD_Command
· #ENDIF
RETURN
=========================
While I'm on the line, how is that #IF _Lcdready statement supposed to work? I don't see any test for _Lcdready in the demo code, and as far as I can tell, it's always the alternate code (with all the pulsout commands) that runs.

Comments

  • sylvie369sylvie369 Posts: 1,622
    edited 2007-10-28 21:46
    A little playing with it gave me more information: it's apparently not those specific characters ("here2") in the DEBUG statement that matter, but rather the string displayed has to have either 4 or 5 characters in it. Fewer than 4 or more than 5 and I don't get anything displayed at all on the LCD.
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2007-10-28 22:42
    Sylvie -

    My guess is that it's a timing problem. Try replacing your DEBUG statement with a PAUSE statement. Start with PAUSE 1 and work your way up until it works as it should.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • sylvie369sylvie369 Posts: 1,622
    edited 2007-10-28 22:49
    Bruce -

    Thanks - yup, even just PAUSE 1 worked fine.

    Man, I've got a lot to learn.
Sign In or Register to comment.