One Line Breaks Code?
Archiver
Posts: 46,084
Frank-
The LCDIN instruction leaves the four data bus pins in input mode.
Your LCD_Command and LCD_Write routines assume those pins are in
output mode (they were placed in output mode wey are in output mode
once by the DIRL statement). As a result, after executing the LCDIN
your Stamp program is no longer controlling the output states of the
data bus pins, and further attempted writes to the LCD are
ineffective.
It's one outcome of mixing the BS2 & BS2p* approaches as Jon
remarked.
You might also check the LCD's R/W* pin. It doesn't seem to be
manipulated by your program, so the program may assume it's always in
the Write state. The circuit may be hardwired to accomplish that,
which would mean you can't read from the LCD unless you run the
wire from the R/W* pin to I/O 2 instead. Then manipulate it in your
own software (BS2 approach) or let the LCDIN/LCDOUT instructions work
for you (BS2p*).
Regards,
Steve
The LCDIN instruction leaves the four data bus pins in input mode.
Your LCD_Command and LCD_Write routines assume those pins are in
output mode (they were placed in output mode wey are in output mode
once by the DIRL statement). As a result, after executing the LCDIN
your Stamp program is no longer controlling the output states of the
data bus pins, and further attempted writes to the LCD are
ineffective.
It's one outcome of mixing the BS2 & BS2p* approaches as Jon
remarked.
You might also check the LCD's R/W* pin. It doesn't seem to be
manipulated by your program, so the program may assume it's always in
the Write state. The circuit may be hardwired to accomplish that,
which would mean you can't read from the LCD unless you run the
wire from the R/W* pin to I/O 2 instead. Then manipulate it in your
own software (BS2 approach) or let the LCDIN/LCDOUT instructions work
for you (BS2p*).
Regards,
Steve
Comments
I have added:
' Two new lines of code
PAUSE 250
LCDIN 0, $C0 + 0, [noparse][[/noparse]char]
The stamp directive was modified to read:
' {$STAMP BS2pe}
I am using a iNex 1000 24/40 board with a BS2pe.
The unmodified code runs perfect. The modified code I think hangs
the stamp. Anyway, all mods to the LCD stop.
I have a larger program for a project of mine. The LCD wouldn't
update. After deleting all the non-LCD code, I noticed what remained
was a modified version of Ex. 12.
Changed two lines of Ex. 12 and bam. LCD quit updating.
What do you think?
Below is the offending code.
Thanks,
Frank
'
======================================================================
========
'
' File...... Ex12 - LCD Characters.BS2
' Purpose... Custom LCD Characters
' Author.... Parallax
' E-mail.... stamptech@p...
' Started...
' Updated... 01 MAY 2002
'
' {$STAMP BS2pe}
'
'
======================================================================
========
'
' Program Description
'
' This program demonstrates custom character creation and animation
on a
' character LCD.
'
' The connections for this program conform to the BS2p LCDIN and
LCDOUT
' commands. Use this program for the BS2, BS2e or BS2sx. There is a
separate
' program for the BS2p.
'
' I/O Definitions
'
E CON 0 ' LCD Enable pin (1
= enabled)
RS CON 3 ' Register Select (1
= char)
LCDbus VAR OUTB ' 4-bit LCD data bus
'
' Constants
'
ClrLCD CON $01 ' clear the LCD
CrsrHm CON $02 ' move cursor to home
position
CRSRLF CON $10 ' move cursor left
CRSRRT CON $14 ' move cursor right
DispLf CON $18 ' shift displayed
chars left
DispRt CON $1C ' shift displayed
chars right
DDRam CON $80 ' Display Data RAM
control
CGRam CON $40 ' Custom character RAM
Line1 CON $80 ' DDRAM address of
line 1
Line2 CON $C0 ' DDRAM address of
line 2
'
' Variables
'
char VAR Byte ' character sent to
LCD
newChar VAR Byte ' new character for
animation
index1 VAR Byte ' loop counter
index2 VAR Byte ' loop counter
'
' EEPROM Data
'
Msg1 DATA "THE BASIC STAMP " ' preload EEPROM with
messages
Msg2 DATA " IS VERY COOL! ", 3
CC0 DATA $0E, $1F, $1C, $18, $1C, $1F, $0E, $00 '
character 0
CC1 DATA $0E, $1F, $1F, $18, $1F, $1F, $0E, $00 '
character 1
CC2 DATA $0E, $1F, $1F, $1F, $1F, $1F, $0E, $00 '
character 2
Smiley DATA $00, $0A, $0A, $00, $11, $0E, $06, $00 '
smiley face
'
' Initialization
'
Initialize:
DIRL = %11111101 ' setup pins for LCD
LCD_Init:
PAUSE 500 ' let the LCD settle
LCDbus = %0011 ' 8-bit mode
PULSOUT E, 1
PAUSE 5
PULSOUT E, 1
PULSOUT E, 1
LCDbus = %0010 ' 4-bit mode
PULSOUT E, 1
char = %00101000 ' multi-line mode
GOSUB LCD_Command
char = %00001100 ' disp on, crsr off,
blink off
GOSUB LCD_Command
char = %00000110 ' inc crsr, no disp
shift
GOSUB LCD_Command
Download_Chars: ' download custom
chars to LCD
char = CGRam ' point to CG RAM
GOSUB LCD_Command ' prepare to write CG
data
FOR index1 = CC0 TO (Smiley + 7) ' build 4 custom chars
READ index1, char ' get byte from EEPROM
GOSUB LCD_Write ' put into LCD CG RAM
NEXT
'
' Program Code
'
Main:
char = ClrLCD ' clear the LCD
GOSUB LCD_Command
PAUSE 250
FOR index1 = 0 TO 15 ' get message from
EEPROM
READ (Msg1 + index1),char ' read a character
GOSUB LCD_Write ' write it
NEXT
PAUSE 2000 ' wait 2 seconds
Animation:
FOR index1 = 0 TO 15 ' cover 16 characters
READ (Msg2 + index1), newChar ' get new char from
2nd message
FOR index2 = 0 TO 4 ' 5 characters in
animation cycle
char = Line2 + index1 ' set new DDRAM
address
GOSUB LCD_Command
LOOKUP index2, [noparse][[/noparse]0, 1, 2, 1, newChar], char
GOSUB LCD_Write ' write animation
character
PAUSE 50 ' delay between
animation chars
NEXT
NEXT
' Two new lines of code
PAUSE 250
LCDIN 0, $C0 + 0, [noparse][[/noparse]char]
PAUSE 1000
GOTO Main
' do it all over
END
'
' Subroutines
'
LCD_Command:
LOW RS ' enter command mode
LCD_Write:
LCDbus = char.HIGHNIB ' output high nibble
PULSOUT E, 1 ' strobe the Enable
line
LCDbus = char.LOWNIB ' output low nibble
PULSOUT E, 1
HIGH RS ' return to character
mode
RETURN
http://www.parallax.com/detail.asp?product_id=27297
you will find a link to a ZIP file with the experiment files. Inside
there is a BS2p version of all the experiments. Start with that since
the BS2pe supports the same LCD commands as the BS2p. This would be a
better place to start than using BS2 code (that doesn't have native
support for LCD).
-- Jon Williams
-- Applications Engineer, Parallax
-- Dallas Office
Original Message
From: franksmith512 [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=ii9UnaUkPhGYVcFiIigevuG_w4WN6enmJpCSOjSNeEtPXaGUxM230Y53kMoFGMXCmwSyl8E5b2drrxksEw]franksmith512@y...[/url
Sent: Saturday, December 13, 2003 10:14 AM
To: basicstamps@yahoogroups.com
Subject: [noparse][[/noparse]basicstamps] One Line Breaks Code?
Below is a copy of Exercise 12 from Stamp Works. These are the lines
I have added:
' Two new lines of code
PAUSE 250
LCDIN 0, $C0 + 0, [noparse][[/noparse]char]
The stamp directive was modified to read:
' {$STAMP BS2pe}
I am using a iNex 1000 24/40 board with a BS2pe.
The unmodified code runs perfect. The modified code I think hangs
the stamp. Anyway, all mods to the LCD stop.
I have a larger program for a project of mine. The LCD wouldn't
update. After deleting all the non-LCD code, I noticed what remained
was a modified version of Ex. 12.
Changed two lines of Ex. 12 and bam. LCD quit updating.
What do you think?
Below is the offending code.
Thanks,
Frank
'
======================================================================
========
'
' File...... Ex12 - LCD Characters.BS2
' Purpose... Custom LCD Characters
' Author.... Parallax
' E-mail.... stamptech@p...
' Started...
' Updated... 01 MAY 2002
'
' {$STAMP BS2pe}
'
'
======================================================================
========
'
' Program Description
'
' This program demonstrates custom character creation and animation
on a
' character LCD.
'
' The connections for this program conform to the BS2p LCDIN and
LCDOUT
' commands. Use this program for the BS2, BS2e or BS2sx. There is a
separate
' program for the BS2p.
'
' I/O Definitions
'
E CON 0 ' LCD Enable pin (1
= enabled)
RS CON 3 ' Register Select (1
= char)
LCDbus VAR OUTB ' 4-bit LCD data bus
'
' Constants
'
ClrLCD CON $01 ' clear the LCD
CrsrHm CON $02 ' move cursor to home
position
CRSRLF CON $10 ' move cursor left
CRSRRT CON $14 ' move cursor right
DispLf CON $18 ' shift displayed
chars left
DispRt CON $1C ' shift displayed
chars right
DDRam CON $80 ' Display Data RAM
control
CGRam CON $40 ' Custom character RAM
Line1 CON $80 ' DDRAM address of
line 1
Line2 CON $C0 ' DDRAM address of
line 2
'
' Variables
'
char VAR Byte ' character sent to
LCD
newChar VAR Byte ' new character for
animation
index1 VAR Byte ' loop counter
index2 VAR Byte ' loop counter
'
' EEPROM Data
'
Msg1 DATA "THE BASIC STAMP " ' preload EEPROM with
messages
Msg2 DATA " IS VERY COOL! ", 3
CC0 DATA $0E, $1F, $1C, $18, $1C, $1F, $0E, $00 '
character 0
CC1 DATA $0E, $1F, $1F, $18, $1F, $1F, $0E, $00 '
character 1
CC2 DATA $0E, $1F, $1F, $1F, $1F, $1F, $0E, $00 '
character 2
Smiley DATA $00, $0A, $0A, $00, $11, $0E, $06, $00 '
smiley face
'
' Initialization
'
Initialize:
DIRL = %11111101 ' setup pins for LCD
LCD_Init:
PAUSE 500 ' let the LCD settle
LCDbus = %0011 ' 8-bit mode
PULSOUT E, 1
PAUSE 5
PULSOUT E, 1
PULSOUT E, 1
LCDbus = %0010 ' 4-bit mode
PULSOUT E, 1
char = %00101000 ' multi-line mode
GOSUB LCD_Command
char = %00001100 ' disp on, crsr off,
blink off
GOSUB LCD_Command
char = %00000110 ' inc crsr, no disp
shift
GOSUB LCD_Command
Download_Chars: ' download custom
chars to LCD
char = CGRam ' point to CG RAM
GOSUB LCD_Command ' prepare to write CG
data
FOR index1 = CC0 TO (Smiley + 7) ' build 4 custom chars
READ index1, char ' get byte from EEPROM
GOSUB LCD_Write ' put into LCD CG RAM
NEXT
'
' Program Code
'
Main:
char = ClrLCD ' clear the LCD
GOSUB LCD_Command
PAUSE 250
FOR index1 = 0 TO 15 ' get message from
EEPROM
READ (Msg1 + index1),char ' read a character
GOSUB LCD_Write ' write it
NEXT
PAUSE 2000 ' wait 2 seconds
Animation:
FOR index1 = 0 TO 15 ' cover 16 characters
READ (Msg2 + index1), newChar ' get new char from
2nd message
FOR index2 = 0 TO 4 ' 5 characters in
animation cycle
char = Line2 + index1 ' set new DDRAM
address
GOSUB LCD_Command
LOOKUP index2, [noparse][[/noparse]0, 1, 2, 1, newChar], char
GOSUB LCD_Write ' write animation
character
PAUSE 50 ' delay between
animation chars
NEXT
NEXT
' Two new lines of code
PAUSE 250
LCDIN 0, $C0 + 0, [noparse][[/noparse]char]
PAUSE 1000
GOTO Main
' do it all over
END
'
' Subroutines
'
LCD_Command:
LOW RS ' enter command mode
LCD_Write:
LCDbus = char.HIGHNIB ' output high nibble
PULSOUT E, 1 ' strobe the Enable
line
LCDbus = char.LOWNIB ' output low nibble
PULSOUT E, 1
HIGH RS ' return to character
mode
RETURN
To UNSUBSCRIBE, just send mail to:
basicstamps-unsubscribe@yahoogroups.com
from the same email address that you subscribed. Text in the Subject
and Body of the message will be ignored.
Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
This message has been scanned by WebShield. Please report SPAM to
abuse@p....
That is just sooo much better. I have already updated my project and
it now works great!
Thanks,
Frank
--- In basicstamps@yahoogroups.com, "Jon Williams" <jwilliams@p...>
wrote:
> At the bottom of the StampWorks product page:
>
> http://www.parallax.com/detail.asp?product_id=27297
>
> you will find a link to a ZIP file with the experiment files.
Inside
> there is a BS2p version of all the experiments. Start with that
since
> the BS2pe supports the same LCD commands as the BS2p. This would
be a
> better place to start than using BS2 code (that doesn't have native
> support for LCD).
>
> -- Jon Williams
> -- Applications Engineer, Parallax
> -- Dallas Office
>
>
>
Original Message
> From: franksmith512 [noparse][[/noparse]mailto:franksmith512@y...]
> Sent: Saturday, December 13, 2003 10:14 AM
> To: basicstamps@yahoogroups.com
> Subject: [noparse][[/noparse]basicstamps] One Line Breaks Code?
>
>
> Below is a copy of Exercise 12 from Stamp Works. These are the
lines
> I have added:
>
> ' Two new lines of code
> PAUSE 250
> LCDIN 0, $C0 + 0, [noparse][[/noparse]char]
>
> The stamp directive was modified to read:
> ' {$STAMP BS2pe}
>
> I am using a iNex 1000 24/40 board with a BS2pe.
>
> The unmodified code runs perfect. The modified code I think hangs
> the stamp. Anyway, all mods to the LCD stop.
>
>
> I have a larger program for a project of mine. The LCD wouldn't
> update. After deleting all the non-LCD code, I noticed what
remained
> was a modified version of Ex. 12.
>
> Changed two lines of Ex. 12 and bam. LCD quit updating.
>
> What do you think?
>
> Below is the offending code.
>
> Thanks,
> Frank
>
>
>
>
> '
>
======================================================================
> ========
> '
> ' File...... Ex12 - LCD Characters.BS2
> ' Purpose... Custom LCD Characters
> ' Author.... Parallax
> ' E-mail.... stamptech@p...
> ' Started...
> ' Updated... 01 MAY 2002
> '
> ' {$STAMP BS2pe}
> '
> '
>
======================================================================
> ========
>
>
> '
--
>
> ' Program Description
> '
--
>
>
> ' This program demonstrates custom character creation and animation
> on a
> ' character LCD.
> '
> ' The connections for this program conform to the BS2p LCDIN and
> LCDOUT
> ' commands. Use this program for the BS2, BS2e or BS2sx. There is
a
> separate
> ' program for the BS2p.
>
>
> '
--
>
> ' I/O Definitions
> '
--
>
>
> E CON 0 ' LCD Enable pin
(1
> = enabled)
> RS CON 3 ' Register Select
(1
> = char)
> LCDbus VAR OUTB ' 4-bit LCD data bus
>
>
> '
--
>
> ' Constants
> '
--
>
>
> ClrLCD CON $01 ' clear the LCD
> CrsrHm CON $02 ' move cursor to
home
> position
> CRSRLF CON $10 ' move cursor left
> CRSRRT CON $14 ' move cursor right
> DispLf CON $18 ' shift displayed
> chars left
> DispRt CON $1C ' shift displayed
> chars right
> DDRam CON $80 ' Display Data RAM
> control
> CGRam CON $40 ' Custom character
RAM
> Line1 CON $80 ' DDRAM address of
> line 1
> Line2 CON $C0 ' DDRAM address of
> line 2
>
>
> '
--
>
> ' Variables
> '
--
>
>
> char VAR Byte ' character sent to
> LCD
> newChar VAR Byte ' new character for
> animation
> index1 VAR Byte ' loop counter
> index2 VAR Byte ' loop counter
>
>
> '
--
>
> ' EEPROM Data
> '
--
>
>
> Msg1 DATA "THE BASIC STAMP " ' preload EEPROM
with
> messages
> Msg2 DATA " IS VERY COOL! ", 3
>
> CC0 DATA $0E, $1F, $1C, $18, $1C, $1F, $0E, $00 '
> character 0
> CC1 DATA $0E, $1F, $1F, $18, $1F, $1F, $0E, $00 '
> character 1
> CC2 DATA $0E, $1F, $1F, $1F, $1F, $1F, $0E, $00 '
> character 2
> Smiley DATA $00, $0A, $0A, $00, $11, $0E, $06, $00 '
> smiley face
>
>
> '
--
>
> ' Initialization
> '
--
>
>
> Initialize:
> DIRL = %11111101 ' setup pins for LCD
>
> LCD_Init:
> PAUSE 500 ' let the LCD settle
> LCDbus = %0011 ' 8-bit mode
> PULSOUT E, 1
> PAUSE 5
> PULSOUT E, 1
> PULSOUT E, 1
> LCDbus = %0010 ' 4-bit mode
> PULSOUT E, 1
> char = %00101000 ' multi-line mode
> GOSUB LCD_Command
> char = %00001100 ' disp on, crsr
off,
> blink off
> GOSUB LCD_Command
> char = %00000110 ' inc crsr, no disp
> shift
> GOSUB LCD_Command
>
> Download_Chars: ' download custom
> chars to LCD
> char = CGRam ' point to CG RAM
> GOSUB LCD_Command ' prepare to write
CG
> data
> FOR index1 = CC0 TO (Smiley + 7) ' build 4 custom
chars
> READ index1, char ' get byte from
EEPROM
> GOSUB LCD_Write ' put into LCD CG
RAM
> NEXT
>
>
> '
--
>
> ' Program Code
> '
--
>
>
> Main:
> char = ClrLCD ' clear the LCD
> GOSUB LCD_Command
> PAUSE 250
>
> FOR index1 = 0 TO 15 ' get message from
> EEPROM
> READ (Msg1 + index1),char ' read a character
> GOSUB LCD_Write ' write it
> NEXT
>
> PAUSE 2000 ' wait 2 seconds
>
> Animation:
> FOR index1 = 0 TO 15 ' cover 16
characters
> READ (Msg2 + index1), newChar ' get new char from
> 2nd message
> FOR index2 = 0 TO 4 ' 5 characters in
> animation cycle
> char = Line2 + index1 ' set new DDRAM
> address
> GOSUB LCD_Command
> LOOKUP index2, [noparse][[/noparse]0, 1, 2, 1, newChar], char
> GOSUB LCD_Write ' write animation
> character
> PAUSE 50 ' delay between
> animation chars
> NEXT
> NEXT
>
> ' Two new lines of code
> PAUSE 250
> LCDIN 0, $C0 + 0, [noparse][[/noparse]char]
>
> PAUSE 1000
> GOTO Main
> ' do it all over
> END
>
>
> '
--
>
> ' Subroutines
> '
--
>
>
> LCD_Command:
> LOW RS ' enter command mode
>
> LCD_Write:
> LCDbus = char.HIGHNIB ' output high nibble
> PULSOUT E, 1 ' strobe the Enable
> line
> LCDbus = char.LOWNIB ' output low nibble
> PULSOUT E, 1
> HIGH RS ' return to
character
> mode
> RETURN
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the
Subject
> and Body of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
>
>
>
> This message has been scanned by WebShield. Please report SPAM to
> abuse@p...
BS2pe. I had tied it to ground after Jon's message, but quickly
reconnected to P2. For clarity, Jon didn't tell me to make that
change. It was my own thought to ground R/W.
I have made the switch in code as suggested by Jon.
Thanks,
Frank
--- In basicstamps@yahoogroups.com, "S Parkis" <parkiss@e...> wrote:
> Frank-
>
> The LCDIN instruction leaves the four data bus pins in input mode.
> Your LCD_Command and LCD_Write routines assume those pins are in
> output mode (they were placed in output mode wey are in output mode
> once by the DIRL statement). As a result, after executing the LCDIN
> your Stamp program is no longer controlling the output states of the
> data bus pins, and further attempted writes to the LCD are
> ineffective.
>
> It's one outcome of mixing the BS2 & BS2p* approaches as Jon
> remarked.
>
> You might also check the LCD's R/W* pin. It doesn't seem to be
> manipulated by your program, so the program may assume it's always
in
> the Write state. The circuit may be hardwired to accomplish that,
> which would mean you can't read from the LCD unless you run the
> wire from the R/W* pin to I/O 2 instead. Then manipulate it in
your
> own software (BS2 approach) or let the LCDIN/LCDOUT instructions
work
> for you (BS2p*).
>
> Regards,
>
> Steve
-- Jon Williams
-- Parallax
Original Message
From: franksmith512 [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=mt7YxsCBT6wXGdI7zZ9oqYPqb42QrvUdqkrwTYjGDH4I_nSq39iJB_XI_LRqofqyWjuB7HmviICnHcvtUg]franksmith512@y...[/url
Sent: Saturday, December 13, 2003 5:15 PM
To: basicstamps@yahoogroups.com
Subject: [noparse][[/noparse]basicstamps] Re: One Line Breaks Code?
Jon,
That is just sooo much better. I have already updated my project and
it now works great!
Thanks,
Frank
--- In basicstamps@yahoogroups.com, "Jon Williams" <jwilliams@p...>
wrote:
> At the bottom of the StampWorks product page:
>
> http://www.parallax.com/detail.asp?product_id=27297
>
> you will find a link to a ZIP file with the experiment files.
Inside
> there is a BS2p version of all the experiments. Start with that
since
> the BS2pe supports the same LCD commands as the BS2p. This would
be a
> better place to start than using BS2 code (that doesn't have native
> support for LCD).
>
> -- Jon Williams
> -- Applications Engineer, Parallax
> -- Dallas Office
>
>
>
Original Message
> From: franksmith512 [noparse][[/noparse]mailto:franksmith512@y...]
> Sent: Saturday, December 13, 2003 10:14 AM
> To: basicstamps@yahoogroups.com
> Subject: [noparse][[/noparse]basicstamps] One Line Breaks Code?
>
>
> Below is a copy of Exercise 12 from Stamp Works. These are the
lines
> I have added:
>
> ' Two new lines of code
> PAUSE 250
> LCDIN 0, $C0 + 0, [noparse][[/noparse]char]
>
> The stamp directive was modified to read:
> ' {$STAMP BS2pe}
>
> I am using a iNex 1000 24/40 board with a BS2pe.
>
> The unmodified code runs perfect. The modified code I think hangs
> the stamp. Anyway, all mods to the LCD stop.
>
>
> I have a larger program for a project of mine. The LCD wouldn't
> update. After deleting all the non-LCD code, I noticed what
remained
> was a modified version of Ex. 12.
>
> Changed two lines of Ex. 12 and bam. LCD quit updating.
>
> What do you think?
>
> Below is the offending code.
>
> Thanks,
> Frank
>
>
>
>
> '
>
======================================================================
> ========
> '
> ' File...... Ex12 - LCD Characters.BS2
> ' Purpose... Custom LCD Characters
> ' Author.... Parallax
> ' E-mail.... stamptech@p...
> ' Started...
> ' Updated... 01 MAY 2002
> '
> ' {$STAMP BS2pe}
> '
> '
>
======================================================================
> ========
>
>
> '
--
>
> ' Program Description
> '
--
>
>
> ' This program demonstrates custom character creation and animation
> on a
> ' character LCD.
> '
> ' The connections for this program conform to the BS2p LCDIN and
> LCDOUT
> ' commands. Use this program for the BS2, BS2e or BS2sx. There is
a
> separate
> ' program for the BS2p.
>
>
> '
--
>
> ' I/O Definitions
> '
--
>
>
> E CON 0 ' LCD Enable pin
(1
> = enabled)
> RS CON 3 ' Register Select
(1
> = char)
> LCDbus VAR OUTB ' 4-bit LCD data bus
>
>
> '
--
>
> ' Constants
> '
--
>
>
> ClrLCD CON $01 ' clear the LCD
> CrsrHm CON $02 ' move cursor to
home
> position
> CRSRLF CON $10 ' move cursor left
> CRSRRT CON $14 ' move cursor right
> DispLf CON $18 ' shift displayed
> chars left
> DispRt CON $1C ' shift displayed
> chars right
> DDRam CON $80 ' Display Data RAM
> control
> CGRam CON $40 ' Custom character
RAM
> Line1 CON $80 ' DDRAM address of
> line 1
> Line2 CON $C0 ' DDRAM address of
> line 2
>
>
> '
--
>
> ' Variables
> '
--
>
>
> char VAR Byte ' character sent to
> LCD
> newChar VAR Byte ' new character for
> animation
> index1 VAR Byte ' loop counter
> index2 VAR Byte ' loop counter
>
>
> '
--
>
> ' EEPROM Data
> '
--
>
>
> Msg1 DATA "THE BASIC STAMP " ' preload EEPROM
with
> messages
> Msg2 DATA " IS VERY COOL! ", 3
>
> CC0 DATA $0E, $1F, $1C, $18, $1C, $1F, $0E, $00 '
> character 0
> CC1 DATA $0E, $1F, $1F, $18, $1F, $1F, $0E, $00 '
> character 1
> CC2 DATA $0E, $1F, $1F, $1F, $1F, $1F, $0E, $00 '
> character 2
> Smiley DATA $00, $0A, $0A, $00, $11, $0E, $06, $00 '
> smiley face
>
>
> '
--
>
> ' Initialization
> '
--
>
>
> Initialize:
> DIRL = %11111101 ' setup pins for LCD
>
> LCD_Init:
> PAUSE 500 ' let the LCD settle
> LCDbus = %0011 ' 8-bit mode
> PULSOUT E, 1
> PAUSE 5
> PULSOUT E, 1
> PULSOUT E, 1
> LCDbus = %0010 ' 4-bit mode
> PULSOUT E, 1
> char = %00101000 ' multi-line mode
> GOSUB LCD_Command
> char = %00001100 ' disp on, crsr
off,
> blink off
> GOSUB LCD_Command
> char = %00000110 ' inc crsr, no disp
> shift
> GOSUB LCD_Command
>
> Download_Chars: ' download custom
> chars to LCD
> char = CGRam ' point to CG RAM
> GOSUB LCD_Command ' prepare to write
CG
> data
> FOR index1 = CC0 TO (Smiley + 7) ' build 4 custom
chars
> READ index1, char ' get byte from
EEPROM
> GOSUB LCD_Write ' put into LCD CG
RAM
> NEXT
>
>
> '
--
>
> ' Program Code
> '
--
>
>
> Main:
> char = ClrLCD ' clear the LCD
> GOSUB LCD_Command
> PAUSE 250
>
> FOR index1 = 0 TO 15 ' get message from
> EEPROM
> READ (Msg1 + index1),char ' read a character
> GOSUB LCD_Write ' write it
> NEXT
>
> PAUSE 2000 ' wait 2 seconds
>
> Animation:
> FOR index1 = 0 TO 15 ' cover 16
characters
> READ (Msg2 + index1), newChar ' get new char from
> 2nd message
> FOR index2 = 0 TO 4 ' 5 characters in
> animation cycle
> char = Line2 + index1 ' set new DDRAM
> address
> GOSUB LCD_Command
> LOOKUP index2, [noparse][[/noparse]0, 1, 2, 1, newChar], char
> GOSUB LCD_Write ' write animation
> character
> PAUSE 50 ' delay between
> animation chars
> NEXT
> NEXT
>
> ' Two new lines of code
> PAUSE 250
> LCDIN 0, $C0 + 0, [noparse][[/noparse]char]
>
> PAUSE 1000
> GOTO Main
> ' do it all over
> END
>
>
> '
--
>
> ' Subroutines
> '
--
>
>
> LCD_Command:
> LOW RS ' enter command mode
>
> LCD_Write:
> LCDbus = char.HIGHNIB ' output high nibble
> PULSOUT E, 1 ' strobe the Enable
> line
> LCDbus = char.LOWNIB ' output low nibble
> PULSOUT E, 1
> HIGH RS ' return to
character
> mode
> RETURN
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the
Subject
> and Body of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
>
>
>
> This message has been scanned by WebShield. Please report SPAM to
> abuse@p...
To UNSUBSCRIBE, just send mail to:
basicstamps-unsubscribe@yahoogroups.com
from the same email address that you subscribed. Text in the Subject
and Body of the message will be ignored.
Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
This message has been scanned by WebShield. Please report SPAM to
abuse@p....
wasn't paying attention to connections; I thought it best to start at
the bottom and work upward.
-- Jon Williams
-- Parallax
Original Message
From: franksmith512 [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=82KCyxrIt9SGdDMosSPFjnoLA9hOv-ZJYudpOmf2w_XrXW-H3DKPLyArS7KY4EYPN-iBwNNk9HfejPuBW1aLpQ]franksmith512@y...[/url
Sent: Saturday, December 13, 2003 5:21 PM
To: basicstamps@yahoogroups.com
Subject: [noparse][[/noparse]basicstamps] Re: One Line Breaks Code?
Steve, The R/W pin is apparrently still being manipulated by the
BS2pe. I had tied it to ground after Jon's message, but quickly
reconnected to P2. For clarity, Jon didn't tell me to make that
change. It was my own thought to ground R/W.
I have made the switch in code as suggested by Jon.
Thanks,
Frank
--- In basicstamps@yahoogroups.com, "S Parkis" <parkiss@e...> wrote:
> Frank-
>
> The LCDIN instruction leaves the four data bus pins in input mode.
> Your LCD_Command and LCD_Write routines assume those pins are in
> output mode (they were placed in output mode wey are in output mode
> once by the DIRL statement). As a result, after executing the LCDIN
> your Stamp program is no longer controlling the output states of the
> data bus pins, and further attempted writes to the LCD are
> ineffective.
>
> It's one outcome of mixing the BS2 & BS2p* approaches as Jon remarked.
>
> You might also check the LCD's R/W* pin. It doesn't seem to be
> manipulated by your program, so the program may assume it's always
in
> the Write state. The circuit may be hardwired to accomplish that,
> which would mean you can't read from the LCD unless you run the wire
> from the R/W* pin to I/O 2 instead. Then manipulate it in
your
> own software (BS2 approach) or let the LCDIN/LCDOUT instructions
work
> for you (BS2p*).
>
> Regards,
>
> Steve
To UNSUBSCRIBE, just send mail to:
basicstamps-unsubscribe@yahoogroups.com
from the same email address that you subscribed. Text in the Subject
and Body of the message will be ignored.
Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
This message has been scanned by WebShield. Please report SPAM to
abuse@p....