PDA

View Full Version : HSEROUT to LCD with 16F887



menta
- 24th June 2008, 18:07
I'm trying to use my LCD (PIB-216) with the USART.
According to the data sheet the TX output is RC6.
I tried this code but I only see garbage. Maybe the codes I send ae wrong.
Please advice.



DEFINE HSER_TXSTA 24h
DEFINE HSER_SPBRG 25 ' 9600 Bauds

PAUSE 2000
HIGH PORTD.7
HSEROUT [254,128,65,65]
END

Archangel
- 24th June 2008, 19:03
Hi Menta,
is the serial LCD set to receive true?

menta
- 24th June 2008, 20:18
What do you mean ?

If I connect the LCD on portB.1 and send
SEROUT PORTB.1,6,[254,131,#HH,58]
It display correctly.

menta
- 24th June 2008, 20:43
I connected PORTC.6 to RB7 (the PICkit 2 UART tool serial input)
and I see ???????? when the HSEROUT command is printing.

menta
- 24th June 2008, 21:02
ok, I have managed to see the correct data that was send by HSEROUT in the PICkit2 UART tool when setting 2400 baud. I also changed the LCD mode to 2400, but it still show junk.


DEFINE HSER_TXSTA 10100000b
DEFINE HSER_BAUD 2400
DEFINE HSER_SPBRG 25 ' 2400 Bauds

PAUSE 2000
HIGH PORTD.7
main:
HSEROUT [65,13,10]
PAUSE 2000
goto main

Archangel
- 25th June 2008, 02:18
You can send data through a serial link either TRUE or INVERTED. I am sure using HSEROUT the data is always true, whereas your serial LCD may be either true or inverted, if your serial LCD is set to accept data in inverted form, then you will see characters looking like gibberish.
<br>
You say this works:SEROUT PORTB.1,6,[254,131,#HH,58]<br>
the 6 is telling me N9600 baud, which is inverted so you must reset in software the serial backpack to accept TRUE in order to read properly.

menta
- 25th June 2008, 07:46
From the HSEROUT help:
"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. "
http://www.melabs.com/resources/pbpmanual/5_27-5_29.htm

Archangel
- 25th June 2008, 16:05
I am not suggesting hserout will do anything but, what the book says. Now read carefully: You must change the <font color=BLUE> serial backpack's ability</font color> <font color=red> to RECEIVE from inverted to TRUE</font color> <b>BECAUSE,</b>"the serial transmission is done in hardware, it is not possible to set the levels to an inverted state to . . . ."

skimask
- 25th June 2008, 18:15
"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. "

Like Joe said...listen very carefully...

SERIN/SERIN2/SEROUT/SEROUT2/DEBUG/DEBUGIN - software driven
You can set the modes, normal, inverted, whatever. Totally and completely driven by software. You can emulate the logical levels of standard RS232, but not the actual voltages present in standard RS232 (i.e. inverted)...or... You can emulate the logic levels and voltage levels of what is sometimes called TTL-RS232 (i.e. normal)...

HSERIN/HSERIN2/HSEROUT/HSEROUT2 - hardware driven
You can NOT the modes here, only the baud rates, bits per character, and a few other parameters. This is completely driven by the hardware inside the PIC. There is NO inversion anywhere inside the PIC, whether it be thru hardware or software. With HSERxxx commands, you can also emulate the logical levels of standard RS232, but again, not the voltage levels. BUT!!! The output from the PIC is (as described above) sometimes called TTL-RS232 (i.e. normal).

In short, HSERxxx - needs a MAX232 device if talking to an RS232 compliant device. May or may not need a MAX232 type device if talking to any other type device (i.e. directly to another PIC. What drives a Serial LCD? Anyone?).

SERxxx - may or may not need a MAX232 type device depending on the application.

So, take your project, figure out what it's outputting, take the device you're talking to, figure out what it wants, take your project again and change it to match...

Archangel
- 25th June 2008, 23:31
So, take your project, figure out what it's outputting, take the device you're talking to, figure out what it wants, take your project again and change it to match...According to his post <b>#3</b> his serial LCD is accepting N9600, he need to read the data sheet for that device and change it to Txxxx to use HSEROUT. Most likely it requires moving a shorting block on a three pin header.

menta
- 26th June 2008, 00:12
from the LCD data sheet:
"Serial input...............RS-232, or inverted TTL/CMOS, 2400 or 9600, N81"
http://www.seetron.com/pdf/bpi_bpk.pdf

I do not see any documentation beside changing the speed from 2400 to 9600 using the SW on its back.

skimask
- 26th June 2008, 03:53
from the LCD data sheet:
"Serial input...............RS-232, or inverted TTL/CMOS, 2400 or 9600, N81"
http://www.seetron.com/pdf/bpi_bpk.pdf

I do not see any documentation beside changing the speed from 2400 to 9600 using the SW on its back.

Exactly...so...read it again...the backpack takes RS232 or inverted TTL/CMOS, which if you have read my last post completely and understood it, you would know that from a logic level standpoint (not a voltage level) RS232 = inverted TTL.

Therefore, without any external hardware, only one subset of the PBP serial format communication commands can successfully communicate with this LCD module.

So, to quote myself once again...
SERIN/SERIN2/SEROUT/SEROUT2/DEBUG/DEBUGIN - software driven
You can set the modes, normal, inverted, whatever. Totally and completely driven by software. You can emulate the logical levels of standard RS232, but not the actual voltages present in standard RS232 (i.e. inverted)...or... You can emulate the logic levels and voltage levels of what is sometimes called TTL-RS232 (i.e. normal)...

HSERIN/HSERIN2/HSEROUT/HSEROUT2 - hardware driven
You can NOT change the modes here, only the baud rates, bits per character, and a few other parameters. This is completely driven by the hardware inside the PIC. There is NO inversion anywhere inside the PIC, whether it be thru hardware or software.

In short:
HSERxxx - needs a MAX232 device if talking to an RS232 compliant device. May or may not need a MAX232 type device if talking to any other type device (i.e. directly to another PIC. What drives a Serial LCD? Anyone?).

SERxxx - may or may not need a MAX232 type device depending on the application.

skimask
- 26th June 2008, 03:54
According to his post <b>#3</b> his serial LCD is accepting N9600, he need to read the data sheet for that device and change it to Txxxx to use HSEROUT. Most likely it requires moving a shorting block on a three pin header.
Can't do that with this particular module. Only takes RS232 (inverted) inputs.

menta
- 26th June 2008, 09:18
Thanks....

Darrel Taylor
- 26th June 2008, 18:05
You can use a single transistor and a couple resistors to invert the signal from the USART.

You don't have to go with a full MAX232.
DT