Content originally posted in LPCWare by lokinhas on Wed Oct 29 03:05:18 MST 2014 Hi everyone.
In my current project I'm using a LPC1788 with the SysTick acting has a global timer, for non blocking code, the problem is that when a function needs to disable momentary the SysTick the interrupt (SysTick_IRQn) a HardFault occurs.
In the past I've used several LPC microcontrollers with a Cortex-M0 core (LPC1227, LPC11U68, etc) with the exact same code, without problems.
In attachment there's a example project that you can try.
Content originally posted in LPCWare by NXP_Paul on Wed Oct 29 08:14:00 MST 2014 Try disabling the Systick interrupt using the following: SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_ENABLE_Msk;
Then re-enable the interrupt using: SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_TICKINT_Msk | SysTick_CTRL_ENABLE_Msk;
The Disbale IRQ function states the following in the core_cm3.h file:
/** \brief Disable External Interrupt
The function disables a device-specific interrupt in the NVIC interrupt controller.
\param [in] [u]IRQn External interrupt number. Value cannot be negative.[/u] */
If you look in the cmsis_1777x_8x.h file, it shows that the Systick has a negative value: SysTick_IRQn = -1,/*!< 15 System Tick Interrupt */
I changed your program using the disable/enable as shown above, and there is no longer a hardfault error.