This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

interrups not working properly

hi,
I am new to implementing interrupts and arm 7 as well.
I have just tried one example after reading the manual as well as some post.
I have few questions about the register values.
1)How do we get the value of VICVectCntl?I read the document but it's not clear.Please can someone explain me..
VICVectCntl1 = 0x20 | 7;

2)My code ehoes the character i enter on serial port uart1 but after the character it keeps on echoing 00
eg: 06 00 00..
and i see when i debug that it executes putchar_uart1()
indefinately and does not echoes any othe character i type after the first one.
Please any suggestions would help me

//main.c
#include <stdio.h>
#include <RTL.h>
#include <LPC214x.H>
int main(void)
{
init_serial1();
printf("testing \n");
while(1);
}
//end of main

//serial.c
void init_serial1 (void)  {

  PINSEL0 = 0x00050000;
  U1LCR = 0x83;
  U1DLL = 8;         //115200 baudrate
  U1LCR = 0x03;

  /* set up the interrupts */
U1IER = 0x05;   //
VICVectAddr1 = (unsigned long) u1_interrupt;   /* set interrupt vector */
VICVectCntl1 = 0x20 | 7;
VICIntEnable = 0x00000080;   /* enable uart1 interrupts */

}

void u1_interrupt (void)
{
 char intrpt;
 intrpt = U1RBR;
 putchar_uart1( intrpt );
 U1IER = 0x00;
 VICVectAddr = 0;   /* acknowledge interrupt */
}//end u1_interrupt()

int putchar_uart1(int ch)
{
  while (!(U1LSR & 0x20));
  return (U1THR = ch);
}

  • Hello ss dd,

    you must add the __irq to you ISR function like:

    void u1_interrupt __irq {
      //...
    }
    

    You have 16 possible vectored interrupts (0..15). Each of them has a pair of VICVectAddr# and VICVectCntl#. In VICVectAddr# you specify the address of the ISR and in VICVectCntl# the interrupt number and enable it.
    In your example you use pair VICVectAddr1, VICVectCntl1. In VICVectCntl1 bits 4:0 you spezify interrupt number 7 which is USART1.

    Please see LPC214x User Manual chapter 5.4 VIC Registers.

    Best Regards,
    Martin Guenther

  • Hi Martin,

    Thanks a lot for the information.Now the VICVectCntl1 is clear to me.I have also added __irq like
    void __irq u1_interrupt(void).
    Now the code hangs after echoing the first character and seems the interrupt gets executed only the first time
    Any idea why??

  • Hello ss dd,

    Within your UART1 ISR you must read the UART1 Interrupt Identification Register (U1IIR) to determine the cause of the interrupt and to clear interrupt.

    Please see LPC214x User Manual chapter 10.3.1 UART1 Interrupt Identification Register.

    Maybe you like to study the Keil example http://www.keil.com/download/docs/330.asp
    or
    http://www.keil.com/download/docs/347.asp

    Best Regards,
    Martin Guenther

  • hi martin,
    thanks once again.I went through this example
    http://www.keil.com/download/docs/330.asp

    and one thing that is not clear to me is when is com_putchar() and com_getchar() called?
    Can i call these methods from main?when should i call these method ?How should i synchronise the interrupts and calling these functions.I don't want to use fputc.

    Please tell me the easy way of understanding it

    What I understoofd is whenever a UART1 interrupt is raised it is handled by following interrupt service routine where depending on the interrupt,
    1)the character received is inserted in the buffer if it is Character Time-Out interrupt
    2)the character is removed from the buffer and stored in u1thr register if it is thre interrupt.
    void sio_irq (void) __irq {}.

    I hope i could make myself clear.If not,please let me know.
    My main objective is
    write an interrupt routine that picks up received characters from one FIFO and puts them in the transmit FIFO for the other port (start by putting the characters into the transmit FIFO of the same port to verify that you get a perfect echo function).
    Please help

  • Hello ss dd,

    com_putchr() and com_get_char() are called via fputc() and fgetc() using retargetting. Please see file Retarget.c.

    Best Regards,
    Martin Guenther

  • hi,

    My Rx interrupt is working fine but not the thre interrupt.Please can u give me a small but complete example of how thre interrupts work