2010年1月7日 星期四

[pic18net] UART processing

============================================================
(2010/01/07 updated)


1. befor receiving in by UART (ex, ReadUART() function call)..
MUST do the below process:
while(!DataRdyUART());


(Receiving UART-msg by one-byte, "c")

//Receive a byte
while(!DataRdyUART());
c = ReadUART();



2. befor sending out by UART (ex, WriteUART() function call)..
MUST do the below process:
while(BusyUART());


(Send-out UART-msg by one-byte, "c")

//Transmit a byte
while(BusyUSART());
putcUART(*data);




By following up the above 2 must-procedures, that's the complete RECEIVE-In/Send-Out by UART procedure.

============================================================
(2010/01/22 updated)

in [TCPIP Demo APP] project for PIC18xxx series, the UART initialization is located in the below section (Line0491 ~ Line0509) of "InitializeBoard()" function.


============================================================
(2010/01/27 updated)
For the intro by 2010/01/07, that's NOT good way to receiving and/or sending UART messages, while multi tcpip stack tasks running simultaneously.

The better way comes from (UART <-> TCP Bridge Example), [UART2TCPBridge.C].
The ISR function (UART2TCPBridgeISR( )) for UART receiving and/or sending message is the CLASSIC example.

沒有留言: