sayzer, that is correct. I'm not entirely sure that is the problem that Ryan7777 is having, but he will experience it at some point.
Providing a timeout make the code more resilient to problem as they occur.
sayzer, that is correct. I'm not entirely sure that is the problem that Ryan7777 is having, but he will experience it at some point.
Providing a timeout make the code more resilient to problem as they occur.
Ryan,
Serial to Parallel LCD is one of the easiest things you can do with a PIC. But you're making it harder than it needs to be.
All of the initialization of the LCD is handled by PicBasic Pro. You don't need all that stuff in-between Main: and goto main2.
Simple initialization...Next, you are sending ASCII numbers from the BS2, so they are ready to display. Converting the ASCII to a WORD, then converting the WORD back to ASCII is counter productive and just waists time that you need since the data is comming in faster than it can do the conversions.Code:LCDOUT $FE, 1 PAUSE 500
Also, by converting to words, it eliminates the possibility of sending Commands, which you'll need to do, to move the curson to where you want to put the text.
All you really need to do is receive 1 byte at a time, and pass it on to the LCDOUT command.While that will get you closer to what you want, you really should use the USART with HSERIN. There's not much time between incomming characters, and if they are sent too fast from the BS2 (can't imagine a BS2 being FAST), you might miss a character. If that happens you can add some CHAR Pacing on the BS2 to slow things down a bit. But if you use HSERIN, you won't have to worry about it.Code:LCDloop: SERIN2 PORTB.0, 16780, [INbyte] LCDOUT INbyte GOTO LCDloop
For the USART, you don't need a MAX232, just make the BS2 send RS232 in TRUE mode, instead of inverted.
DT
thank you all for the replys!
You guys sure do love the usart, I'll more than likely be using it, but for now im using serin2. Im using the internal osc and i was told the USART can cause problems if running at 4mHz, also i dont feel like extra hardware while just playing around on the breadboard.. (i.e Xtal, MAX232 and all the caps... ) but i will keep it in mind when i move on to building something final. also dont need the time out yet, im still trying to get a grasp on the code at hand, there wouldnt be anywhere to jump to atm... the following code is working as before, (T.Y. Ben) i still get garbage after my text like:
hello█ █ █ █ █ █ █ █ █ █ █ █ █ █
which im guessing is the leftover array bytes all set to zero, which is a predefined character in my LCD which happens to be a big black block with some of its upper pixels missing (?) any idea's how to get around that? (getting rid of holder = 0 does nothing, still get the same result)
also if i do what Darrel says, what do i send the PIC? could you give me an example of what i should be sending it, and what will come out on my LCD?
maybe $48,$45,$4C,$4C$4F (hello)?
holder VAR BYTE[20]
LCDOUT $FE, 1
PAUSE 1000
main:
holder = 0
SERIN2 PORTB.0, 16780, [ str holder\20\13]
LCDOUT $FE,1, STR holder\20
PAUSE 2000
goto main:
BS2p Pbasic Code:
Start:
SEROUT 0,17405, ["hello",13]
PAUSE 1000
GOTO Start:
A couple of things about what you have.
First off holder=0 doesn't really do anything. I would suspect you were hoping it would make all the bytes 0 in the array. That isn't the case. You would need to create a loop that places a zero in each byte of the array. Second, you don't have a timeout. Without a timeout, you run the real possibility the code will stall.
I altered the code to address some of the issues you are running into. Keep in mind there are a least 3 different ways (maybe more) to accomplish what you are asking. It’s really a matter of style and application, neither of which I can decide for you. In this version of the code, I added length and command. Command handles the command portion of LCDOut (see manual). Length tells the string command when to stop. This should eliminate the blocks. Using this approach, you need to expand the string you are sending from the stamp. (See below) If you didn’t want to specify a length you would need to create a loop to collect the data byte by byte and then use the terminating character that was in the code before. Here again both work, it depends on style and application. Enjoy.
In regards to HSERIN, like the rest of us you will eventually run into a problem and you will need to use hserin to solve it. Usually this occurs when your code starts doing other things and polling for serial data becomes impractical. We all get there at some point.Code:Holder var byte[20] Length var byte Command var byte main: serin2 PORTB.0, 16780, Data_Error,[Command, Length ,STR holder\20\Length] LCDOUT $FE,Command, STR holder\Length goto main BS2p Pbasic Code: Start: SEROUT 0,17405, [1,5,"hello"] ‘ 1=LCD Clear, 5=Length of hello PAUSE 1000 GOTO Start
Last edited by DynamoBen; - 5th October 2006 at 16:48.
Bookmarks