-   Linux - Hardware (
-   -   FTDI communication problems (

rasta_freak 06-05-2009 05:54 AM

FTDI communication problems
Hi. I'm using FTDI FT232BM serial converter for communication between PC and custom microcontroller board (Atmel MCU), on linux (but tested on too), ubuntu linux. There are few commands that PC sends, and MCU responds. Most commands are short, 2-3 bytes only, and there was no single error in communication. I recently implemented one command (for some kind of protection), where PC sends command byte + 8 data bytes, and MCU responds with 8 bytes. (Actually, it's double than that, because MCU & PC 'echo' (send back) every byte received). Problem is, out of 250 tests, around 10 of them fail (~3% chance of failure). It's not predictable, sometimes there are 2 failures (out of 250 tests), sometimes 15. What happens is that no data is waiting for me (for PC) in input buffer, like it's lost. Latency is set to 1 ms. Could there be any other issue other that cabling for these errors? (USB cable from board to PC is not shielded, and ~25cm long). I can't debug properly MCU board (it's developed by someone else), but I doubt it's MCU fault (PC normaly scans MCU ~30 times per sec, for it's input lines & state, so there's activity going on all the time). Baud rate is set to 57600. Is there anything else about FTDI or USB serial stuff I may have overlooked? Here's the code I use to setup ttyUSB port:


/* error checking left out */
struct termios st;
int fDev = open("/dev/ttyUSB0", O_RDWR | O_NOCTTY);
tcgetattr(fDev, &st);
cfsetspeed(&st, B57600);
st.c_cflag &= ~PARENB;
st.c_cflag &= ~CSTOPB;
st.c_cflag &= ~CSIZE;
st.c_cflag |=  CS8;
st.c_cflag &= ~CRTSCTS;
st.c_cflag |=  CREAD;
st.c_cflag |=  CLOCAL;
st.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
st.c_iflag &= ~(IXON | IXOFF | IXANY);
st.c_oflag &= ~OPOST;
st.c_cflag &= ~(OCRNL | ONLCR);
st.c_cc[VMIN]  = 0;
st.c_cc[VTIME] = 2;
tcsetattr(fDev, TCSANOW, &st);

All times are GMT -5. The time now is 02:48 PM.