cancel
Showing results for 
Search instead for 
Did you mean: 

Get PWM output state for interrupt purposes STM32F215

Zarck.zek
Associate II
Posted on February 01, 2018 at 09:37

Hi,

I'm working on STM32F215 and I generate a PWM output on TIM1. This signal is going to an other device.

For synchronization purposes on this signal, I would like to get the rising and falling edge of it.

My first thought is to link the PWM ouptut directly to a EXTI pin in order to get my edges interrupt.

I just begin working withTimerbut I'm just there is a simple way to get those PWM informations.

Could you please help me with a code example/interrupt configuration ?

Thank you very much,

Marc

#interrput #tim-pwm #stm32f2

Note: this post was migrated and contained many threaded conversations, some content may be missing.
13 REPLIES 13
Posted on February 01, 2018 at 16:52

Yes, Cube generates the following (for TIM2 in this case), in the OP case it would all be TIM1)

void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* tim_baseHandle)
{
 if(tim_baseHandle->Instance==TIM2)
 {
 /* USER CODE BEGIN TIM2_MspInit 0 */
 /* USER CODE END TIM2_MspInit 0 */
 /* TIM2 clock enable */
 __HAL_RCC_TIM2_CLK_ENABLE();
 /* TIM2 interrupt Init */
 HAL_NVIC_SetPriority(TIM2_IRQn, 0, 0);
 HAL_NVIC_EnableIRQ(TIM2_IRQn);
 /* USER CODE BEGIN TIM2_MspInit 1 */
 /* USER CODE END TIM2_MspInit 1 */
 }
}

Sorry for ugly code, but first pretty code version is stuck in stupid moderation!!!! Dumb!

and...

/******************************************************************************

* * The minimal vector table for a Cortex-M4. Note that the proper constructs * must be placed on this to ensure that it ends up at physical address * 0x0000.0000. * ******************************************************************************/ .section .isr_vector,'a',%progbits .type g_pfnVectors, %object .size g_pfnVectors, .-g_pfnVectors g_pfnVectors: .word _estack .word Reset_Handler .word NMI_Handler .word HardFault_Handler .word MemManage_Handler .word BusFault_Handler .word UsageFault_Handler ....

.word EXTI9_5_IRQHandler

.word TIM1_BRK_TIM15_IRQHandler .word TIM1_UP_TIM16_IRQHandler .word TIM1_TRG_COM_TIM17_IRQHandler .word TIM1_CC_IRQHandler .word TIM2_IRQHandler .word TIM3_IRQHandler .word TIM4_IRQHandler .word I2C1_EV_IRQHandler ....
Posted on February 01, 2018 at 16:58

No, I mean the source for the vector table, which is traditionally part of the startup code.

In other words, as in the template startup code (e.g. in [STM32Cube_FW_F4_V1.15.0]\Drivers\CMSIS\Device\ST\STM32F4xx\Source\Templates\) contain separate ISR names for the separate TIM1 interrupts (TIM1_UP_TIM10_IRQHandler for the update and TIM1_CC_IRQHandler for the CC), there must be some way how to redirect them into the 'unified' generated TIM1_IRQHandler - is this left to the user, or is there some generated code to do that?

Thanks,

JW

Posted on February 01, 2018 at 17:01

yes, please see the editted post, first got stuck in moderation, so i made crappy formatted version one bit at a time to avoid getting suck again!

Posted on February 01, 2018 at 17:11

That's for TIM2 and TIM2 has a single interrupt vector anyway, so TIM2_IRQHandler is exactly what you find in the template startup code.

For TIM1, there are separate interrupt vectors for various interrupt sources and thus there is no TIM1_IRQHandler in the template startup code.

Can you please try to generate the code for TIM1?

Thanks,

JW