LPC54608 Uart FC8 Issue

cancel
Showing results for 
Search instead for 
Did you mean: 

LPC54608 Uart FC8 Issue

Jump to solution
566 Views
fatihozen
Contributor IV

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;
}
}

Labels (1)
Tags (2)
1 Solution
229 Views
victorjimenez
NXP TechSupport
NXP TechSupport

Hello fatih ozen,

Did you try removing all the LCD configurations of your project to see if the problem goes away? I took as an example the project "usart_polling" of the SDK 2.4.1 and I didn't face any problem while changing to UART8 in pins P3_16 and P3_17. Here are the modifications that I made. 

#define DEMO_USART USART8
#define DEMO_USART_CLK_SRC kCLOCK_Flexcomm8
#define DEMO_USART_CLK_FREQ CLOCK_GetFreq(kCLOCK_Flexcomm8)

/*******************************************************************************
 * Code
 ******************************************************************************/
int main(void)
{
    uint8_t ch;
    usart_config_t config;

    CLOCK_AttachClk(kFRO12M_to_FLEXCOMM8);

    BOARD_InitPins();
    BOARD_BootClockFROHF48M();

    USART_GetDefaultConfig(&config);
    config.baudRate_Bps = BOARD_DEBUG_UART_BAUDRATE;
    config.enableTx = true;
    config.enableRx = true;

    USART_Init(DEMO_USART, &config, DEMO_USART_CLK_FREQ);

    USART_WriteBlocking(DEMO_USART, txbuff, sizeof(txbuff) - 1);

    while (1)
    {
        USART_ReadBlocking(DEMO_USART, &ch, 1);
        USART_WriteBlocking(DEMO_USART, &ch, 1);
    }
}

Inside the function BOARD_InitPins I have the following. 

void BOARD_InitPins(void)
{
    /* Enables the clock for the IOCON block. 0 = Disable; 1 = Enable.: 0x01u */
    CLOCK_EnableClock(kCLOCK_Iocon);

    const uint32_t port3_pin16_config = (
                                         IOCON_PIO_FUNC1 |
                                         /* No addition pin function */
                                         IOCON_PIO_MODE_INACT |
                                         /* Input function is not inverted */
                                         IOCON_PIO_INV_DI |
                                         /* Enables digital function */
                                         IOCON_PIO_DIGITAL_EN |
                                         /* Input filter disabled */
                                         IOCON_PIO_INPFILT_OFF |
                                         /* Standard mode, output slew rate control is enabled */
                                         IOCON_PIO_SLEW_STANDARD |
                                         /* Open drain is disabled */
                                         IOCON_PIO_OPENDRAIN_DI);
    IOCON_PinMuxSet(IOCON, 3U, 16U, port3_pin16_config);

    const uint32_t port3_pin17_config = (
                                         IOCON_PIO_FUNC1 |
                                         /* No addition pin function */
                                         IOCON_PIO_MODE_INACT |
                                         /* Input function is not inverted */
                                         IOCON_PIO_INV_DI |
                                         /* Enables digital function */
                                         IOCON_PIO_DIGITAL_EN |
                                         /* Input filter disabled */
                                         IOCON_PIO_INPFILT_OFF |
                                         /* Standard mode, output slew rate control is enabled */
                                         IOCON_PIO_SLEW_STANDARD |
                                         /* Open drain is disabled */
                                         IOCON_PIO_OPENDRAIN_DI);
    IOCON_PinMuxSet(IOCON, 3U, 17U, port3_pin17_config);
}

Hope it helps!

Victor.

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Correct Answer button. Thank you!

----------------------------------------------------------------------------------------------------------------------- 

View solution in original post

2 Replies
229 Views
fatihozen
Contributor IV

Anybody interested in ?

I also tried FC8 usart communication on OM13092 I have seen signal on PIO3_17. My code is simple. Im doing same things on my custom board but I only see 3.3V on this pin.

Board is working on 180Mhz. There is written 48M but I changed codes in function for 180Mhz. I am also using LCD on my board. So I also init LCD clock here if it is a problem or not. I am doing true pin assignment for usart pins.

Why it can't work on my side ? Any idea ?


