Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Receive string '?f' and clear the LCD in PIC16F628

Status
Not open for further replies.

storage

Junior Member level 1
Joined
Feb 21, 2011
Messages
16
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,373
How to convert PHP to C++ coding?

Is there a program which provides this compiling method?
 
Last edited:

Anyone know how would I write the command for '?f' string to erase my whole LCD?
 

It isn't clear what you want. Are you trying to send two characters "?" then "f" as a command to start an LCD clearing routine or are you trying to send them directly to the LCD?

And why on Earth are you using a software UART when there is a hardware one inside the PIC? Using the hardware one makes the code MUCH easier to write and far more reliable, particularly as you are also using blocking delay routines.

Brian.
 

Is there a program which provides this compiling method?
 
Last edited:

If I understand, you just said that wrong, just sending 'f' or 'g' would print those character son the LCD rather than treat them as instructions. I think what you are trying to do is use the '?' to indicate the next character is an instruction.

Basically, just look for the '?' from your receive routine and when you find it, drop into a routine that again waits for a character, decodes it and performs the action you require. However, I have reservations about your timing routines and it might not work as you intended. With the software UART you are using, it is essential you are monitoring the input state at a constant rate or you will miss any character arriving. Consider that while in your delay routine, transmitting or while writing to the LCD, you are vulnerable to losing bits in the input stream. A much better way of doing it is to use the hardware UART and interrupts. The code will be smaller and can be doing something else while still receiving serial data. An interrupt will alert your program when all 8 bits of data have been received and is ready to use, you don't have to do any timing code or loops at all.

Brian.
 

Is there a program which provides this compiling method?
 
Last edited:

1. Add a new variable to the cblock, lets call it "CmdMode". We will make this = 1 if a '?' is received.
2. Call the rcv_RS232 routine to get a character from the serial input.
3. Compare it to '?' and if it matches, make CmdMode = 1. Hint: subtract or XOR the received value with '?' and check the Z flag in the STATUS register.
4. When you call rcv_RS232, check if CmdMode = 1 and the character is 'f', if both are true, call 'LCD_Clr' to clear the display then 'clrf CmdMode' so the next character works as normal.

I still think you will have problems. The RS232 routines are 'real-time', they will not wait for data to arrive so you must constantly call rcv_RS232 to make sure you don't miss anything. While in the delay routines or waiting for the LCD to go ready, the serial input will not be monitored. Think of the data arriving constantly on a conveyor belt, if you aren't there to off load it all the time things fall off the end and are lost. Using the USART interrupt is easy and will overcome this problem.

Brian.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top