LPC2132/01 FIQ interrupt handler

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • LPC2132/01 FIQ interrupt handler


    We had to add in our project LPC2132/01 FIQ interrupt handler. Due to bug in most NXP ARM based controllers, I had to disable & re enable both IRQ & FIQ bits in ARM CSPR register while refreshing CPU watchdog. Since embOS functions OS_EnableInt() / OS_DisableInt() in file OS_Priv.h only effects IRQ bit, I made my own functions which set & clear the two bits rather then only one.

    My question is – how can I be sure that register r12 is free, and that it is OK to do CPSR register modifications by the help of r12 without saving it 1st to stack (this is how it is done in your code)

    C Source Code

    1. /********************************************************************
    2. * HAL_En_IRQ_FIQ()
    3. *
    4. * This function enable CPU IRQ (used by VIC) and FIQ interrupt
    5. *
    6. * Parameters:
    7. *
    8. * Return:
    9. *********************************************************************/
    10. __interwork __arm void HAL_En_IRQ_FIQ(void)
    11. {
    12. __asm("mrs r12,CPSR") ;
    13. __asm("bic r12,r12,192"); // Clear CPSR IRQ_DISABLE (bit#7), and FIQ_DISABLE (bit#6)
    14. __asm("msr CPSR_c,r12") ;
    15. }
    16. /********************************************************************
    17. * HAL_Dis_IRQ_FIQ()
    18. *
    19. * This function disable CPU IRQ (used by VIC) and FIQ interrupt
    20. *
    21. * Parameters:
    22. *
    23. * Return:
    24. *********************************************************************/
    25. __interwork __arm void HAL_Dis_IRQ_FIQ(void)
    26. {
    27. __asm("mrs r12,CPSR") ;
    28. __asm("orr r12,r12,192"); // Set CPSR IRQ_DISABLE (bit#7), and FIQ_DISABLE (bit#6)
    29. __asm("msr CPSR_c,r12") ;
    30. }
    Display All

  • Hello Michael,

    The register r12 is a scratch register, so you can use it in your function w/o the need to save it on the stack.
    If an interrupt occurs the interrupt handler saves and restores register r12, so your own functions are ok.

    If you have any further questions regarding this issue please don't hesitate to post it here.