PDA

View Full Version : SLCD Baud Rate Problem



kiwipiper
- 16th October 2007, 05:28
Greetings All,

I have been trying to get the 16 x 2 Serial LCD Display from Renolds to work with my PIC16F628A so that I can display sensible output which would help with my other experiments.

I finally got it to work on a Basic Stamp BS2p (major success). Code at bottom of message - as you can see it is pretty basic at this stage but it took me a long time to get this working.

The question is how do I replicate this on my PIC with a 4MHz Oscillator.

I tried the second lot of code at bottom of message, and got funny characters appearing so I figure I am pretty close just an issue with the baud rate.

I also found if I followed other examples (and in the documentation) and put in a N9600 I got a BAD EXPRESSION ERROR. What is that all about.

Thanks in advance.

Cheers Bruce

=== STAMP CODE ==================================================

' {$STAMP BS2p}
' Author: Bruce Sim
' Description: Just trying to show something on the SLCD Display
' Date: 16 Oct 2007

PAUSE 2000

start:

SEROUT 0, 16624, [$1b, $2a, $80] ' Set LCD backlight TO about half brightness
PAUSE 500
SEROUT 0, 16624, [$1b, $30] 'Clear screen AND move cursor TO start of first line
PAUSE 500
SEROUT 0, 16624, [$1b, $42] ' Turn on blinking cursor
PAUSE 500
SEROUT 0, 16624, [$1b, $55] ' Turn on underline cursor
PAUSE 500
SEROUT 0, 16624, ["Hello Bruce", CR] 'Display Text
PAUSE 1000
SEROUT 0, 16624, [$1b, $30] 'Clear Screen
PAUSE 500
GOTO start

=== PIC Code ==================================================

' {PIC 16F628A - with 4MHz Oscillator}
' Author: Bruce Sim
' Description: Just trying to show something sensible on the SLCD Display
' Date: 16 Oct 2007

PAUSE 2000

DEFINE OSC 4

start:

SEROUT 0, 9600, [$1b, $2a, $80] ' Set LCD backlight TO about half brightness
PAUSE 500
SEROUT 0, 9600, [$1b, $30] 'Clear screen AND move cursor TO start of first line
PAUSE 500
SEROUT 0, 9600, [$1b, $42] ' Turn on blinking cursor
PAUSE 500
SEROUT 0, 9600, [$1b, $55] ' Turn on underline cursor
PAUSE 500
GOTO start

Bruce
- 16th October 2007, 06:06
Check your PBP manual for SEROUT baud modes. SEROUT 0,9600 is not valid for SEROUT.

SEROUT 0, 16624 for the BS2p is 9600 baud, driven, inverted. To match this with PBP just
look up the baud mode number for 9600 baud, driven, inverted. SEROUT 0, 6 would output
serial data on RB0 at 9600 baud, driven, inverted.

If you include "modedefs.bas", then you could use SEROUT 0,N9600 which is somewhat
easier when porting code from Stamps to PBP.

kiwipiper
- 16th October 2007, 08:34
Greetings Bruce

Exactly what I needed thank you very much.

Cheers Bruce