Hi everybody,
I'm working with a project that needs to transfer higth speed serial data from a XMOS device to a HOST PC.
I used the modules fast uart (https://github.com/xcore/sc_uart) prensent in gihub repository.
I want to implement a serial XON/XOFF software flow control to transfer data from XMOS device to a host PC.
I wrote the following code, but seems doesn't work well.
//Send buffer data to UART
void SendToSerial(streaming chanend DataFromFIFO, streaming chanend DataFromHostPC, streaming chanend DataToHostPC) {
unsigned int rx;
unsigned char XON = 1;
unsigned char RxFlow;
while(1){
select {
// xon/xoff char received from PC
case DataFromHostPC:> RxFlow:
if ( RxFlow == XOFF_CHAR){
XON = 0;
}
if ( RxFlow == XON_CHAR ){
XON = 1;
}
break;
// data from fifo to be sent over uart to the host pc
case DataFromFIFO :> rx:
// Checking if the transmission must be stopped
while( XON == 0 ){
DataFromHostPC:>RxFlow; // wait PC command
if ( RxFlow == XON_CHAR ){
XON = 1;
}
} // wating xon char ok
DataToHostPC <: rx;
break;
}
}
}
In main, i have:
par {
GetFromFIFO(DataFromFIFO); // Get data from fifo
HandleUart(DataFromFIFO,DataFromHostPC,DataToHostPC); // Send data to UART
ReceiveXOFF(DataFromHostPC); // Get data received from PC via UART
SendToHost(DataToHostPC); // Send data to UART
}
Checking the serial lines with the oscilloscope, when the XOFF char is sent by the host pc, the data doesn't stops. Where is the problem?
How to proper implement xon/xoff software flow control? Is there any sample code?
Thanks in advance.
XON / XOFF uart flow control
-
- Member
- Posts: 9
- Joined: Tue Nov 22, 2011 3:20 pm
-
- XCore Expert
- Posts: 589
- Joined: Wed Feb 29, 2012 10:03 am
Moved to Discussion:http://www.xcore.com/forum/viewtopic.php?f=26&t=2552