PWM, interrupt and call-back
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-03-16 11:48 PM
Hello,
I am studyng (first time) PWM using a Nucleo_401RE, STMCubeIDE, and HAL drivers;
I write some example using interrupt TIM2 and its TIM2_CH1 and PA5 to control the green led LD2.
The counter count UP, in the TIM2_IRQHandler , for the moment , I do nothing.
The signal is correct, but I have some question about HAL_TIM_OC_Start_IT and HAL_TIM_PWM_Start_IT , the first is:
where read complete documents about this Hal functions?
The user manual UM1725 say:
HAL_TIM_PWM_Start_IT
Starts the PWM signal generation in interrupt mode. (Very interesting)
HAL_TIM_OC_Start_IT
Starts the TIM Output Compare signal generation in interrupt mode. (Ah! interesting)
Why I ask this?
I want use a call back due to the interrupt call;the STMCubeIDE in NVIC have only one kind of interrupt: TIM2 global interrupt
I SUPPOSE that some differernts call back are possible only in base of the type of ____start, but what?
The famous UM1725 say, for example:
HAL_TIM_PeriodElapsedCallback
Period elapsed callback in non blocking mode. (Very interesting ...)
In details:
I want have DIFFERENTS call back when counter reach CCR and when when counter reload from ARR (I SUPPOSE there are two different IRQ calls) ;
Or recognize the two moments.
I have tryed different combination of kind of ____start and kind of call back: No valid results.
Many thanks and excuse for my english, but after Brexit ...
Luciano
- Labels:
-
STM32CubeIDE
-
STM32F4 Series
-
TIM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-03-17 12:47 AM
> I SUPPOSE there are two different IRQ calls
In most of the timers, no. TIM1 is the notable exception (still merging some/many of the interrupts, and adding interrupts from other timers, at times; and maybe partially TIM8. Read the interrupt chapter in Reference Manual (RM).
> Or recognize the two moments.
You normally distinguish them (or, better, react to any of them) by reading TIMx_SR in the ISR. Note that you have to clear it (Cube/HAL does this for you if you call its internal whatnot) and that requires *writing* zeros to particular TIMx_SR bits (i.e. not RMW!)
> The famous UM1725
Read the sources, Cube/HAL is open source.
Or, way better, ditch Cube entirely and go for adult programming. RM is your friend.
JW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-03-17 1:25 AM
HAL functions are rather poorly documented, I could never figure out how these HAL_TIM_ functions are supposed to work.
Using the register interface as documented in the reference manual works without much guesswork.
GPIO setup would of course be different for your board.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-03-17 4:27 AM
Many thanks. I search for sources , I don't know where...
And many thanks, really I'm not adult : only 47 year old ( in Hex obviously).
luciano
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-03-17 4:28 AM
Many thanks. I try ...
Luciano
