AnsweredAssumed Answered

Why does call to UART_HAL_SetTxInversionCmd() cause exception to HardFault_Handler?

Question asked by Scott Whitney on Apr 15, 2015
Latest reply on Apr 16, 2015 by Scott Whitney

Hi folks,

 

I have made good progress using KSDK_1.1.0 to develop some code that implements a polled debug console and an interrupt-driven UART, but tried something today that has me baffled.  I am hoping that perhaps one of you has tried this and found a solution.  I'm using a TWR-K60D100M with IAR Embedded Workbench for Cortex-M V7.40.2.

 

Looking at the UART Tx signals with a logic analyzer, they appear to idle in the "high" state, i.e. they go low to start transmitting data.  I confirmed this by looking at a UART0 Tx output and UART3 Tx, which runs down to a convenient jumper on the TWR-SER board.

 

I have some eval hardware that I'm trying to send serial data to that appears to want the data in the opposite state, so I did some reading and found out that there are bits to allow inversion of Rx and/or Tx.  As a small code example, here is a sample initialization that would initialize UART0 and try to invert the Tx and Rx lines:

 

     uart_user_config_t uart0Config; // UART configuration parameters

     uart_state_t uart0State;        // Memory for UART driver state structure   

 

     // Set up the I/O pins required

     configure_uart_pins(HW_UART0);

 

    // Initialize the UART configuration

    uart0Config.baudRate = 115200;

    uart0Config.bitCountPerChar = kUart8BitsPerChar;

    uart0Config.parityMode = kUartParityDisabled;

    uart0Config.stopBitCount = kUartOneStopBit;

 

    // Initialize the UART driver

    UART_DRV_Init(HW_UART0, &pcCommUartState, &uart0Config);

  

    // Here comes trouble...

    UART_HAL_SetTxInversionCmd(HW_UART0, true);

    UART_HAL_SetRxInversionCmd(HW_UART0, true);

 

As soon as I try to call UART_HAL_SetTxInversionCmd(), the K60 processor appears to generate a hard fault, and I end up in the following startup code:

 

        PUBWEAK HardFault_Handler

        SECTION .text:CODE:REORDER:NOROOT(1)

HardFault_Handler

        B .

 

Does anyone know why this could be happening?  The UART documentation clearly says that there are registers with bits to invert Tx and/or Rx, but when I try to do it through the provided HAL function, I get HardFault_Handler().

 

Thanks in advance for any advice or help!

 

Scott

Outcomes