AnsweredAssumed Answered

TIM_ParallelSynchro on stm32f103xx not work

Question asked by Ariel Rivera on Mar 25, 2018
Latest reply on Mar 25, 2018 by Jan Waclawek

I have implemented on stm32f103xx the example TIM_ParallelSynchro, this not work. For stm32f407xx fine work.

 

 

int main(void)

{
HAL_Init();
SystemClock_Config();
InitConfigTIM3_Master(); 
InitConfigTIM2_Slave();

while (1)
{

}
}

 

static void InitConfigTIM2_Slave(void)
{
TIM_OC_InitTypeDef sOCConfig;
TIM_SlaveConfigTypeDef sSlaveConfig;

hTIM2.Instance = TIM2;

hTIM2.Init.Period = 9;
hTIM2.Init.Prescaler = 0;
hTIM2.Init.ClockDivision = 0;
hTIM2.Init.CounterMode = TIM_COUNTERMODE_UP;
hTIM2.Init.RepetitionCounter = 0;
HAL_TIM_Base_Init(&hTIM2);
HAL_TIM_PWM_Init(&hTIM2);

 

sOCConfig.OCMode = TIM_OCMODE_PWM1;
sOCConfig.OCPolarity = TIM_OCPOLARITY_HIGH;
sOCConfig.Pulse = 3;
HAL_TIM_PWM_ConfigChannel(&hTIM2, &sOCConfig, TIM_CHANNEL_3);


sSlaveConfig.SlaveMode = TIM_SLAVEMODE_GATED;
sSlaveConfig.InputTrigger = TIM_TS_ITR2; // for TIM3 master
HAL_TIM_SlaveConfigSynchronization(&hTIM2, &sSlaveConfig);

 

HAL_TIM_MspPost_Init(&hTIM2);

HAL_TIM_PWM_Start_IT(&hTIM2, TIM_CHANNEL_3);
}

 

static void InitConfigTIM3_Master(void)
{
TIM_MasterConfigTypeDef sMasterConfig;
TIM_OC_InitTypeDef sOCConfig;

 

hTIM3.Instance = TIM3;
hTIM3.Init.Period = 3600-1;
hTIM3.Init.Prescaler = 0;
hTIM3.Init.ClockDivision = 0;
hTIM3.Init.CounterMode = TIM_COUNTERMODE_UP;
hTIM3.Init.RepetitionCounter = 0;
HAL_TIM_Base_Init(&hTIM3);
HAL_TIM_PWM_Init(&hTIM3) ;

 

sOCConfig.OCMode = TIM_OCMODE_PWM1;
sOCConfig.OCPolarity = TIM_OCPOLARITY_HIGH;
sOCConfig.Pulse = 1800;
HAL_TIM_PWM_ConfigChannel(&hTIM3, &sOCConfig, TIM_CHANNEL_2) ;

 

sMasterConfig.MasterOutputTrigger = TIM_TRGO_UPDATE;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_ENABLE;
HAL_TIMEx_MasterConfigSynchronization(&hTIM3,&sMasterConfig) ;

 

HAL_TIM_MspPost_Init(&hTIM3);

 

HAL_TIM_Base_Start_IT(&hTIM3);
HAL_TIM_PWM_Start_IT(&hTIM3, TIM_CHANNEL_2);
}

Outcomes