PDA

View Full Version : Simple serial debug script



barkerben
- 4th November 2005, 13:38
Hi - I have the following debug code for software serial output. Unfortunately, I seem to receive garbage, albeit consistent garbage, at the
PC. This ixample gives me underscores only at the PC end for instance.

It seems so simple- any glaring errors? Could it be that I'm using the hardware serial pins, even though I'm actually using them for software serial...?

Cheers,

Ben

<code>
' PicBasic program to demonstrate operation of an LCD in 4-bit mode
'
' LCD should be connected as follows:
' LCD PIC
' DB4 PortA.0
' DB5 PortA.1
' DB6 PortA.2
' DB7 PortA.3
' RS PortA.4 (add 4.7K pullup resistor to 5 volts)
' E PortB.3
' RW Ground
' Vdd 5 volts
' Vss Ground
' Vo 20K potentiometer (or ground)
' DB0-3 No connect

Include "modedefs.bas"

' Set LCD Enable port
DEFINE LCD_EREG PORTB

' Set LCD Enable bit
DEFINE LCD_EBIT 5


PORTB.7=0 ' Reset GPS Module
Pause 500 ' Wait for LCD to startup
PORTB.7=1 ' Reset GPS Module


loop: Lcdout $fe, 1 ' Clear LCD screen
Lcdout "Hello" ' Display Hello
SEROUT PORTB.1,N300,["A"]
SEROUT PORTB.2,N300,["B"]
Pause 500 ' Wait .5 second

Lcdout $fe, 1 ' Clear LCD screen
Lcdout "World"
Pause 500 ' Wait .5 second


Goto loop ' Do it forever

</code>

Kamikaze47
- 6th November 2005, 16:10
might not help, but im sure this line " DEFINE LCD_EBIT 5" should be "DEFINE LCD_EBIT 3" (At least if uve got the lcd connected the way it says in those comment lines at the top)

barkerben
- 6th November 2005, 16:12
Ah - The comments are a leftover from some code I scavenged. I believe that
pin 3 port B is the default for the enable bit, but I had to change it.

I did get the serial working - hope to try the LCD again in a day or so when I next get the chance...

Ben