2020-11-17 06:18 AM
Hello,
Working on STM32F030R8 nucleo board, using MXcube, i am trying to use the same timer as the one who is used to generate a PWM output.
For this, i am used to use HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef* htim) with if(htim->Instance == TIM1) but nothing happens whereas it does for other timer with the same settings.
Maybe the way to used the same timer event is different because already used for PWM, is it ?
Thank you,
2020-11-17 09:00 AM
TIM1 is different from other timers in that it has a separate interrupt for Capture/Compare, and a different one for Update and other events. Make sure you have enabled the latter (TIM1_BRK_UP_TRG_COM_IRQn) and that the ISR is appropriately named, too.
Also read out and check the TIM registers, mainly if TIM1_DIER.UIE is set.
JW
2020-11-19 06:36 AM
Hello Waclawek.jan and thank you for your answer.
(TIM1_BRK_UP_TRG_COM_IRQn) was already enable.
I have set the UIE bit of TIM1_DIER which i did not found configured at all, but it changes nothing.
And what do you mean by "the ISR is approriately nammed" ?
As i was worknig exclusively with HAL functions thanks to CubeMX and i was not really understanding the fundamental aspect of the way it works, i have decided to run through the datasheet (DMA, Interrupts and Events, ADC and finally timers chapters) in order to have the knowledge for what i need in my project.
My english is not my native language and as i am quite new in STM32 microcontroller, i have some basic questions. It would be great if you could bring lights on it (thanks in advance :smiling_face_with_smiling_eyes: )
I know it will take some time to answer, but i think it will be helpfull for the next new developpers =)
1.DMA chapter:
=> Which of the above condition trigger the DMA transfer ? As i understand the DMA channel Configuration sequence code exampe,
I guess DMA channel should be enable first and the DMA request mapping triggers the DMA. Is that correct ?
2.Interrupts and Events chapter:
3.ADC chapter
4.For the Timers part, i am still studying..:anxious_face_with_sweat:
Thank you ,
2020-11-19 08:11 PM
> I guess DMA channel should be enable first and the DMA request mapping triggers the DMA. Is that correct ?
Yes. But ADC presents an extra complication, maybe as an initial experiment, you may want to do a timer-triggered transfer, maybe from memory to GPIO or other TIM.
Try using it to blink a LED without any software running in main loop, only initializing peripherals. I may have some examples in that direction on efton.sk.
Doing that exercise will maybe answer your "why".
> EXTI
NVIC is part of processor core handling all interrupts. EXTI only interface the pin-related interiors, plus some few others which are wakeup related. Both edges generate interrupt, if you are able to process them fast enough.
>DMA_EOT
I don't use Cube not any other "library" exactly because they do these unnecessary renames. Cube is open source so you can look these things up yourself.
> DMA_IFCR
That's a register to *clear* already set flags.
>studying..:anxious_face_with_sweat:
The key is to both read and experiment. After reading about some feature, write a simple test program to verify if you've understood correctly what you've just read.
JW