cancel
Showing results for 
Search instead for 
Did you mean: 

Tim1 and Tim2 block each other.

atürk.1
Associate

Hello stm community,

I am working with the STM8S001J3 processor on the ST Visual Develop Toolchain.

And I use the TIM1 and the TIM2.

The Tim1 is enabled via the external port when the D port is active. It is used to work synchronously with the 50hz/230v side to switch on the system in the 0 pass. The Tim2 should simply give a pulse out of a port when it is turned on. But somehow they block each other. The configuration etc. I think that everything is correct.

If the code is not enough, then I send more lines- Thx (:

Here is the config in the main:

void TIM2_setup(void)

{

   TIM2_DeInit();

   TIM2_TimeBaseInit(TIM2_PRESCALER_16, 5);

   TIM2_ITConfig(TIM2_IT_UPDATE, ENABLE);

void TIM1_Testsetup(void)

{

           TIM1_DeInit();

           TIM1_TimeBaseInit(160-1, TIM1_COUNTERMODE_UP, 400 ,0); //984 

           TIM1_ITConfig(TIM1_IT_UPDATE, ENABLE);

}

Here is the code for the INTERRUPT_HANDLER

INTERRUPT_HANDLER(EXTI_PORTD_IRQHandler, 6)

{

                       if(GPIO_ReadInputPin(GPIOD , GPIO_PIN_6))

                       {

                       TIM1_Cmd(ENABLE);

                     }

}

 INTERRUPT_HANDLER(TIM1_UPD_OVF_TRG_BRK_IRQHandler, 11)

{

                       if(!GPIO_ReadInputPin(GPIOB , GPIO_PIN_4))

                       {

                                   TIM2_Cmd(ENABLE);

                                   GPIO_WriteReverse(GPIOA, GPIO_PIN_3);

                       }

                                   if(GPIO_ReadInputPin(GPIOB , GPIO_PIN_4))

                                   {

                                   GPIO_WriteLow(GPIOA, GPIO_PIN_3);

                                   }

                                   TIM1_ClearFlag(TIM1_FLAG_UPDATE);

                                 TIM1_SetCounter (0);

                                   TIM1_Cmd(DISABLE);

 }

0 REPLIES 0