AnsweredAssumed Answered

Issue with SysTick interrupt not triggering on STM32F0

Question asked by sknab on Mar 14, 2016
Latest reply on Mar 14, 2016 by Clive One
I've been having trouble with getting the SysTick interrupt to trigger in a simple program using the standard peripheral library. The code should just pulse an LED every time the SysTick interrupt fires, but instead it just sits in the main() loop and never toggles the GPIO.

#include "stm32f0xx.h"
 
GPIO_InitTypeDef    GPIO_InitStruct;
NVIC_InitTypeDef    NVIC_InitStruct;
 
void init()
{
    RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
    GPIO_InitStruct.GPIO_Pin = GPIO_Pin_6;
    GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
    GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
    GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;
    GPIO_Init(GPIOA, &GPIO_InitStruct);
 
    NVIC_InitStruct.NVIC_IRQChannel = SysTick_IRQn;
    NVIC_InitStruct.NVIC_IRQChannelPriority = 0;
    NVIC_Init(&NVIC_InitStruct);
 
    SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK_Div8);
}
 
void LED_On()
{
    GPIOA->BRR = GPIO_Pin_6;
}
 
void LED_Off()
{
    GPIOA->BSRR = GPIO_Pin_6;
}
 
int main()
{
    init();
    LED_Off();
    for(;;);
}
 
void SysTick_Handler()
{
    LED_On();
    LED_Off();
}

Am I missing something obvious that's needed to set up the SysTick interrupt handler? I've been looking around for a while and I haven't seen something other people are doing with the standard peripheral library that I'm not.

Thanks for any help.

Outcomes