cancel
Showing results for 
Search instead for 
Did you mean: 

Timer output influenced by other timer

Tomas Hamouz
Associate III

Hi everybody,

I have TIM15, configured to PWM generation, in one shot configuration, using OC1N output. The output is set to 0 and timer disabled.. 

When I later initialize TIM1, the output of TIM15 goes high at the instant the Update event is generated. I noticed it depend on Fast mode setting - if not set, the output remains low. The Fast mode is required/recommended in One Pulse configuration.

How is it possible to change anything in other timer instance?

Sample code below.

Tomas

 

//-----------------------------------------------------------------------------
void TIM15_TIM1_Test(void)
//-----------------------------------------------------------------------------
{
    // TIM15 init
    LL_TIM_InitTypeDef      TIM_InitStruct;
    TIM_InitStruct.Prescaler = 383; //
    TIM_InitStruct.CounterMode = LL_TIM_COUNTERMODE_UP;
    TIM_InitStruct.Autoreload = 100;
    TIM_InitStruct.ClockDivision = LL_TIM_CLOCKDIVISION_DIV1;
    TIM_InitStruct.RepetitionCounter = 0;
    LL_TIM_Init(TIM15, &TIM_InitStruct);

    // output channel setup
    LL_TIM_OC_InitTypeDef   TIM_OC_InitStruct;
    TIM_OC_InitStruct.OCMode = LL_TIM_OCMODE_PWM1;
    TIM_OC_InitStruct.OCState = LL_TIM_OCSTATE_DISABLE;
    TIM_OC_InitStruct.OCNState = LL_TIM_OCSTATE_ENABLE;
    TIM_OC_InitStruct.CompareValue = 50;
    TIM_OC_InitStruct.OCPolarity = LL_TIM_OCPOLARITY_LOW;
    TIM_OC_InitStruct.OCNPolarity = LL_TIM_OCPOLARITY_LOW;
    TIM_OC_InitStruct.OCIdleState = LL_TIM_OCIDLESTATE_LOW;
    TIM_OC_InitStruct.OCNIdleState = LL_TIM_OCIDLESTATE_LOW;
    LL_TIM_OC_Init(TIM15, LL_TIM_CHANNEL_CH1, &TIM_OC_InitStruct);

    LL_TIM_SetOffStates(TIM15, LL_TIM_OSSI_ENABLE, LL_TIM_OSSR_ENABLE);
    // here sits the devil - if I omit the Fast mode, it works fine
    LL_TIM_OC_EnableFast(TIM15, LL_TIM_CHANNEL_CH1);
    LL_TIM_EnableAllOutputs(TIM15);

    LL_TIM_GenerateEvent_UPDATE(TIM15);
    LL_TIM_EnableCounter(TIM15);    // needed to set the output to 0

    // connect pin to timer
    LL_GPIO_InitTypeDef GPIO_InitStruct;
    GPIO_InitStruct.Pin = BEEPER_PIN;
    GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
    GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW;
    GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
    GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
    GPIO_InitStruct.Alternate = BEEPER_AF;
    LL_GPIO_Init(BEEPER_PORT, &GPIO_InitStruct);

    LL_TIM_DisableCounter(TIM15);             // to be started later

    // TIM1 init
    LL_TIM_InitTypeDef TIM_InitStruct;
    TIM_InitStruct.Prescaler = 0;
    TIM_InitStruct.CounterMode = LL_TIM_COUNTERMODE_UP;
    TIM_InitStruct.Autoreload = 959;
    TIM_InitStruct.ClockDivision = LL_TIM_CLOCKDIVISION_DIV1;
    TIM_InitStruct.RepetitionCounter = 0;
    // in this call the output TIM15/OC1N goes high
    // at the instant of UpdateEvent generation   
    LL_TIM_Init(TIM1, &TIM_InitStruct);
}

 

 

 

0 REPLIES 0