Hi,
I'm trying to set the timers and attach an interrupt using the registers on my Nucleo F334R8, to be able to go faster than with the Ticker class' methods and to set priorities between the several interrupts that I will need.
After a lot of research on the internet, here's what I have tried :
DigitalOut myout(PA_5);
int main(void) {
SystemInit();
__TIM3_CLK_ENABLE();
TIM3->CR2 &= 0; // UG used as trigg output
TIM3->PSC = 0; // no prescaler
TIM3->ARR = 72000; // 1kHz
TIM3->EGR = TIM_EGR_UG; // reinit the counter
TIM3->DIER = TIM_DIER_UIE; // enable update interrupts
// enable timer
TIM3->CR1 |= TIM_CR1_CEN;
NVIC_EnableIRQ(TIM3_IRQn); // Enable interrupt from TIM3 (NVIC level)
while (1) ;
}
void TIM3_IRQHandler(void) // interrupt routine
{
if(TIM3->SR & TIM_SR_UIF) // if UIF flag is set
{
TIM3->SR &= ~TIM_SR_UIF; // clear UIF flag
myout=!myout; // toggle PA_5
}
}
but it doesn't work... I've read the programmer reference of the STM32F334 for configuring the timer's registers but I didn't really understand the NVIC part (how to activate interrupt n°54 for exemple, or how to attach a routine to the interrupt...)
I'm quite a beginner to all this : I've only used much more simple microcontrollers before.
Any help would be much appreciated!
Hi,
I'm trying to set the timers and attach an interrupt using the registers on my Nucleo F334R8, to be able to go faster than with the Ticker class' methods and to set priorities between the several interrupts that I will need.
After a lot of research on the internet, here's what I have tried :
but it doesn't work... I've read the programmer reference of the STM32F334 for configuring the timer's registers but I didn't really understand the NVIC part (how to activate interrupt n°54 for exemple, or how to attach a routine to the interrupt...) I'm quite a beginner to all this : I've only used much more simple microcontrollers before.
Any help would be much appreciated!