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

NVIC_xxx() function is not doing the inteded job

Note: This was originally posted on 5th July 2011 at http://forums.arm.com

Here is the platform setting

IAR workbench v6.20.3 for ARM
NXP-LPC1114 Gen2 MCU (Cortex M0 family)
Windows 7, Segger JLink

I'm writing boot-loader code and on the entry of the code, i would like  to disable all the interrupt sources that are active. This will allow me  to directly jump from user-application to boot-application when the  user attempts to do a firmware upgrade while the user-application is  active/running.

Specific scenario.

User-application uses SysTick timer which is not used by  Boot-application. On receiving a command to upgrade the firmware, i will  directly jump to boot application's main function.
Now the CPU is executing the Boot-application's main() function and  receives the SysTick interrupt. The manual says that NVIC_DisableIRQ()  is used to disable the interrupt/exception. But the call is failing is  to do so.

// Enables systick timer
   LPC_SYS_TICK->SYST_RVR = (((F_CPU/1000)*1)-1);
   LPC_SYS_TICK->SYST_CVR = 0;
   LPC_SYS_TICK->SYST_CSR = 0x07;  

// The following call should stop the Systick timer
   NVIC_DisableIRQ(SysTick_IRQn);

// ISR routine for Systick timer interrupt
void SysTick_Handler(void)
{
// The control should not come here if NVIC_DisableIRQ() call succeeds
}


Does anyone faced similar kind of issue? Please suggest me to handle/tackle the situation!..
Parents
  • Note: This was originally posted on 6th July 2011 at http://forums.arm.com

    Hi,

    Thanks for you reply

    But __disable_irq() and __enable_irq() is not going to disable the interrupt sources, it only delays the interrupts from getting serviced.

    Say for example when we have timer16b0 operating at the rate of 10mSec match, calling __disable_irq() is simply going to make the system such that the match interrupt will not be serviced as and when the TCNT value matches the MR0 register value.Here this function is not stopping the timer16b0 from running and so once we call __enable_irq(), it will immediately throw an interrupt for the last match interrupt occured.

    I understand NMI and HardFault couldn't be stopped as these are non-maskable interrupts. But the documentation of NVIC_DisableIRQ() says that it can be used for disabling both interrupts and exceptions.

    Other than SysTick timer source, i tried the same for timer32b0 resource as well but the function failed to do so.

    So summarizing the same, i have following queries
    1. Can someone use NVIC_DisableIRQ() for disabling the SysTick Timer?
    2. How NVIC_DisableIRQ() function behaves when IRQn defined in the negative range is passed say SVCall_IRQn or PendSV_IRQn or SysTick_IRQn?

    regards
    barani
Reply
  • Note: This was originally posted on 6th July 2011 at http://forums.arm.com

    Hi,

    Thanks for you reply

    But __disable_irq() and __enable_irq() is not going to disable the interrupt sources, it only delays the interrupts from getting serviced.

    Say for example when we have timer16b0 operating at the rate of 10mSec match, calling __disable_irq() is simply going to make the system such that the match interrupt will not be serviced as and when the TCNT value matches the MR0 register value.Here this function is not stopping the timer16b0 from running and so once we call __enable_irq(), it will immediately throw an interrupt for the last match interrupt occured.

    I understand NMI and HardFault couldn't be stopped as these are non-maskable interrupts. But the documentation of NVIC_DisableIRQ() says that it can be used for disabling both interrupts and exceptions.

    Other than SysTick timer source, i tried the same for timer32b0 resource as well but the function failed to do so.

    So summarizing the same, i have following queries
    1. Can someone use NVIC_DisableIRQ() for disabling the SysTick Timer?
    2. How NVIC_DisableIRQ() function behaves when IRQn defined in the negative range is passed say SVCall_IRQn or PendSV_IRQn or SysTick_IRQn?

    regards
    barani
Children
No data