First hello to everyone.
Sorry for my English.
I tell you.
I'm starting to use microcontrollers ARM7 specifically the LPC2134 and I am performing a bidirectional serial communication.
The program consists blink an LED to verify that the system is working, and UART communication with a PC and a serial adapter to convert levels.
My purpose is to use a vectored IRQ interrupt, so that when some data arrives the program stops and observe the interrupt and save the received data in an array for later processing.
In addition I make a bluque sending the ASCII table to the PC.
My problem is that encuanto recivo a data interruption jumps and I can not in any way out of it by staying in an infinite loop in the interruption.
The program I'm doing with the KEIL 4.
Main Program
int main()
{
Init_pll();
VICIntEnClr=0xFFFF;//Borro cualquier posible interrupcion
Init_gpio();
init_uart();
i=0;
while (1)
{
for(i=0;i<256;i++)
{
LED_blink ();//Parpadeo del LED
ENVIA_BYTETX0(i);
}
}
}
UART CONFIGURATION
void init_uart(void)
{
U0LCR=0x03;
U0FDR=0x10;//Multivall a 1
U0LCR|=BIT7;//Activo Bit DLAB para poder configurar velocidad
U0DLL=divisor & 0xFF;
U0LCR &=~BIT7;//Borro Bit DLAB para poder configurar velocidad
U0FCR=1;//Activo FIFO
U0IER = 0;//Desabilito interrupciones UART 1
VICIntSelect &= ~(1<<UART_0);
VICDefVectAddr |= (1<<UART_0);
VICVectCntl10 = 0x20 | UART_0; /* Prioridad 0 Vectorizada use it for UART 0 Interrupt*/
VICVectAddr10 = (unsigned long)RX_UART_CERO ; /* set interrupt vector in 0 */
VICIntEnable |= BIT6; /* Enable UART0 Interrupt */
U0IER = 1;//Habilito interrupcion de recepcion de datos validos
}
INTERRUPT
_irq void RX_UART_CERO (void)
{
if(U0IIR&DR) // Infinite loop
{
while (!(U0LSR&DR));
if(PUNT_W0<512)
{
BUFFER_UART0[PUNT_W0]=U0RBR;
PUNT_W0++;
}
else;
}
else;
VICVectAddr &= 0x0000;//Clear Flag Interrupts but not exit and return to Infinite loop
}
Everything works fine until you receive date UART in the LPC. Then jumps to the interruption and there does not come out.
No longer what to do, I take several days reading the datasheet and reviewing the program, but can not find anything wrong.
I request help from someone who can guide me to solve the problem and continue learning.
Thanks you very much.
Hi Roberto,
It seems that your code is not clearing the U0IIR register, which indicates if there is a pending interrupt, causing a loop on the ISR. For further details, you could refer to the following links:
http://www.keil.com/forum/20979/
http://www.nxp.com/documents/application_note/AN10414.pdf
Hope this will be useful for you.
Best regards!
/Carlos
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Ok.
Thanks you very much Carlos.
Thanks to your help I could solve the problem.
Best regards.
Roberto