2023-02-13 05:04 AM
I am using STM32L412 microcontroller and doing baremetal programming for timer interrupt. I am using Timer 6 and base clock of 4MHZ is used as HCLK. However my interrupt is not firing below mentioning my code. count variable is also not updating
int main(void)
{
LedConfig();
StartTimer6();
/* Loop forever */
while(1)
{
count=1;
}
}
void LedConfig(void)
{
/*Enable Clock for Port B. */
RCC->AHB2ENR |= (1U<<1);
/*Configure GPIOB_13 as general purpose output*/
GPIOB->MODER |= (1U<<26);
GPIOB->MODER &= ~(1U<<27);
}
void StartTimer6(void)
{
RCC->APB1ENR1 |= (1U<<4);
TIM6->PSC = 1000;
TIM6->ARR = 4000;
TIM6->EGR |= (1U<<0);
TIM6->DIER |= (1U<<0);
TIM6->CR1 |= (1U<<0);
NVIC_EnableIRQ(TIM6_IRQn);
}
void TIM6_IRQHandler(void)
{
if(TIM6->SR & (1U<<0))
{
GPIOB->ODR ^= (1U<<13);
TIM6->SR &= ~(1U<<0);
}
}
Solved! Go to Solution.
2023-02-14 02:41 AM
Thanks @KnarfB as you said IRQ handler was different the actual one is TIM6_DACUNDER_IRQHandler. After I changed the handler name the code started working
2023-02-14 02:48 AM
Glad it works. To add some confusion: stm32l412xx.h (ARM CMSIS) and others contains a line
/* Aliases for __IRQHandler */
#define TIM6_IRQHandler TIM6_DAC_IRQHandler
which covers that error up. But you don't seem to use that.
KnarfB
2023-02-14 03:01 AM
Nice catch, @KnarfB !
> TIM6_DACUNDER_IRQHandler
I've never seen handler name like this. As I've said above, I would like to know where that startup_stm32l412rbtx.s is from.
JW
2023-02-14 03:21 AM
when I tried the debug mode startup_stm32l412rbtx.s was autoloading because of the error, it was in the debug folder under projectname.elf -[arm/le]. I got the Handler name from this file.
2023-02-14 03:58 AM
What toolchain / version are you using?
KnarfB