<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Keil programming for interrupts</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/34172/keil-programming-for-interrupts</link><description> 
Hi everyone, 

 
I dont know what should I do to let the keil compiler know refer
to which function when interrupt occur. I know interrupt functions
are followed with _irq prefix but there may be several of these
functions! 
 </description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: Keil programming for interrupts</title><link>https://community.arm.com/thread/117700?ContentTypeID=1</link><pubDate>Fri, 09 Jan 2015 00:45:33 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:d2cf7c2e-55b3-4d27-a1b5-22c09baf35ee</guid><dc:creator>Hamed Adldoost</dc:creator><description>&lt;p&gt;&lt;p&gt;
Dear all friends,&lt;/p&gt;

&lt;p&gt;
Thanks for your helpful advises. Yes I see that the function
USARTInit() installs my usart function &amp;#39;UART0Handler&amp;#39; in the VIC
table by following code:&lt;/p&gt;

&lt;pre&gt;
 if ( install_irq( UART0_INT, (void *)UART0Handler ) == FALSE )
    {
        return (FALSE);
    }
&lt;/pre&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Keil programming for interrupts</title><link>https://community.arm.com/thread/108038?ContentTypeID=1</link><pubDate>Thu, 08 Jan 2015 20:44:02 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:64cf194b-f154-4c9c-b3e8-91633f5ac0c4</guid><dc:creator>edPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
The same source code bundle where you did find this UART ISR did
also contain the source code to initialize the UART - and that code
did contain a source code line that used the name of the ISR
function. That&amp;#39;s the line that associate the UART ISR with that
specific UART.&lt;/p&gt;

&lt;p&gt;
It&amp;#39;s always a good idea to not just cut some lines from example
programs but to actually try and run the examples and to use the
processor datasheet/user manual and lookup the description of how
different parts of the processor works until you understand exactly
what the source code deoes.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Keil programming for interrupts</title><link>https://community.arm.com/thread/120482?ContentTypeID=1</link><pubDate>Thu, 08 Jan 2015 17:43:27 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:ef3ed783-6737-4877-b932-5de0919ed060</guid><dc:creator>John Linq</dc:creator><description>&lt;p&gt;&lt;p&gt;
For Example:&lt;/p&gt;

