i am using LPC11C24FBD48 Controller and i initialized the Stick timer but when i run the code it is going to Hard fault handler.
__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks){ if (ticks > SysTick_LOAD_RELOAD_Msk) return (1); /* Reload value impossible */
SysTick->LOAD = (ticks & SysTick_LOAD_RELOAD_Msk) - 1; /* set reload register */ NVIC_SetPriority (SysTick_IRQn, (1<<__NVIC_PRIO_BITS) - 1); /* set Priority for Systick Interrupt */ SysTick->VAL = 0; /* Load the SysTick Counter Value */ SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_TICKINT_Msk | SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ return (0); /* Function successful */} this is the stick timer code please help me
If your code is running in unprivileged state, you will get HardFault as unprivileged code is not allowed to access the SysTick timer.
Another possible issue is that if the SysTick Handler has not been defined and SysTick interrupt is triggered, it will then depends on how the vector table is defined. If by default unimplemented interrupt/exception handlers go into HardFault handler, you might end up with Program Counter reaching HardFault handler, although actually it is trying to run a SysTick handler.
regards,
Joseph