int main(void)
{
usart_config_t config;
CLOCK_EnableClock(kCLOCK_InputMux);
CLOCK_AttachClk(kMCLK_to_LCD_CLK);
CLOCK_SetClkDiv(kCLOCK_DivLcdClk, 1, true);
CLOCK_AttachClk(kFRO12M_to_FLEXCOMM8);
BOARD_InitPins();
BOARD_BootClockFROHF48M();

USART_GetDefaultConfig(&config);
config.baudRate_Bps = 9600;
config.enableTx = true;
config.enableRx = true;
USART_Init(USART8, &config, CLOCK_GetFreq(kCLOCK_Flexcomm8));
while(1){
USART_WriteBlocking(USART8, (uint8_t *)&"c", 1);}
}

0 Kudos
230 Views
victorjimenez
NXP TechSupport
NXP TechSupport

Hello fatih ozen,

Did you try removing all the LCD configurations of your project to see if the problem goes away? I took as an example the project "usart_polling" of the SDK 2.4.1 and I didn't face any problem while changing to UART8 in pins P3_16 and P3_17. Here are the modifications that I made. 

#define DEMO_USART USART8
#define DEMO_USART_CLK_SRC kCLOCK_Flexcomm8
#define DEMO_USART_CLK_FREQ CLOCK_GetFreq(kCLOCK_Flexcomm8)

/*******************************************************************************
 * Code
 ******************************************************************************/
int main(void)
{
    uint8_t ch;
    usart_config_t config;

    CLOCK_AttachClk(kFRO12M_to_FLEXCOMM8);

    BOARD_InitPins();
    BOARD_BootClockFROHF48M();

    USART_GetDefaultConfig(&config);
    config.baudRate_Bps = BOARD_DEBUG_UART_BAUDRATE;
    config.enableTx = true;
    config.enableRx = true;

    USART_Init(DEMO_USART, &config, DEMO_USART_CLK_FREQ);

    USART_WriteBlocking(DEMO_USART, txbuff, sizeof(txbuff) - 1);

    while (1)
    {
        USART_ReadBlocking(DEMO_USART, &ch, 1);
        USART_WriteBlocking(DEMO_USART, &ch, 1);
    }
}

Inside the function BOARD_InitPins I have the following. 

void BOARD_InitPins(void)
{
    /* Enables the clock for the IOCON block. 0 = Disable; 1 = Enable.: 0x01u */
    CLOCK_EnableClock(kCLOCK_Iocon);

    const uint32_t port3_pin16_config = (
                                         IOCON_PIO_FUNC1 |
                                         /* No addition pin function */
                                         IOCON_PIO_MODE_INACT |
                                         /* Input function is not inverted */
                                         IOCON_PIO_INV_DI |
                                         /* Enables digital function */
                                         IOCON_PIO_DIGITAL_EN |
                                         /* Input filter disabled */
                                         IOCON_PIO_INPFILT_OFF |
                                         /* Standard mode, output slew rate control is enabled */
                                         IOCON_PIO_SLEW_STANDARD |
                                         /* Open drain is disabled */
                                         IOCON_PIO_OPENDRAIN_DI);
    IOCON_PinMuxSet(IOCON, 3U, 16U, port3_pin16_config);

    const uint32_t port3_pin17_config = (
                                         IOCON_PIO_FUNC1 |
                                         /* No addition pin function */
                                         IOCON_PIO_MODE_INACT |
                                         /* Input function is not inverted */
                                         IOCON_PIO_INV_DI |
                                         /* Enables digital function */
                                         IOCON_PIO_DIGITAL_EN |
                                         /* Input filter disabled */
                                         IOCON_PIO_INPFILT_OFF |
                                         /* Standard mode, output slew rate control is enabled */
                                         IOCON_PIO_SLEW_STANDARD |
                                         /* Open drain is disabled */
                                         IOCON_PIO_OPENDRAIN_DI);
    IOCON_PinMuxSet(IOCON, 3U, 17U, port3_pin17_config);
}

Hope it helps!

Victor.

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Correct Answer button. Thank you!

----------------------------------------------------------------------------------------------------------------------- 

View solution in original post