AnsweredAssumed Answered

LPC54608 Uart FC8 Issue

Question asked by fatih ozen on Sep 26, 2018
Latest reply on Sep 27, 2018 by Victor Jimenez

Hello,

 

I have my own board with LPC54608.
I want to use uart via PIO3_16 and PIO3_17. But I could not achieve my goal. Chip is working on 180 Mhz.

Could anybody help me ?


I referenced " lpcxpresso54608_driver_examples_usart_usart_interrupt " example in SDK 2.0.

There are two functions in this code.

void vInitialize_USB(void)         // This function is called in my main function.

void Usart_Send(void)              // This function is called in my while(true) endless loop.
I externed functions.

 

 

/////////////////////////////////////////////////////////////////////

#include <stdbool.h>
#include ".fsl_gpio.h"
#include "fsl_usart.h"
#include "uart.h"

 

#define DEMO_USART_IRQHandler FLEXCOMM8_IRQHandler

 

uint8_t g_tipString[] =
"11111111";

 

uint8_t demoRingBuffer[8];


volatile uint8_t txIndex; /* Index of the data to send out. */
volatile uint8_t rxIndex; /* Index of the memory to save new arrived data. */

 

void DEMO_USART_IRQHandler(void)
{
uint8_t data;

/* If new data arrived. */
if ((kUSART_RxFifoNotEmptyFlag | kUSART_RxError) & USART_GetStatusFlags(USART8))
{
data = USART_ReadByte(USART8);
/* If ring buffer is not full, add data to ring buffer. */
if (((rxIndex + 1) % 8) != txIndex)
{
demoRingBuffer[rxIndex] = data;
rxIndex++;
rxIndex %= 8;
}
}
/* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
exception return operation might vector to incorrect interrupt */
#if defined __CORTEX_M && (__CORTEX_M == 4U)
__DSB();
#endif
}

 

 

void vInitialize_USB(void)
{
usart_config_t config;


CLOCK_AttachClk(kFRO12M_to_FLEXCOMM8);

IOCON->PIO[3][16] = 0x0301;
IOCON->PIO[3][17] = 0x0301;

 

RESET_PeripheralReset(kFC8_RST_SHIFT_RSTn);

 

USART_GetDefaultConfig(&config);
config.baudRate_Bps = 115200;
config.enableTx = true;
config.enableRx = true;
USART_Init(USART8, &config, CLOCK_GetFreq(kCLOCK_Flexcomm8));


USART_WriteBlocking(USART8, g_tipString, sizeof(g_tipString) / sizeof(g_tipString[0]));


USART_EnableInterrupts(USART8, kUSART_RxLevelInterruptEnable | kUSART_RxErrorInterruptEnable);
EnableIRQ(FLEXCOMM8_IRQn);

}

 

 

void Usart_Send(void)
{
while ((kUSART_TxFifoNotFullFlag & USART_GetStatusFlags(USART8)) && (rxIndex != txIndex))
{
USART_WriteByte(USART8, demoRingBuffer[txIndex]);
txIndex++;
txIndex %= 8;
}
}

Outcomes