Problems with serial driver for RS485 applications on TWRK60 , TWR-SER and MQX3.7

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Problems with serial driver for RS485 applications on TWRK60 , TWR-SER and MQX3.7

1,246 Views
GottiLuca
Contributor IV

 

I'm developing an application with MQX3.7 compiled with IAR compiler (v. 6.1) using the TWRK60 toolkit as a protoype board .

In order to us the RS422 / RS485 transceiver ( U5 on the TWR-SER ) as a RS485 driver, i've to set the following jumpers : J17, J18 and J19 in pos 2-3

and i've installed three jumpers on the J13 header on pos 1-2 , 3-4 and 5-6.

 

I tried to use the IO_SERIAL_HW_485_FLOW_CONTROL option in opening my serial port as follows :

 

        /* HW 485 flow control on chip*/
        rs485_dev = fopen( RS485_CHANNEL, (char const *)(IO_SERIAL_HW_485_FLOW_CONTROL ) );

When i try to send a message on the rs485 device i see the RTS signal being driven sincronous with the char ( just before the fisrt character and just after the last char ) but the problem is in the polarity of the signal : instead of being driven HIGH during data transmission, it is driven LOW ( wich means enabling only the receiver of the transceiver ).

Is this a bug of MQX or there is a logical reason for MQX to drives this pin LOW instead of HIGH ..??

I've solved the problem simply opening the RS485 channel without the IO_SERIAL_HW_485_FLOW_CONTROL option and adding the hanshake of the RTS pin directly by the lwgpio driver .

 

However i  think that this behaviour it would be corrected in MQX if there is any valid reason ....

 

 

0 Kudos
2 Replies

332 Views
master_szumi
Contributor III

I find the same problem - it's MQX bug.

 

You must change polarization of RTS signal.

 

If you use serial polled mode:

 

1. Open MQX serl_pol_kuart.c

2. Modify code

 

         if( *param_ptr & IO_SERIAL_HW_485_FLOW_CONTROL )
         {           
            /* get serial device index and set GPIO pin functionality to RTS */
            _bsp_serial_rts_init( io_info_ptr->INIT.DEVICE );
            /* enable hardware support for 485 RTS pin drive */
            //sci_ptr->MODEM |= UART_MODEM_TXRTSE_MASK;            
            sci_ptr->MODEM |= (UART_MODEM_TXRTSE_MASK | UART_MODEM_TXRTSPOL_MASK);
         }

 

3. Sloved

 

 

 

0 Kudos

332 Views
ebee
Contributor II

This same bug still exists in MQX 4.0.

The above fix suggested by Jakub still works. The interrupt driven version uses the same code for the ioctl functions so you will need to make the same changes in the same file if you are using the serial port in interrupt mode.

0 Kudos