[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Releasing RTS in RS485 mode

----- Original Message ----- 
From: "Steen Jansdal" <sja@xxxxxxx.dk>
To: <dev-etrax@xxxxxxx.com>
Sent: Friday, February 14, 2003 13:14
Subject: Releasing RTS in RS485 mode

> Hi,
> I have problems getting /dev/ttyS3 to release the RTS soon enough in 
> RS485 mode. The RTS are used to control the direction of the
> communication on the RS485 driver.
> Specs:
> devboard_lx
> Linux 2.4.19 with axis patches
> Mark/Space parity patches from Tamas Szabo ( Thank you very much Tamas, 
> your patches are working great! )
> 115200 baud
> For enabling rs485 mode I've done the following:
> struct rs485_ctrl ctrl485;
> memset(&ctrl485, 0, sizeof(ctrl485));
> ctrl485.rts_on_send = 0;
> ctrl485.rts_after_send = 1;
> ctrl485.delay_rts_before_send = 0;
> status = ioctl(cb->fd, TIOCSERSETRS485, &ctrl485);
> And when I want to transmit I do the following:
> struct rs485_wrt io485;
> io485.outc_size = len;
> io485.outc = cmd;
> status = ioctl(cb->fd, IOCSERWRRS485, &io485);
> Using an oscilloscope I've measured some timings.
> On the first picture (twobytes.gif) you see two bytes (55h and AAh)
> with no parity. The time from the last stopbit until the RTS line
> is released is more than 120 us.
> Then I connected my devboard_lx to another device and sometimes
> I was able to read the proper data from the device but sometimes
> it failed, because the direction of the RS485 driver was changes
> too late.
> I captured a good (ok.gif) and a bad (fail.gif) situation.
> Is there anything I can do? Am I doing something wrong?
> Steen

Make sure you have enabled CONFIG_ETRAX_FAST_TIMER
in the kernel config - that should make the time smaller and 
more deterministic.
If that is already enabled, it's a little trickier,
I guess that the interrupts are turned off for to long 
sometimes - perhaps using RTAI and doing the RTS flipping
in a realtime task is the only safe way (or finding the place 
where interrupts are turned off for to long)
I beleive the masters thesis workers that ported RTAI to ETRAX100LX
soon will publish the code (there were some review remarks that
needed fixing).

Best regards
Johan Adolfsson, Embedded Platform
Axis Communications AB