Flow control for twrk65f180m using MQX

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

Flow control for twrk65f180m using MQX

831 Views
viveksrinivasan
Contributor I

Hi Guys,

I'm trying to use one of the UART's in twrk65f180m using MQX to communicate with the Bluetooth chip. For this I need hardware flow control .

But when I enable hardware flow control for the UART, I don't see any bytes coming out of the Tx line.

But when I disable flow control, I can see the bytes coming out of Tx line.

My question is :

1. Is harware flow control implemented for MQX. Because when I read other posts regarding Flow Control, many people say that it is not implemented or it is implemented only in polling. Is that true?

2. Is hardware flow control enabled for interrupt mode?

3. Is there any sample applications that use hardware flow control?

Your help is much appreciated.

Thank you.

Have a great day!

Vivek

Tags (2)
0 Kudos
2 Replies

387 Views
viveksrinivasan
Contributor I

Below is my code,

//-----------------Initialization-----------------------//

        *handle = (ClxUartPort*)_io_fopen((char *)"ittyd:", (char *)(IO_SERIAL_HW_FLOW_CONTROL | IO_SERIAL_RAW_IO));

        if (*handle == NULL)

        {

          printf("Error opening the UART 3 device driver!");

          _task_block();

        }

//---------------------Write-----------------------------//

fflush( (MQX_FILE_PTR)handle );

   

    ioctl( (MQX_FILE_PTR)handle, IO_IOCTL_SERIAL_CAN_TRANSMIT, &ioFree );

   

    if(ioFree)

    { 

      writtenData = _io_write((MQX_FILE_PTR)handle,

                              (void*)data,

                              (_mqx_int)dataLength);

      if (writtenData == IO_ERROR)

      {

        printf("\nUart Tx error");

        _task_block();

      }

     

      ioctl( (MQX_FILE_PTR)handle, IO_IOCTL_SERIAL_WAIT_FOR_TC, NULL );

    }

The code waits ont the last line indefinitely ( ioctl( (MQX_FILE_PTR)handle, IO_IOCTL_SERIAL_WAIT_FOR_TC, NULL );), for transmission complete interrupt to happen.

Let me know if i'm doing something wrong. Thanks.

-Vivek

0 Kudos

387 Views
soledad
NXP Employee
NXP Employee

Hello Vivek:

The BSPCFG_ENABLE_TTYD_HW_SIGNALS has influence on init_gpio.c, where it enabled RTS and CTS signals:

For example in the K60 device:

#if BSPCFG_ENABLE_TTYD_HW_SIGNALS

                /* PTC18 as RTS function (Alt.3) + drive strength */

                pctl->PCR[18] = 0 | PORT_PCR_MUX(3) | PORT_PCR_DSE_MASK;

                /* PTC19 as CTS function (Alt.3) + drive strength */

                pctl->PCR[19] = 0 | PORT_PCR_MUX(3) | PORT_PCR_DSE_MASK;

#endif

Pin functions are independent on the mode (polled/interrupted) of the serial IO driver.

Flow control then works depending on IO_SERIAL_HW_485_FLOW_CONTROL flag passed to serial io device. (refer to /mqx/examples/rs485).

When you open serial io device with IO_SERIAL_HW_485_FLOW_CONTROL flag, it will configure Kinetis UART module MODEM register:

case IO_IOCTL_SERIAL_SET_FLAGS:

        // automatic HW flow control          if (*param_ptr & IO_SERIAL_HW_485_FLOW_CONTROL) {

            // RTS hw flow control - support for RS485

          

            /* 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_RXRTSE_MASK | UART_MODEM_TXCTSE_MASK));

            sci_ptr->MODEM |= UART_MODEM_TXRTSE_MASK;

        }

        else if (*param_ptr & IO_SERIAL_HW_FLOW_CONTROL) {

            // RTS, CTS hw flow control              sci_ptr->MODEM &= ~UART_MODEM_TXRTSE_MASK;

            sci_ptr->MODEM |= (UART_MODEM_RXRTSE_MASK | UART_MODEM_TXCTSE_MASK);

        }

        else {

            sci_ptr->MODEM &= (~(UART_MODEM_RXRTSE_MASK | UART_MODEM_TXCTSE_MASK | UART_MODEM_TXRTSE_MASK));

        }

      

        break;

shortly, BSPCFG_ENABLE_TTYD_HW_SIGNALS and IO_SERIAL_HW_485_FLOW_CONTROL are valid for both serial and interrupt mode serial I/O drivers.


Have a great day,
Sol

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos