LPC 1769 UART FIFO problem

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

LPC 1769 UART FIFO problem

1,639 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by J.K. on Mon Mar 26 08:04:04 MST 2012
Hello!

I´m trying to read 8 bytes of data from the Uart RX FIFO at once. Is this possible? Can I set the registers so that I only get one interuppt when the FIFO contains 8 bytes and then just read it or do I need to handle every byte every time it is received at the RX buffer?

Very grateful for any help!
0 Kudos
Reply
4 Replies

1,077 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by gbm on Sun Apr 08 09:27:39 MST 2012
Actually you get an interrupt if either there is a preset number of bytes present in the FIFO OR some time has passed after receiving the last byte (32 bit slices or something similar, stated explicitly in the docs. This is how it should behave and, AFAIK, it's precisely what it does.
0 Kudos
Reply

1,077 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by justchen on Sat Apr 07 20:32:56 MST 2012
I have the same problem with LPC1768,
    /*  configuration uart0 pin function */
    PinCfg.Funcnum = 1;                         // UART function number was 1
    PinCfg.OpenDrain = PINSEL_PINMODE_NORMAL;
    PinCfg.Pinmode = PINSEL_PINMODE_PULLUP;
    PinCfg.Pinnum = 2;
    PinCfg.Portnum = 0;                      // port0.2
    PINSEL_ConfigPin(&PinCfg);
    PinCfg.Pinnum = 3;                      // port0.3
    PINSEL_ConfigPin(&PinCfg);

    /*  configuration uart0 function */
    uartCfg.Baud_rate = 115200;
    uartCfg.Parity = UART_PARITY_NONE;
    uartCfg.Databits = UART_DATABIT_8;
    uartCfg.Stopbits = UART_STOPBIT_1;

    /*
    UART_FIFOConfigStructInit(&uartFIFOType);
    uartFIFOType.FIFO_DMAMode = DISABLE;
    uartFIFOType.FIFO_Level = UART_FIFO_TRGLEV2;    // UART FIFO trigger level 2: 8 character
    uartFIFOType.FIFO_ResetRxBuf = DISABLE;    
    uartFIFOType.FIFO_ResetTxBuf = DISABLE;
    //uartFIFOType.FIFO_State = ENABLE;        
    UART_FIFOConfig(LPC_UART0,&uartFIFOType);
    */
    LPC_UART0->FCR = ( (2<<6) | 1 );
    
    UART_Init(LPC_UART0,&uartCfg);
    UART_TxCmd(LPC_UART0, ENABLE);    // enable UART0 tx

    UART_IntConfig(LPC_UART0, UART_INTCFG_RBR, ENABLE);        // enable UART0 RX interrupt
    UART_IntConfig(LPC_UART0, UART_INTCFG_THRE, ENABLE);    // enable UART0 TX interrupt

        /* preemption = 1, sub-priority = 1 */
    NVIC_SetPriority(UART0_IRQn, ((0x01<<3)|0x01));    // set uart0 interrupt priority
    /* Enable Interrupt for UART0 channel */
    NVIC_EnableIRQ(UART0_IRQn);    // enable uart0 interrupt for NVIC

It get an interrupt for every byte too.:confused:
0 Kudos
Reply

1,077 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by J.K. on Mon Mar 26 09:30:06 MST 2012
Thanks for the answer. I have the following initialization code:

PINSEL_CFG_Type PinCfg;
    UART_CFG_Type uartCfg;
    UART_FIFO_CFG_Type FIFOCfg;

    /* Initialize UART3 pin connect */
    PinCfg.Funcnum = 2;
    PinCfg.Pinnum = 0;
    PinCfg.Portnum = 0;
    PINSEL_ConfigPin(&PinCfg);
    PinCfg.Pinnum = 1;
    PINSEL_ConfigPin(&PinCfg);

    uartCfg.Baud_rate = 57600;
    uartCfg.Databits = UART_DATABIT_8;
    uartCfg.Parity = UART_PARITY_NONE;
    uartCfg.Stopbits = UART_STOPBIT_1;
    UART_Init(UART_DEV, &uartCfg);

    /* Initialize FIFO register */
    FIFOCfg.FIFO_DMAMode = DISABLE;
    FIFOCfg.FIFO_Level = UART_FIFO_TRGLEV2;
    FIFOCfg.FIFO_ResetRxBuf = ENABLE;
    FIFOCfg.FIFO_ResetTxBuf = ENABLE;
    UART_FIFOConfig(LPC_UART3, &FIFOCfg);

    NVIC_EnableIRQ(UART3_IRQn);

    UART_TxCmd(UART_DEV, ENABLE);

    UART_IntConfig(LPC_UART3, UART_INTCFG_RBR, ENABLE);

I still get an interrupt for every byte that I send. I´ve tried to remove some of the interrupts but then I never enter the interrupt handler. How does one read the FIFO? Do I have to read the RBR register as many times as I got bytes in the FIFO or can I access the data in another way? There is a lot of confusion here
0 Kudos
Reply

1,077 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Polux rsv on Mon Mar 26 09:03:38 MST 2012
In the user manual, UM10360.pdf, read :rolleyes: the chapter 14 describing the Uart. And specially the UxFCR, bits 6 and 7. You can set 1, 4, 8 or 14 received cars before an interrupt is firing.

Angelo
0 Kudos
Reply