LPC812 UART in Polling mode does not works

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

LPC812 UART in Polling mode does not works

3,105 Views
ashokfair
Contributor IV

Hi Everyone,

Im using LPC812 MAX board,

Initially i have configured the board for two UARTs (UART0 as Debug port and UART1 as external) and it works.

later i m in need of switching the external UART into polling mode (refer to lpcOpen_3_01-> periph_uart_rom_polling)

after that Debug UART stopped working. my suspect is  "Init_UART_PinMux" something going wrong here.

i have attached the polling example , please help me asap.

any other good suggestion to communicate with esp8266 without polling ?

Thanks,

Ashok r

Labels (4)
0 Kudos
Reply
10 Replies

2,625 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Ashok Ra,

How is going on about this issue? whether you had already fixed it.
Have a great day,
TIC

 

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

0 Kudos
Reply

2,625 Views
ashokfair
Contributor IV

HI Zhou,

Now the things are changed , after an release of LPC812 SDK. im trying in interrupt mode. unfortunately this time changing baud-rate did not works. 

0 Kudos
Reply

2,625 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Ashok Ra,
Thanks for your reply.
I was wondering if you can introduce the issue in details, the more information can help me to figure it out.
Have a great day,
TIC

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

0 Kudos
Reply

2,625 Views
ashokfair
Contributor IV

HI Zhou,

Thank you, sure i can explain

I am using XpressoIDE 10.2 and downloaded LPC812MAX SDK. THe default UART example baud-rate is set to 9600 for all projects (polling/interrupt/terminal). I tried to change the baud-rate in UART_Init() like below. But did not works

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

    /* Initilize the USART with configuration. */
    USART_Init(EXAMPLE_USART, &config, EXAMPLE_USART_CLK_FREQ);

I believe some clock things needs to be modified , but not sure about it. please help me.

0 Kudos
Reply

2,625 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Ashok Ra,
I'd like to suggest that you need to do some hardware circuit modification as the figure shows and give a try again.

pastedImage_3.png


Have a great day,
TIC

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

0 Kudos
Reply

2,625 Views
ashokfair
Contributor IV

HI Zhou,

Thank you! But with my same LPC MAX board previously 115200 baudrate works with LPCOpen8xx Libraries.

0 Kudos
Reply

2,625 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Ashok Ra,
Please give the modified USART_SetBaudRate()  try, it works on my site.
Have a great day,
TIC

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

status_t USART_SetBaudRate(USART_Type *base, uint32_t baudrate_Bps, uint32_t srcClock_Hz)
{
    /* check arguments */
    assert(!((NULL == base) || (0 == baudrate_Bps) || (0 == srcClock_Hz)));

#if defined(FSL_FEATURE_USART_HAS_OSR_REGISTER) && (FSL_FEATURE_USART_HAS_OSR_REGISTER)
    uint32_t best_diff = (uint32_t)-1, best_osrval = 0xf, best_brgval = (uint32_t)-1;
    uint32_t diff = 0U, brgval = 0U, osrval = 0U, baudrate = 0U;

    /* If synchronous is enable, only BRG register is useful. */
    if (base->CFG & USART_CFG_SYNCEN_MASK)
    {
        brgval = srcClock_Hz / baudrate_Bps;
        base->BRG = brgval - 1;
    }
    else
    {
        for (osrval = best_osrval; osrval >= 8; osrval--)
        {
            brgval = (srcClock_Hz / ((osrval + 1) * baudrate_Bps)) - 1;
            if (brgval > 0xFFFF)
            {
                continue;
            }
            baudrate = srcClock_Hz / ((osrval + 1) * (brgval + 1));
            diff = baudrate_Bps < baudrate ? baudrate - baudrate_Bps : baudrate_Bps - baudrate;
            if (diff < best_diff)
            {
                best_diff = diff;
                best_osrval = osrval;
                best_brgval = brgval;
            }
        }

        /* value over range */
        if (best_brgval > 0xFFFF)
        {
            return kStatus_USART_BaudrateNotSupport;
        }

        base->OSR = best_osrval;
        base->BRG = best_brgval;
    }
#else
    uint32_t brgval = 0U;
    /* If synchronous is enable. */
    if (base->CFG & USART_CFG_SYNCEN_MASK)
    {
        brgval = srcClock_Hz / baudrate_Bps;
        base->BRG = brgval - 1;
    }
    else
    {
        /* In asynchronous mode, The baud rate divider divides the common USART
         * peripheral clock by a factor of 16 multiplied by the baud rate value
         * to provide the baud rate.
         */
         brgval = srcClock_Hz / (baudrate_Bps * 16);
         if (brgval == 0) {
              brgval = 1;
         }
         SYSCON->UARTCLKDIV = brgval;

         uint32_t uart_fra_multiplier;
         RESET_PeripheralReset(kUARTFRG_RST_N_SHIFT_RSTn);
         SYSCON->UARTFRGDIV = 0xFF;
         uart_fra_multiplier = ((srcClock_Hz / brgval) * 256)/(baudrate_Bps * 16);
         SYSCON->UARTFRGMULT=uart_fra_multiplier;

        //base->BRG = brgval - 1;
    }
#endif /* FSL_FEATURE_USART_HAS_OSR_REGISTER */

    return kStatus_Success;
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
0 Kudos
Reply

2,625 Views
ashokfair
Contributor IV

Thanks TIC & Zhou

0 Kudos
Reply

2,625 Views
vojtechhavlicek
Contributor III

Hi,

When you initliazed these 2 uarts - this was via ROM API - interrupt mode / polling mode?

You generally dont need polling mode to communicate with device. 

0 Kudos
Reply

2,625 Views
ashokfair
Contributor IV

I tried with below fn call..

 Chip_UART_ReadBlocking(UART1,data,length);

but not reading all bytes.

only works with length as 1,

0 Kudos
Reply