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.
Read
XON / XOFF uart flow control
-
- XCore Expert
- Posts: 589
- Joined: Wed Feb 29, 2012 10:03 am
XON / XOFF uart flow control
Last edited by sethu_jangala on Wed Sep 24, 2014 5:17 am, edited 4 times in total.
Reason: Edit
Reason: Edit
-
- XCore Expert
- Posts: 589
- Joined: Wed Feb 29, 2012 10:03 am
Try changing streaming channels to normal channels and see if this solves your issue. Can you export and send the workspace if possible?
-
- Member
- Posts: 9
- Joined: Tue Nov 22, 2011 3:20 pm
Thanks for your replay.sethu wrote:Try changing streaming channels to normal channels and see if this solves your issue. Can you export and send the workspace if possible?
The uart fast library has a prototype that takes as input a streaming channel:
Code: Select all
void uart_rx_fast(in port p, streaming chanend c, int clocks);
In this case what is the difference between streaming channel and channel??
-
- XCore Expert
- Posts: 589
- Joined: Wed Feb 29, 2012 10:03 am
If the module uses streaming channel you have to use streaming channel in the application. You can find information regarding the difference between streaming channel and normal channel from the following link:fdaniii wrote: The uart fast library has a prototype that takes as input a streaming channel:
i need to change the library...Code: Select all
void uart_rx_fast(in port p, streaming chanend c, int clocks);
In this case what is the difference between streaming channel and channel??
http://www.xcore.com/questions/1778/how ... al-channel
Sethu.