Hi, i am currently trying to implement a fast UART, with data speed in the Mhz range. I need the use of handshakes, i.e. cts/rts or my uart device (FT232) will lose packets.
First of all i managed to read the rts(request to send) port and halt the streaming when my ft232 is not ready to receive. I made a host application that tests the received string and everything is good, even for large transfers, i.e. more than 4kB.
For both the rts and rx, i used a 1 bit port; rts is input and tells the microcontroller when to stop sending bytes through rx. What i don't understand is why this only works in a 1 bit port for rx (haven't tried for rts yet). If i send data to lets say bit 0 of a 4 bit port, i receive only some crap at the host.
My transmitter code is based on the simple fast uart example.
Code: Select all
extern in port p_uart_readyin;
void uart_tx_fast(out port p, streaming chanend c, int clocks) {
int t;
unsigned char b;
char a= 0x21;
while (1) {
char e = a;
c :> b;
int busy=1;
while(busy)
p_uart_readyin :> busy;
p <: 0 @ t;
t += clocks;
#pragma loop unroll(8)
for(int i = 0; i < 8; i++) {
p @ t <: >> e;
t += clocks;
}
p @ t <: 1;
t += clocks;
p @ t <: 1;
if (a == 0x7e)
a=0x21;
else
a++;
2)
As a second question (less important), since the XMOS architecture allows for configuring the ports in handshake mode, i thought i would give it a try, as it would be interesting to have the port handle the handshakes instead of the processor.
In the xs1 library, i think i need the following port configuration:
Code: Select all
configure_out_port_strobed_slave(void port p, in port readyin, clock clk, unsigned initial)
Code: Select all
configure_in_port_strobed_master(void port p, out port readyout, const clock clk)
not configure_x_port_handshake, as it implements a full handshake where one side will also send a signal when sending data.
I never was able to work with the port handshakes so far. The result always fails; there is definitely something i am doing wrong. Anyone ever managed to do some UART handshakes that way? Thanks!