PDA

View Full Version : lcd with Hserout and a max232 connections? help



flipper_md
- 1st March 2008, 20:36
Hello

I wanted to drive my serial LCD with Hserout (for a test), on a pic16f628a, but I can't seem to shoot understandable data on the tx line.

First I realised it wanted an inverter, so I plugged a Max232, and used only the inverter feature(removed capacitor on the -10 +10 v port... multimeter agreed it does the job).

But i'm still getting trash data on the display...

here is the code
:
' Initialize USART
input portb.1
output portb.2
RCSTA = %10010000 ' Enable serial port and continuous receive
TXSTA = %00100000 ' Enable transmit and asynchronous mode
define HSER_BAUD 9600
define HSER_CLROERR 1

hserout [12,"* LED FADER *"]


see jpeg for circuit layout (may be wrong...)

http://www.picbasic.co.uk/forum/attachment.php?attachmentid=2384&stc=1&d=1204400100

BrianT
- 2nd March 2008, 23:09
I found that I needed to set the RS-232 drive pin high some milliseconds before sending data. Otherwise I just got a string of gibberish on the terminal.

This is to put the RS232 output low which is the defined MARK or IDLE condition for the RS-232 interface.

Try something like...

High portb.2
pause 5
hserout [12,"* LED FADER *"]

HTH
BrianT

flipper_md
- 5th March 2008, 17:58
Tnx Brian

for some reasons I still get garbage when sending text string(even with your trick), but single characters as in the following code appear ok...(I see a bunch of lowercase alphabet char)

For cycle = 25 to 70
hserout [12,cycle]
serout PortLCD, N9600, [12,"Hserout loop ",#cycle]
Pause 200
next

skimask
- 5th March 2008, 18:20
For cycle = 25 to 70
hserout [12,cycle]
serout PortLCD, T9600, [12,"Hserout loop ",#cycle]
Pause 200
next

???

flipper_md
- 5th March 2008, 19:35
I was just testing sending char thru serial Hardware...

Actually it's 33 to 58 that gives a to z in lower case, to be exact, and it's supposed to be 97 to 122 according to documentation.


regular Serout is doing the job perfect.

falingtrea
- 6th March 2008, 20:32
FYI, if you are really using the meLabs Serial LCD, you don't need the Max part. According to the data for the Serial LCD there is a jumper that will change the input polarity(JP3). Here is what the manual says about HSER signals :

"Since the serial transmission is done in hardware, it is not possible to set
the levels to an inverted state to eliminate an RS-232 driver. Therefore a
suitable driver should be used with HSEROUT."

Also, I would be very careful about trying to do both HSER and SER commands to the same pin. The hardware serial expects a specific pin to be used, and if the pin is connected to the UART, it may not be usable as a standard I/O. Try taking out the SEROUT code and just run it with HSEROUT.

Another bit from the PBP manual:

"All baud rates at all oscillator speeds may not be supported by the device. See the Microchip data sheet for the hardware serial port baud rate tables and additional information."

This means you need to double check the data sheet if you are using any crystal freq other than 4 MHz.

flipper_md
- 8th March 2008, 16:06
You just reminded me of that *Rx port on the LCD. Went in the spec sheet and as you said, it's a inverted rs-232 port. 8)

Hooking that up strait the the Hserout pin yield something different, telling me that it's a timing issue going on with Hserout.

I can now get some Uppercase characters showing up when asking for 33 to 58 char range , but it's randomly working and only when trying to output 1 char at time.
LCD will show :
"ABcdefGHijklmnop
qrstuvwxyz"

(Strings still show tons of garbage) like hserout [12,"* LED FADER *"]

I dunno if Hserout is less tolerant than serout, or my code is not correct, but it feel strange that a dedicated mcu serial port cannot drive a lcd display.


thanks for the inverted port reminder, as the max232 takes a lot of space for such a small function!