lpc824 uart RXRDY interrupt

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

lpc824 uart RXRDY interrupt

1,155 Views
alvarasmikalain
Contributor I

Hello, I encountered a problem with RXRDY interrupt of uart in LPC824. I lost first bytes of packet sometimes.

One processor send packet of bytes (13 bytes) every 2 seconds. Another should receive that packet via interrupt. Receiver correctly accept in example 5 packets and the 6'th packets first two bytes was lost (interrupt not generated) and from third byte residual packet was received ok. Then again all ok wiht next packets, but after some time first bytes missing and so on.

Strange thing that if I use pooling method in main loop(if(( LPC_USART1->STAT & 0x01)==1)), then all bytes received correctly, none bytes are lost. So I think interrupt not always generated?

LPC824 main clock is 60mhz, systemcoreclock 30mhz., uart  baudrate 115200 (but with others baudrates situaciot the same).

uart configuration:

const uint32_t UARTCLKDIV=1;
/* Reset FRG */
LPC_SYSCON->PRESETCTRL &= ~ (1<<2);
LPC_SYSCON->PRESETCTRL |= (1<<2);

LPC_SYSCON->UARTCLKDIV=UARTCLKDIV;
LPC_SYSCON->UARTFRGDIV=0xFF;
clk = SystemCoreClock*2/UARTCLKDIV;

NVIC_DisableIRQ(UART1_IRQn);
//enable uart
LPC_SYSCON->SYSAHBCLKCTRL |= (1<<15);
//reset uart
LPC_SYSCON->PRESETCTRL&=~(1<<4);
LPC_SYSCON->PRESETCTRL|=(1<<4);
//enable pin switch
LPC_SYSCON->SYSAHBCLKCTRL |= (1<<7);F

LPC_SWM->PINASSIGN1 = 0xFF1706FFUL;

LPC_USART1->CFG=0;
LPC_USART1->CFG |= (1 << 2);

LPC_USART1->BRG = clk / 16 / baudrate - 1;
LPC_SYSCON->UARTFRGMULT = (((clk / 16) * (LPC_SYSCON->UARTFRGDIV + 1)) /
(baudrate * (LPC_USART1->BRG + 1))) - (LPC_SYSCON->UARTFRGDIV + 1);

LPC_USART1->INTENSET = 1; // Enable UART interrupt rx
while ( LPC_USART1->STAT & 0x01)
regVal = LPC_USART1->RXDAT; // Dump data from RX FIFO

NVIC_SetPriority(UART1_IRQn,0);
NVIC_EnableIRQ(UART1_IRQn); 
LPC_USART1->CFG |= (1 << 0);

Labels (1)
0 Kudos
2 Replies

594 Views
alvarasmikalain
Contributor I

Ok I will try NXP-examples.

0 Kudos

594 Views
fjrg76
Contributor IV

It seemed you take the bare-bones way, Have you tried the NXP-examples? Although not perfect, they help from time to time to get things done. May be you should try them so you can isolate the error source (if any).

0 Kudos