diff --git a/src/platform/stm32/platform.c b/src/platform/stm32/platform.c index f531cc3e..c968a70b 100755 --- a/src/platform/stm32/platform.c +++ b/src/platform/stm32/platform.c @@ -839,6 +839,9 @@ int platform_s_timer_set_match_int( unsigned id, u32 period_us, int type ) TIM_OCInitStructure.TIM_Pulse = final; TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High; TIM_OC1Init( base, &TIM_OCInitStructure ); + + // Patch timer configuration to reload when period is reached + TIM_SetAutoreload( base, final ); TIM_OC1PreloadConfig( base, TIM_OCPreload_Enable ); @@ -846,7 +849,7 @@ int platform_s_timer_set_match_int( unsigned id, u32 period_us, int type ) TIM_SetCounter( base, 0 ); TIM_Cmd( base, ENABLE ); - TIM_ITConfig( base, TIM_IT_CC1, ENABLE ); + //TIM_ITConfig( base, TIM_IT_CC1, ENABLE ); return PLATFORM_TIMER_INT_OK; } diff --git a/src/platform/stm32/platform_int.c b/src/platform/stm32/platform_int.c index e9777eba..30771125 100644 --- a/src/platform/stm32/platform_int.c +++ b/src/platform/stm32/platform_int.c @@ -145,12 +145,14 @@ static void tmr_int_handler( int id ) if (TIM_GetITStatus( base, TIM_IT_CC1) != RESET) { TIM_ClearITPendingBit( base, TIM_IT_CC1 ); + if( id == VTMR_TIMER_ID ) cmn_virtual_timer_cb(); else cmn_int_handler( INT_TMR_MATCH, id ); - if( stm32_timer_int_periodic_flag[ id ] != PLATFORM_TIMER_INT_CYCLIC ); - //TIM_ITConfig( base, TIM_IT_CC1, DISABLE ); + + if( stm32_timer_int_periodic_flag[ id ] != PLATFORM_TIMER_INT_CYCLIC ) + TIM_ITConfig( base, TIM_IT_CC1, DISABLE ); } }