Serial Flow control
I will have two serial ports and wish to poll them for incoming data. However, when I use RX_BYTE to collect a byte from one of the ports it hangs there until data arrives. How do I tell the microcontroller to move on when no data is at the port?
marshall hall edgell
marshall hall edgell
Comments
RX_BYTE could be anything...
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Did you know that 111,111,111 multiplied by 111,111,111 equals 12345678987654321 ?
www.iElectronicDesigns.com
·
RX_BYTE:
'USE: RX_BYTE port
temp1 = __PARAM1 'Which port
IF temp1 = DB9Port THEN
SERIN RX_DB9, Baud, temp3 'incoming byte into temp3, later add code for USB
ENDIF
RETURN temp3
marshall
If you expect the SX chip to buffer any serial data coming into it in the back ground so you can do other things then you'll probably want to look at JohnyMac's ISR based serial routines. It normally watches just one serial line but I suppose with some work you could watch two ports and have a dedicated buffer for each one. Since it keeps track of the number of items in the receive buffer you can just check that. If the count is 0 just continue on.
I did something similar to that with just a single Serial input. It does it in the background. If anything does come in then it is processed. You can see the example code from the April 2008 issue of SERVO:
www.servomagazine.com/downloads.php?year=2008
Robert
When I search on the forum for JohnyMac I only get your msg. Where should I look for those routines?
marshall
Post Edited (JonnyMac) : 5/27/2008 9:49:12 PM GMT
That was because I made a typo in the name. Sorry about that. Looks like the answer is in this thread now anyhow...
Robert