&lt;pre&gt;
/******************************************************************************
** Function name:               install_irq
**
** Descriptions:                Install interrupt handler
** parameters:                  Interrupt number, interrupt handler address,
**                                              interrupt priority
** Returned value:              true or false, return false if IntNum is out of range
**
******************************************************************************/
DWORD &lt;b&gt;install_irq&lt;/b&gt;( DWORD IntNumber, void *HandlerAddr, DWORD Priority )
{
    DWORD *vect_addr;
    DWORD *vect_prio;

    VICIntEnClr = 1 &amp;lt;&amp;lt; IntNumber; /* Disable Interrupt */
    if ( IntNumber &amp;gt;= VIC_SIZE )
    {
                return ( FALSE );
    }
    else
    {
                /* find first un-assigned VIC address for the handler */
                vect_addr = (DWORD *)(VIC_BASE_ADDR + VECT_ADDR_INDEX + IntNumber*4);
                vect_prio = (DWORD *)(VIC_BASE_ADDR + VECT_PRIO_INDEX + IntNumber*4);
                *vect_addr = (DWORD)HandlerAddr;        /* set interrupt vector */
                *vect_prio = Priority;
                VICIntEnable = 1 &amp;lt;&amp;lt; IntNumber;    /* Enable Interrupt */
                return( TRUE );
    }

/******************************************************************************
** Function name:               init_timer
**
** Descriptions:                Initialize timer, set timer interval, reset timer,
**                                              install timer interrupt handler
**
** parameters:                  timer number and timer interval
** Returned value:              true or false, if the interrupt handler can&amp;#39;t be
**                                              installed, return false.
**
******************************************************************************/
DWORD init_timer ( BYTE timer_num, DWORD TimerInterval )
{
  if ( timer_num == 0 )
  {
        timer0_counter = 0;
        T0MR0 = TimerInterval;
        T0MCR = 3;                              /* Interrupt and Reset on MR0 */
#if FIQ
        /* FIQ is always installed. */
        VICIntSelect |= (0x1&amp;lt;&amp;lt;4);
        VICIntEnable = (0x1&amp;lt;&amp;lt;4);
        return (TRUE);
#else
        if ( &lt;b&gt;install_irq&lt;/b&gt;( TIMER0_INT, (void *)Timer0Handler, HIGHEST_PRIORITY ) == FALSE )
        {
          return (FALSE);
        }
        else
        {
          return (TRUE);
        }
#endif
  }
  else if ( timer_num == 1 )
  {
        timer1_counter = 0;
        T1MR0 = TimerInterval;
        T1MCR = 3;                              /* Interrupt and Reset on MR1 */
#if FIQ
        VICIntSelect |= (0x1&amp;lt;&amp;lt;5);
        VICIntEnable = (0x1&amp;lt;&amp;lt;5);
        return (TRUE);
#else
        if ( install_irq( TIMER1_INT, (void *)Timer1Handler, HIGHEST_PRIORITY ) == FALSE )
        {
          return (FALSE);
        }
        else
        {
          return (TRUE);
        }
#endif
  }
  return (FALSE);
}
&lt;/pre&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Keil programming for interrupts</title><link>https://community.arm.com/thread/118584?ContentTypeID=1</link><pubDate>Thu, 08 Jan 2015 16:21:32 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:8bb750a9-f28f-4ff8-ba27-23af581c1b99</guid><dc:creator>Westonsupermare Pier</dc:creator><description>&lt;p&gt;&lt;p&gt;
So an ARM7 with an NXP/LPC Vectored Interrupt Controller
(VIC).&lt;/p&gt;

&lt;p&gt;
The jump via the VIC is likely in startup.s and when you configure
the VIC you put the address of your IRQ Handler into the slot/vector
set aside for the UART0.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Keil programming for interrupts</title><link>https://community.arm.com/thread/82350?ContentTypeID=1</link><pubDate>Thu, 08 Jan 2015 14:26:45 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:a6227780-31a2-4678-9de0-c3912a1e2d8e</guid><dc:creator>Hamed Adldoost</dc:creator><description>&lt;p&gt;&lt;p&gt;
Dear Westonsupermare,&lt;/p&gt;

&lt;p&gt;
Thanks, I am using LPC2138.&lt;br /&gt;
I see in a example program for usart0 interrupt handlers like below.
I dont know where in this function compiler understands USART0
interrupt calls this function:&lt;/p&gt;

&lt;pre&gt;
void UART0Handler (void) __irq
{
    BYTE IIRValue, LSRValue;
    BYTE Dummy;

    IENABLE;                            /* handles nested interrupt */
    IIRValue = U0IIR;

    IIRValue &amp;gt;&amp;gt;= 1;                       /* skip pending bit in IIR */
    IIRValue &amp;amp;= 0x07;                       /* check bit 1~3, interrupt identification */
    if ( IIRValue == IIR_RLS )          /* Receive Line Status */
    {
        LSRValue = U0LSR;
        /* Receive Line Status */
        if ( LSRValue &amp;amp; (LSR_OE|LSR_PE|LSR_FE|LSR_RXFE|LSR_BI) )
        {
            /* There are errors or break interrupt */
            /* Read LSR will clear the interrupt */
            UART0Status = LSRValue;
            Dummy = U0RBR;              /* Dummy read on RX to clear
                                        interrupt, then bail out */
            IDISABLE;
            VICVectAddr = 0;            /* Acknowledge Interrupt */
            return;
        }
        if ( LSRValue &amp;amp; LSR_RDR )   /* Receive Data Ready */
        {
            /* If no error on RLS, normal ready, save into the data buffer. */
            /* Note: read RBR will clear the interrupt */
            UART0Buffer[UART0Count] = U0RBR;
            UART0Count++;
            if ( UART0Count == BUFSIZE )
            {
                UART0Count = 0;         /* buffer overflow */
            }
        }
    }
    else if ( IIRValue == IIR_RDA )     /* Receive Data Available */
    {
        /* Receive Data Available */
        UART0Buffer[UART0Count] = U0RBR;
        UART0Count++;
        if ( UART0Count == BUFSIZE )
        {
            UART0Count = 0;             /* buffer overflow */
        }
    }
    else if ( IIRValue == IIR_CTI )     /* Character timeout indicator */
    {
        /* Character Time-out indicator */
        UART0Status |= 0x100;           /* Bit 9 as the CTI error */
    }
    else if ( IIRValue == IIR_THRE )    /* THRE, transmit holding register empty */
    {
        /* THRE interrupt */
        LSRValue = U0LSR;               /* Check status in the LSR to see if
                                        valid data in U0THR or not */
        if ( LSRValue &amp;amp; LSR_THRE )
        {
            UART0TxEmpty = 1;
        }
        else
        {
            UART0TxEmpty = 0;
        }
    }

    IDISABLE;
    VICVectAddr = 0;            /* Acknowledge Interrupt */
}
&lt;/pre&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Keil programming for interrupts</title><link>https://community.arm.com/thread/63401?ContentTypeID=1</link><pubDate>Thu, 08 Jan 2015 13:56:24 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:77601e0e-4ba2-49aa-9604-af4ed7b66a24</guid><dc:creator>Westonsupermare Pier</dc:creator><description>&lt;p&gt;&lt;p&gt;
Going to depend on the processor, for a Cortex-Mx part there&amp;#39;s a
vector table and it can call regular C subroutines. On ARM7/9 parts
there&amp;#39;s a IRQ/FIQ vector and that you&amp;#39;d need some special
prologue/epilogue code where you&amp;#39;d need the _irq directive.&lt;/p&gt;

&lt;p&gt;
So what exactly are you using?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>