Implementing UART RX/TX polarity inversion on MKE02Z64VLH4

cancel
Showing results for 
Search instead for 
Did you mean: 

Implementing UART RX/TX polarity inversion on MKE02Z64VLH4

697 Views
AlexanderSammo1
Contributor I

I am using MCUExpresso IDE 11 with MKE02Z64 SDK 2.4.1.

My application requires active high RX/TX operation.  It appears that in addition to the peripheral UART driver, KSDK 1.x also included low level HAL driver (fsl_uart_hal) which permitted setting UART inversion using the example code below.

void UART_HAL_SetTxRxInversionCmd(uint32_t baseAddr, bool rxInvertEnable, bool txInvertEnable)
{
      /* 0 - receive data not inverted, 1 - receive data inverted */
      BW_UART_S2_RXINV(baseAddr, (uint8_t)rxInvertEnable);
      /* 0 - transmit data not inverted, 1 - transmit data inverted*/
      BW_UART_C3_TXINV(baseAddr, (uint8_t)txInvertEnable);
}

Unfortunately, this is no longer accessible.  After doing a little digging around in MKE02Z4.h in my KSDK 2.4.1, it appears there are applicable UART control registers which seemingly allow to accomplish what I need:

#define UART_S2_RXINV_MASK (0x10U)
#define UART_S2_RXINV_SHIFT (4U)
#define UART_S2_RXINV(x) (((uint8_t)(((uint8_t)(x)) << UART_S2_RXINV_SHIFT)) & UART_S2_RXINV_MASK)

#define UART_C3_TXINV_MASK (0x10U)
#define UART_C3_TXINV_SHIFT (4U)
#define UART_C3_TXINV(x) (((uint8_t)(((uint8_t)(x)) << UART_C3_TXINV_SHIFT)) & UART_C3_TXINV_MASK)

Please advise on the best way to implement the control in the main application, and if such control needs to be assigned prior to each transmission / reception or only once upon initialization of the UART peripheral.

Regards,

AGS

***EDIT****

I was able to accomplish what I needed by implementing the following in my UART initialization routine:

((UART_Type *)UART2_BASE)->C3 |= (1<<4);
((UART_Type *)UART2_BASE)->S2 |= (1<<4);

0 Kudos
1 Reply

470 Views
FelipeGarcia
NXP TechSupport
NXP TechSupport

Hello Alexander,

 

Thanks for sharing with us how you solved the issue by using RXINV and TXINV bits configuration.

 

In addition, I recommend you to use our latest version of the SDK (2.6.0). You can download it from the following link.

https://mcuxpresso.nxp.com/en/welcome

 

Best regards,

Felipe

0 Kudos