Home/Support/Support Forum/Connect-Me + RS485
New and improved user forum site going live on 12/6 (All users will need to reset their password when the new forum is active)
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

Connect-Me + RS485

0 votes
Hi all.

I'm in the process of developping a Modbus master based on the Connect-ME and LxNETES. All RS485 ic's need the transmit enable signal to be managed by the processor and this task is usually done through the UART RTS line as this has to be done as close to the hardware as possible. In fact, toggling RTS from the user application adds too big delays to the equation. The problem is that RTS is correctly switched on by the UART when a message is written but it does not recovers the low state after the send is complete.

I've read in the uClinux mailing list that a hack should be done in serial.c (serial_netarm_dna.c for the Connect-ME I guess) in order for the RTS line to recover the low state after the UART has sent the last bit.

Has anyone done a similar hack for any processor running LxNETES? Is there a RS485 driver for LxNETES? Any other suggestion?

Thank you very much,

Daniel Berenguer
http://www.opnode.org
asked Jul 7, 2008 in Linux by estratos New to the Community (40 points)

Please log in or register to answer this question.

28 Answers

0 votes
Hi Daniel,

Did you manage to solve the problem?

I am trying to do the same as you with ConnectCore7U and NET+OS 7.3.

This is my code to try to transmit using a RS485 transceiver:
portb = open( "/com/0", O_RDWR );
result = tcgetattr( portb, &portbCfg );
portbCfg.c_iflag = 0;
//portbCfg.c_cflag |= CRTS;
//portbCfg.c_cflag |= CRTSTOGGLE;
result = cfsetospeed( &portbCfg, 2400 );
result = tcsetattr( portb, TCSANOW, &portbCfg );

result = write( portb, message, sizeof( message ) - 1 );

I have configured the serial port as 4 wire UART. I have also tried setting the c_cflag to CRTS or CRTSTOGGLE, but it did not work, RTS line does not toggle.

I don't know if the serial port driver is the same in NET+OS as in LxNETES, but any help is very welcomed.

Best regards,
Jose
answered Jul 21, 2008 by Jose New to the Community (16 points)
0 votes
Hi Jose. Sorry for the long delay in my response.

No, the NS7520 is not prepared to manage RS485 communications through the RTS line, mainly because the RTSTX bit has no effect on this processor. I'm waiting for the Connect-ME 9210, based on the NS9210, that is supposed to support this feature via RTSEN=1

Daniel.
answered Oct 13, 2008 by estratos New to the Community (40 points)
0 votes
I finally did my tests on the new Connect-ME 9210 platform and... RTS does not work in "RS485 mode" by default and I can't find either an option in the kernel for doing so.

Following the NS9210 hardware manual seems that making RTSEN = 1 in the Wrapper Configuration Register converts RTS into a RS485 transmit enable line. The problem is that I don't know where to do this.

Any suggestion is welcome.

Thanks again,

Daniel.
answered Apr 23, 2009 by estratos New to the Community (40 points)
0 votes
For NET+OS (sorry, I don't know Linux): CTRSTOGGLE is the correct way to get RTS toggle working with the serial driver. Make sure in gpio.h that the serial port is setup for at least 4 wire. Also, you need to make sure to fully setup the termios structure (setup all the flags, not just the cflag).

On a side note HW RTS toggle is not working properly in the NS7520 chip, so NET+OS only supports a software RTS toggle (in the serial driver) on NS7520 based modules (CC7U, ME, etc).

Finally, make sure you have the latest patches installed.
answered Apr 23, 2009 by charliek Veteran of the Digi Community (408 points)
0 votes
Again for NET_O/S (7.4) I've very successfully used the hardware toggle on RTS, setting the CRTSTOGGLE bit. I've also found that its sufficient to define a 2-wire UART (maybe we should have a 3-wire UART definition - I'm sure RxD/TxD/RTS is a popular configuration).

I modified camry_serl.h line 20 to give a little setup and hold on RTS relative to the data:

#define RTSEN ((1 << 19) | 0xf)

Above gives the maximum setup and hold times.
answered Apr 24, 2009 by steved1 Community Contributor (85 points)
0 votes
Do you mean that you manually control RTS via CRTSTOGGLE on each transmission?

This doesn't work for Linux as Linux is not a real-time OS. I tried that before on the old Connect-ME and didn't work because releasing RTS after the transmission takes too much time.

I think the solution is still in setting the RTSEN bit.

I tried doing
(*(volatile unsigned int*) 0x90011000U) |= 0x80000U;

from my application but I get a segmentation fault...

Thanks again,

Daniel.
answered Apr 24, 2009 by estratos New to the Community (40 points)
0 votes
No, CRTSTOGGLE is essentially a 'mode' flag for the serial port. Under NET+O/S on the ME9210 it uses the RTSEN value (IIRC) to update a UART control register. I simply modified the value so that RTS went active two bit times before data transmission started, and was held for two bit times after data transmission ended. Works well.
answered Apr 24, 2009 by steved1 Community Contributor (85 points)
0 votes
Thanks Steve.

Unfortunately, Linux does not support the CRTSTOGGLE flag... but at least I know that RTSEN works on the ME9210.

Thanks again,

Daniel.
answered Apr 25, 2009 by estratos New to the Community (40 points)
0 votes
I've found that setting the serial flag CRTSCTS disables the serial port!!

CTRCTS should just enable the RTS line. This makes me thing that the serial flow control must be enabled anywhere in the kernel before playing with bits and flags.

Any idea?

Daniel.
answered Apr 25, 2009 by estratos New to the Community (40 points)
0 votes
You can not access directly physical memory inside linux (while that can be done in uClinux).
Memory has to be accessed through its virtual memory.

That can be done because there is a static mapping and therefore you already know the virtual addres or because you have remapped that physical memory into a virtual one, using ioremap kernel function.
answered Apr 27, 2009 by pperez New to the Community (11 points)
...