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

I don't know how I can write my ISR routine with cortex m3

Dear Sir/Madam
I'm new in ARM programming with c .I saw the following code to handle timer ISR :

__irq void TIMER1_IRQHandler(void)
{
.
.
.
return;
}


can you introduce me some documents which I will be able to learn how to write my ISR code and how to use them in my code and learning ISR function instructions?

Thanks and bet regards.
Mohsen

Parents
  • Thank you for your kindly reply.My interested microcontroller is Lpc1768 ad I would like to learn the fucntions code which I can write them to Keil or IAR compiler in order to handle ISR when the interrupt request is occurred.
    I would like to learn such this code in lpc1768:

    __irq void Timer1_IRQHandler(void)
    {
    .
    .
    return
    }
    


    and such following code in lpc2132:

    * IRQ_ISR_Handler()
    ****************************************************************/
    #pragma vector=0x18
    __irq __arm void IRQ_ISR_Handler( void )
    {
      void ( *interruptFunction ) ();
      unsigned int vector;
    
      vector = VICVectAddr;         // Get interrupt vector.
      interruptFunction = ( void( * ) () ) vector;
      ( *interruptFunction ) ();   // Call vectored interrupt function.
    }
    


    Is your offered book appropriate for this purpose?

Reply
  • Thank you for your kindly reply.My interested microcontroller is Lpc1768 ad I would like to learn the fucntions code which I can write them to Keil or IAR compiler in order to handle ISR when the interrupt request is occurred.
    I would like to learn such this code in lpc1768:

    __irq void Timer1_IRQHandler(void)
    {
    .
    .
    return
    }
    


    and such following code in lpc2132:

    * IRQ_ISR_Handler()
    ****************************************************************/
    #pragma vector=0x18
    __irq __arm void IRQ_ISR_Handler( void )
    {
      void ( *interruptFunction ) ();
      unsigned int vector;
    
      vector = VICVectAddr;         // Get interrupt vector.
      interruptFunction = ( void( * ) () ) vector;
      ( *interruptFunction ) ();   // Call vectored interrupt function.
    }
    


    Is your offered book appropriate for this purpose?

Children
  • Given where you're at on the learning curve it could only help.

    void ADC_IRQHandler(void) {
      volatile uint32_t adstat;
    
      adstat = LPC_ADC->ADSTAT;                       /* Read ADC clears interrupt     */
    
      AD_last = (LPC_ADC->ADGDR >> 4) & ADC_VALUE_MAX; /* Store converted value   */
    
      AD_done = 1;
    }
    

    The M3 doesn't require the __irq directive of the ARM7/9 cores, you will need to become familiar with the NVIC on the M3, and the hardware/peripheral configuration of your NXP part. Reading the manuals would be a good start.

    I'm sure there are other code examples an internet search away.