Using USART_0 on LPC54101J512

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

Using USART_0 on LPC54101J512

192 Views
mimers19
Contributor I

Hi,

I'm trying to get my MCU to communicate with my computer via a COM port, but so far, I've had no luck. My setup includes the MCUXpresso IDE, where I've activated the RX and TX pins. Additionally, I've configured USART communication, which resulted in the following configuration:

 

const usart_config_t USART0_config = {
.baudRate_Bps = 115200UL,
.syncMode = kUSART_SyncModeDisabled,
.parityMode = kUSART_ParityDisabled,
.stopBitCount = kUSART_OneStopBit,
.bitCountPerChar = kUSART_8BitsPerChar,
.loopback = false,
.enableRx = true,
.enableTx = true,
.clockPolarity = kUSART_RxSampleOnFallingEdge,
.enableContinuousSCLK = false,
.fifoConfig = {
.enableRxFifo = false,
.rxFifoSize = 4U,
.rxFifoThreshold = 1U,
.enableTxFifo = true,
.txFifoSize = 4U,
.txFifoThreshold = 0U
}
};

static void USART0_init(void) {
// USART0 peripheral initialization
USART_Init(USART0_PERIPHERAL, &USART0_config, USART0_CLOCK_SOURCE);
}

 

 

I then wrote a simple program intending to upload a file:

#include <stdio.h>
#include "board.h"
#include "peripherals.h"
#include "pin_mux.h"
#include "clock_config.h"
#include "LPC54101.h"
#include "fsl_debug_console.h"
#include "fsl_usart.h"

int main(void) {
// Initialize board hardware.
BOARD_InitBootPins();
BOARD_InitBootClocks();
BOARD_InitBootPeripherals();
#ifndef BOARD_INIT_DEBUG_CONSOLE_PERIPHERAL
// Initialize FSL debug console.
BOARD_InitDebugConsole();
#endif

// Sending some bytes via USART0
for (uint8_t i = 0; i < 15; i++) {
uint8_t data = 41 + i;
USART_WriteByte(USART0, data);
}
}

 

Following the steps outlined in this guide, I compiled my project and obtained a .hex file. I then used FlashMagic to upload the code to my LPC54101J512.

Despite not receiving any errors from the compiler or FlashMagic, and even after trying three different USB <-> UART converters, I'm not seeing any results.

Can anyone pinpoint what I might be doing wrong?

 

Labels (2)
0 Kudos
1 Reply

164 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello @mimers19 

1) Firstly recommend you use debugger to debug your code, not directly program .hex file to run. Debug step by step to check issue.

2) You can use Config tool inside MCUXpresso IDE to configure USART_0:

Alice_Yang_0-1711333293193.png

 

3) Also can refer to UART SDK demo under LPC54102 .

Alice_Yang_1-1711333332645.png

 

BR

Alice

 

 

0 Kudos