Trying to get my LPC54114 to talk to a RS485 driver and my program seems to be hanging right at the BOARD_InitBootPeripherals() method created by the MCUXpresso peripherals tool.
I started with a new project that ran perfectly (the default PRINTF("Hello World\n") that is included in new projects but when I made the changes in the peripheral tools which auto generated code in BOARD_InitBootPeripherals() the program now blocks on the BOARD_InitBootPeripherals() method and the program never reaches the PRINTF.
Commenting out the method allows the program to continue normally.
LPC54114J256_RS485.cpp
#include <stdio.h>
#include "board.h"
#include "peripherals.h"
#include "pin_mux.h"
#include "clock_config.h"
#include "LPC54114_cm4.h"
#include "fsl_debug_console.h"
uint8_t data[] {0x53, 0x7f};
int main(void) {
BOARD_InitBootPins();
BOARD_InitBootClocks();
BOARD_InitBootPeripherals();
BOARD_InitDebugConsole();
PRINTF("Hello World\n");
volatile static int i = 0 ;
while(1) {
i++ ;
}
return 0 ;
}
board/peripherals.c
#include "peripherals.h"
const usart_config_t RS485_UART_config = {
.baudRate_Bps = 9600,
.parityMode = kUSART_ParityDisabled,
.stopBitCount = kUSART_OneStopBit,
.bitCountPerChar = kUSART_8BitsPerChar,
.loopback = false,
.txWatermark = kUSART_TxFifo0,
.rxWatermark = kUSART_RxFifo1,
.enableRx = true,
.enableTx = true
};
void RS485_UART_init(void) {
RESET_PeripheralReset(kFC2_RST_SHIFT_RSTn);
USART_Init(RS485_UART_PERIPHERAL, &RS485_UART_config, RS485_UART_CLOCK_SOURCE);
}
void BOARD_InitPeripherals(void)
{
RS485_UART_init();
}
void BOARD_InitBootPeripherals(void)
{
BOARD_InitPeripherals();
}
board/pin_mux.c
#include "fsl_common.h"
#include "fsl_iocon.h"
#include "pin_mux.h"
void BOARD_InitBootPins(void)
{
BOARD_InitPins();
}
void BOARD_InitPins(void)
{
CLOCK_EnableClock(kCLOCK_Iocon);
const uint32_t port0_pin0_config = (
IOCON_PIO_FUNC1 |
IOCON_PIO_MODE_INACT |
IOCON_PIO_INV_DI |
IOCON_PIO_DIGITAL_EN |
IOCON_PIO_INPFILT_OFF |
IOCON_PIO_SLEW_STANDARD |
IOCON_PIO_OPENDRAIN_DI);
IOCON_PinMuxSet(IOCON, 0U, 0U, port0_pin0_config);
const uint32_t port0_pin1_config = (
IOCON_PIO_FUNC1 |
IOCON_PIO_MODE_INACT |
IOCON_PIO_INV_DI |
IOCON_PIO_DIGITAL_EN |
IOCON_PIO_INPFILT_OFF |
IOCON_PIO_SLEW_STANDARD |
IOCON_PIO_OPENDRAIN_DI);
IOCON_PinMuxSet(IOCON, 0U, 1U, port0_pin1_config);
IOCON->PIO[0][8] = ((IOCON->PIO[0][8] &
(~(IOCON_PIO_FUNC_MASK | IOCON_PIO_MODE_MASK | IOCON_PIO_DIGIMODE_MASK)))
| IOCON_PIO_FUNC(PIO08_FUNC_ALT1)
| IOCON_PIO_MODE(PIO08_MODE_INACTIVE)
| IOCON_PIO_DIGIMODE(PIO08_DIGIMODE_DIGITAL));
IOCON->PIO[0][9] = ((IOCON->PIO[0][9] &
(~(IOCON_PIO_FUNC_MASK | IOCON_PIO_MODE_MASK | IOCON_PIO_DIGIMODE_MASK)))
| IOCON_PIO_FUNC(PIO09_FUNC_ALT1)
| IOCON_PIO_MODE(PIO09_MODE_INACTIVE)
| IOCON_PIO_DIGIMODE(PIO09_DIGIMODE_DIGITAL));
IOCON->PIO[1][0] = ((IOCON->PIO[1][0] &
(~(IOCON_PIO_FUNC_MASK | IOCON_PIO_MODE_MASK | IOCON_PIO_DIGIMODE_MASK)))
| IOCON_PIO_FUNC(PIO10_FUNC_ALT2)
| IOCON_PIO_MODE(PIO10_MODE_INACTIVE)
| IOCON_PIO_DIGIMODE(PIO10_DIGIMODE_DIGITAL));
}