Usart removing 13,10

Coding and general discussion relating to the compiler

Moderators: David Barker, Jerry Messina

Post Reply
be80be
Registered User
Registered User
Posts: 90
Joined: Mon Feb 23, 2009 2:15 am
Location: tn

Usart removing 13,10

Post by be80be » Mon Dec 20, 2010 6:28 am

I been playing with Usart want to send received data out to a lcd

It send it but i get junk to

So how would I get rid of the control terminator character

Code: Select all

SetBaudrate(br19200)
While true
   LCD.Write(ReadByte)
Wend

User avatar
David Barker
Swordfish Developer
Posts: 1214
Joined: Tue Oct 03, 2006 7:01 pm
Location: Saltburn by the Sea, UK
Contact:

Post by David Barker » Mon Dec 20, 2010 9:13 am

Try reading the character into a byte variable, then apply an if statement.

be80be
Registered User
Registered User
Posts: 90
Joined: Mon Feb 23, 2009 2:15 am
Location: tn

Post by be80be » Mon Dec 20, 2010 10:59 am

Would something like this work or am I even close

Code: Select all

Dim chars As Byte

SetBaudrate(br19200)

chars = USART.ReadByte() 

Select  chars
		Case 0
			'do nothing
		Case 13
			MoveCursor(2,1)
            LCD.Cls
		Case 27
			MoveCursor(1,1)
			LCD.Cls
		 Else
			LCD.Write(chars)
EndSelect


be80be
Registered User
Registered User
Posts: 90
Joined: Mon Feb 23, 2009 2:15 am
Location: tn

Post by be80be » Mon Dec 20, 2010 1:08 pm

I'm not sending gunk no more just need to to be able the clear LCD and change lines

User avatar
Senacharim
Posts: 139
Joined: Tue Aug 10, 2010 5:19 pm
Location: Ventura, CA

Post by Senacharim » Mon Dec 20, 2010 1:42 pm

Have you read thru the LCD's specifications? Usually the manufacturer provides a full set of interface commands & options, which makes excellent reference material for such activities.

Also, out of curiosity, which LCD is it? If you happen to be using the same one I'm using, I probably have a module you could adapt to your needs.
Surviving Member
Bermuda Triangle Battalion
from 2026 to 1992

Voted "Most likely to time travel"--Class of 2024.

be80be
Registered User
Registered User
Posts: 90
Joined: Mon Feb 23, 2009 2:15 am
Location: tn

Post by be80be » Mon Dec 20, 2010 3:32 pm

The lcd is not the problem usart is where I'm weak in

I'm using a Hitachi 44780 i no the commands for that

what I don't know is what usart sends 13,10 CR and LF

but when it received there has to be more like #13 I have seen that used

but not sure.

User avatar
Senacharim
Posts: 139
Joined: Tue Aug 10, 2010 5:19 pm
Location: Ventura, CA

Post by Senacharim » Mon Dec 20, 2010 3:38 pm

The USART only sends what you tell it to send. Easy as that, really.
Surviving Member
Bermuda Triangle Battalion
from 2026 to 1992

Voted "Most likely to time travel"--Class of 2024.

be80be
Registered User
Registered User
Posts: 90
Joined: Mon Feb 23, 2009 2:15 am
Location: tn

Post by be80be » Mon Dec 20, 2010 10:32 pm

Senacharim wrote:The USART only sends what you tell it to send. Easy as that, really.
That would be true if I was sending pic to pic but I'm not thats the problem

I'm sending data from the computer to the pic and displaying that with a LCD

I can't figure things out like (line feed)

10 ^J is that what I should test for haven't tried that

But that would only work if I was typing at a terminal

I think I should test readbyte for things like line feed before I change them to a byte.

User avatar
Senacharim
Posts: 139
Joined: Tue Aug 10, 2010 5:19 pm
Location: Ventura, CA

Post by Senacharim » Mon Dec 20, 2010 10:59 pm

Oh! Every time I set up something from PC to PIC, I've found it necessary to throw in a short delay (1 millisecond is usually plenty) between every byte sent, regardless of the baud rate I'm using.

Also, unless your two baud rates match, you're better off receiving a 'chunk' of data (my LCD holds 32 characters, therefore I use a 32 character array) and then putting the data on the LCD screen.

Hope this helps. I had to dig that experience out of bare silicon myself--with tools I myself fashioned.
Surviving Member
Bermuda Triangle Battalion
from 2026 to 1992

Voted "Most likely to time travel"--Class of 2024.

be80be
Registered User
Registered User
Posts: 90
Joined: Mon Feb 23, 2009 2:15 am
Location: tn

Post by be80be » Tue Dec 21, 2010 9:42 pm

Here some great stuff PC to PIC using serial ports

http://www.lvr.com/serport.htm

And
http://www.me.umn.edu/courses/me2011/sm ... ort-vb.pdf

Post Reply