UART TX misteriously stops working

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

UART TX misteriously stops working

591 Views
adamhimer
Contributor II

Hi all,

I have a very strange problem on the with LPC1549.

Setup:
- USART_1 is used as a debugger output that prints to a serial terminal
- First section of flash is used for a bootloader, the rest is used for application firmware
- Both bootloader and application use the same functions in "board.c" and "board.h" from "lpc_board_nxp_lpcxpresso_1549" project

This has worked perfectly fine on my previous board revision, which used TX-p0.13 and RX-p0.18 (ISP pins but reversed due to PCB mistake)

The PCB was revised and TX-RX reversed, so that it matches the default ISP pinout for sake of compatibility.

After the changes, everything works fine, except the TX functionality in the bootloader code. The bootloader receives command characters perfectly fine on the RX line when I type it into the terminal, but won't echo it back(as a quick test) or print out anything.

The application prints and receives character commands as normal.

// Set up pins
Chip_IOCON_PinMuxSet(LPC_IOCON, UART1_TX_PORT, UART1_TX_PIN, (IOCON_MODE_INACT | IOCON_DIGMODE_EN));
Chip_IOCON_PinMuxSet(LPC_IOCON, UART1_RX_PORT, UART1_RX_PIN, (IOCON_MODE_INACT | IOCON_DIGMODE_EN));
Chip_SWM_MovablePortPinAssign(SWM_UART1_RXD_I, UART1_RX_PORT, UART1_RX_PIN);
Chip_SWM_MovablePortPinAssign(SWM_UART1_TXD_O, UART1_TX_PORT, UART1_TX_PIN);
// Diff Driver Mode Pins - Default to OFF on both lines
Chip_GPIO_SetPinDIROutput( LPC_GPIO, UART1_mTX_EN_PORT, UART1_mTX_EN_PIN);
Chip_GPIO_SetPinState( LPC_GPIO, UART1_mTX_EN_PORT, UART1_mTX_EN_PIN, FALSE);

Chip_GPIO_SetPinDIROutput( LPC_GPIO, UART1_sTX_EN_PORT, UART1_sTX_EN_PIN);
Chip_GPIO_SetPinState( LPC_GPIO, UART1_sTX_EN_PORT, UART1_sTX_EN_PIN, FALSE);

// Set RS485 Control to UART1 Full Duplex Master
// mTX_ENA=1, sTX_ENA=0
Chip_GPIO_SetPinState( LPC_GPIO, UART1_mTX_EN_PORT, UART1_mTX_EN_PIN, TRUE);
Chip_GPIO_SetPinState( LPC_GPIO, UART1_sTX_EN_PORT, UART1_sTX_EN_PIN, FALSE);

/* Use main clock rate as base for UART baud rate divider */
Chip_Clock_SetUARTBaseClockRate(Chip_Clock_GetMainClockRate(), false);

/* Setup UART */
Chip_UART_Init(DEBUG_UART);
Chip_UART_ConfigData(DEBUG_UART, UART_CFG_DATALEN_8 | UART_CFG_PARITY_NONE | UART_CFG_STOPLEN_1);

uint32_t actual_baud;
static volatile uint32_t baseClockRate;
baseClockRate = Chip_Clock_SetUARTBaseClockRate(921600*16, 1);
Chip_UART_SetBaud(LPC_USART1, DEBUG_BAUDRATE);
//baud rate = U_PCLK/16 x BRGVAL
actual_baud = baseClockRate/ ((LPC_USART1->BRG+1) * 16);
//return actualRate;

Chip_UART_Enable(DEBUG_UART);
Chip_UART_TXEnable(DEBUG_UART);

float baud_error = (((float)actual_baud / (float)DEBUG_BAUDRATE)-1) *100;
DEBUGSTR("\r\n*********************************************\r\nDebug Start\r\nPress 'h' for help.\r\n");
DEBUGOUT("Debug BaudRate = Ideal: %04d, Actual: %04d, Error: %.2f%% \r\n*********************************************\r\n", DEBUG_BAUDRATE, actual_baud,baud_error );


Any help or pointers to the right direction would be greatly appreciated 


0 Kudos
2 Replies

560 Views
adamhimer
Contributor II

Hi Alexis,

Yes, exact same functions are called, from the third "board" related project that is referenced by both bootloader and application.

I changed USART1 port to USART2 port on different pins and it is working fine. 

0 Kudos

563 Views
Alexis_A
NXP TechSupport
NXP TechSupport

Hello @adamhimer,

The configuration for the UART pins is the same in the application and the bootloader?

Best Regards,

Alexis Andalon

0 Kudos