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
// 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...
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:
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!