sending character to lcd 2x16 parallax the lcd giving incorrect characters to input
cc_builder
Posts: 12
I have to use basic assembler language to send characters to LCD,
I have got a code written , but i don't get the correct symbol back. I keep getting '/' symbol for all spaces
the lcd is connected to portb7
I'm using of baud 9600,
Therefore the delay is 104us
code is attached
Any advice greatly appreciated
lcd2.asm
I have got a code written , but i don't get the correct symbol back. I keep getting '/' symbol for all spaces
the lcd is connected to portb7
I'm using of baud 9600,
Therefore the delay is 104us
code is attached
Any advice greatly appreciated
lcd2.asm
Comments
I think that if you aren't inverting, a start bit is actually a "1", and then a stop bit is a "0"
and is the DDRB being set properly? you're setting the MSB of Port B to output, if 1 means output for that register.
basically DDRB = 0B10000000 (same as 0x80), as in bit 7 of that port's direction register is being set to 1.
but then comes the "OUT PORTB, data_temp", in which the data is being ANDed with 0x01 from r24
this is setting B0 to the present bit, but setting all the other bits in the output register (B1 thru B7) to 0.
so what I'm saying is, first determine what bit of PORTB you want to be using, B0 or B7?
we are sending bit 0 first
therefore portb7 would be a output.
what the program is suppose to:
for take the char '1' which 00110001
we want to send either 1 or 0 each time to the lcd.
so therefore we AND 0000 0001
so the bit 0 is going to be sent first.
then shift right so you get 00011000
and 000000001 giving you 0 and send it out
and repeat for each bit.
therefore your sending 0000 0000 or 00000001
I'm keep getting ' \' which is decimal 92, doesn't matter what data i put
also look at this diagram:
http://en.wikipedia.org/wiki/File:Rs232_oscilloscope_trace.svg
yes, correct. but that rightmost bit is typically the LSB, which will be B0 of Port B on any processor that I know of, and not B7.
looking here, where you had set r1 to 0xFF way earlier (clr r1 ; dec r1):
is causing B7 to be set to 1, the bit being driven as output because of how DDRB was set. (ldi temp,0B10000000 ; out DDRB, temp)
then sometime later port B is being set back to 0.
This signal transition is enough for a serial device connected to B7 to interpret it as some sort of data. Some kind of 0->1->0 transition shorter than 9 bits will make a serial device think it's receiving a character.
so it doesn't have any effect or find ldi 225 to a register than out it
and then wire the portB0 pin to the LCD 2x16, not portB7.
if you are required to use portB7 you will need to rewrite all of "serial_out:"
Custom Character 0 for the Parallax Serial LCD is backslash or \. If you send a code 0 to the LCD then backslash will appear.
Also, the Parallax LCD uses true serial (0 is a 0, 1 is a 1), not inverted voltages such as in RS-232.
So therefore i have to bit 0 put in bit 7,
then and it with 1000 0000
then send it ?
then rotating the carry in bit7
but how do i move the carry to bit7
I got it working, now im getting the wrong characters i'm tried fixing it i either get the incorrect high or lower bits.
In the code below
when i put 00110010 suppose to be 2 i get 9.
any suggestion on fixing , i'm assuming i'm loading a bit wrong but i'm can't figure it out any help
greatly appreciated
for 9600 8N1 you need to send 10 total bits.
a start bit of "1" comes before bit 0 of data
a stop bit of "0" comes after bit 7 of data
when i put hexadecimal 32, i get 34 instead of2
when i put 33 i get 3C
it looks like you had it right with the start bit being "0", and then the stop bit being "1"
start out at the "1" level like this:
then start bit is:
out PORTB,r0
then stop bit is:
out PORTB,r1
does it still display characters close to what you want with it this way?
maybe it has to do with the clock frequency source... is it a resonator, crystal, or internal RC oscillator?
maybe it has to do with adjusting the 100us wait. for 9600 baud it's really something more like 104us, but over ten bits that would only be off by 4 * 10 = 40 us
if its just a wire out from a pin on port B7 to RX on the LCD, with nothing in between like an inverter or RS232 signal chip, then according to the documentation, the signal line should be normally at "1" level, then dip down to 0 for a start bit, then send 8 bits, then go back up to 1 for the stop bit. This is what you're doing.
I am pretty confident your Carry bit isn't getting overwritten by any instructions in-between the ROR's in the code you've posted.