SerialDriver strange loopback

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

enrico.dallavia
Posts: 105
Joined: Thu Mar 12, 2015 10:15 am
Has thanked: 2 times

Re: SerialDriver strange loopback

Post by enrico.dallavia »

Thanks, I will do it tomorrow.

Anyway, I have the same effects even with

Code: Select all

int len2Write = strlen(acTxBuf);
 i = 0;
 do{
    chnWrite(&SD2,&acTxBuf[i],1);
   chThdSleepMilliseconds(1);//aspetto
    i+=1;
 }while(i < len2Write);


So I doubt it is a too fast writing over the serial

Thanks for the time you have spent for helping me.
steved
Posts: 834
Joined: Fri Nov 09, 2012 2:22 pm
Has thanked: 12 times
Been thanked: 138 times

Re: SerialDriver strange loopback

Post by steved »

I concur with Giovanni; its most likely a hardware-related problem. Or possibly that the Windows PC can't receive data fast enough. Might be worth trying to get things going at 9600 baud, then increasing the speed.

If you are using 2-wire (or even 4-wire) RS-485 you should ideally enable the transmitter, wait a couple of character times, then start transmitting. This ensures that any glitches on the line have been 'timed out' before the real data is sent. The newer ST chips (using USART2 drivers) can do this automatically, if you are using the RTS line to enable your transmitter - its just a matter of setting up some registers.

Terminators are definitely a good idea. Sometimes (especially in a noisy environment) it's worth adding 'bias resistors' to the line as well, but that requires a power supply to be available, which is not always the case.

Also make sure that there is a common ground between your hardware and the PC interface.

Another thing that can happen if the first few bits of a transmission get lost is that the receiver synchronises incorrectly on the bit stream, and you get rubbish.
enrico.dallavia
Posts: 105
Joined: Thu Mar 12, 2015 10:15 am
Has thanked: 2 times

Re: SerialDriver strange loopback

Post by enrico.dallavia »

hi, thanks for the suggestions.
it is strange because the first symbol is always sent, what I lack is the ones in the middle.
the chip used to translate from tx/rx from stm32 has a pin to enable it reading or writing. nothing else. so I don't have too much to play with..
on the other side I have a PC with USB to 485 (2 wires only) converter with a ftdi chip. the PC is quite fast (core i5 at 4ghz running latest Linux mint) so I doubt I miss some characters. plus the packet I sent from stm has a start/stop symbol that I always receive.
tomorrow I will check with an oscilloscope if the data are present or not on the 2 wires of 485.
the length of the wires are very small, around 50cm, the power source is taken from the same plug.
Post Reply