Login

Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

ARM websites use two types of cookie: (1) those that enable the site to function and perform as required; and (2) analytical cookies which anonymously track visitors only while using the site. If you are not happy with this use of these cookies please review our Privacy Policy to learn how they can be disabled. By disabling cookies some features of the site will not work.

ARM Community: NVIC_xxx() function is not doing the inteded job - ARM Community

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

NVIC_xxx() function is not doing the inteded job Cortex M0 CMSIS Library function NVIC_DisableIRQ()

#1 User is offline   Barani Kumar Venkatesan 

  • Member
  • Pip
  • Group: Members
  • Posts: 2
  • Joined: 05-July 11

Posted 05 July 2011 - 06:56 AM

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!..
0

#2 User is offline   Joseph Yiu 

  • Regular Contributor
  • PipPipPip
  • Group: Members.
  • Posts: 217
  • Joined: 01-March 10

Posted 06 July 2011 - 08:26 AM

Hi there,
Most of the CMSIS NVIC IRQ functions only support IRQ, not system exceptions. Because the SysTick is a system exception, you need to disable this at the SysTick control register.

Note: if you want to disable ALL IRQ and system exception (apart from NMI and hardfault), you can use
__disable_irq();
and reenable ALL IRQ and system exception using
__enable_irq();

regards,
Joseph
1

#3 User is offline   Barani Kumar Venkatesan 

  • Member
  • Pip
  • Group: Members
  • Posts: 2
  • Joined: 05-July 11

Posted 06 July 2011 - 09:39 AM

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
0

#4 User is offline   Joseph Yiu 

  • Regular Contributor
  • PipPipPip
  • Group: Members.
  • Posts: 217
  • Joined: 01-March 10

Posted 07 July 2011 - 09:13 AM

1. Can someone use NVIC_DisableIRQ() for disabling the SysTick Timer?

No, you cannot.

2. How NVIC_DisableIRQ() function behaves when IRQn defined in the negative range is passed say SVCall_IRQn or PendSV_IRQn or SysTick_IRQn?

With the current implementation (CMSIS v2.0), you can find the NVIC_Disable() in the core_cm0.h
static __INLINE void NVIC_DisableIRQ(IRQn_Type IRQn)
{
NVIC->ICER[0] = (1 << ((uint32_t)(IRQn) & 0x1F));
}

From this code, you can find that if you feed a negative number in, you will disable the wrong interrupt.

The CMSIS NVIC functions only work with the NVIC, and is independent to the peripehrals. If you want to disable the interrupt at the peripherals, you must either:
- use device driver functions from the microcontroller vendors if available, or
- program the peripherals directly.
1

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic