output compare channel problems
Hello everyone,
I want to use timer output compare channels as internal timebase (no output pins used). I did generate the following code by CubeMx/* TIM3 init function */
static void MX_TIM3_Init(void){TIM_ClockConfigTypeDef sClockSourceConfig;
TIM_MasterConfigTypeDef sMasterConfig; TIM_OC_InitTypeDef sConfigOC;htim3.Instance = TIM3;
htim3.Init.Prescaler = 0; htim3.Init.CounterMode = TIM_COUNTERMODE_UP; htim3.Init.Period = 65535; htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; if (HAL_TIM_Base_Init(&htim3) != HAL_OK) { Error_Handler(); }sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
if (HAL_TIM_ConfigClockSource(&htim3, &sClockSourceConfig) != HAL_OK) { Error_Handler(); }if (HAL_TIM_OC_Init(&htim3) != HAL_OK)
{ Error_Handler(); }sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; if (HAL_TIMEx_MasterConfigSynchronization(&htim3, &sMasterConfig) != HAL_OK) { Error_Handler(); }sConfigOC.OCMode = TIM_OCMODE_TIMING;
sConfigOC.Pulse = 0x1000; sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH; sConfigOC.OCFastMode = TIM_OCFAST_DISABLE; if (HAL_TIM_OC_ConfigChannel(&htim3, &sConfigOC, TIM_CHANNEL_1) != HAL_OK) { Error_Handler(); }sConfigOC.Pulse = 0x10000;
if (HAL_TIM_OC_ConfigChannel(&htim3, &sConfigOC, TIM_CHANNEL_2) != HAL_OK) { Error_Handler(); }}
I am starting the channels with
HAL_TIM_OC_Start_IT(&htim3, TIM_CHANNEL_1);
HAL_TIM_OC_Start_IT(&htim3, TIM_CHANNEL_2);I am also having an ISR for the Timer events
void HAL_TIM_OC_DelayElapsedCallback(TIM_HandleTypeDef *htim){ if(htim->Channel == HAL_TIM_ACTIVE_CHANNEL_1) { XXX += 1; } else if(htim->Channel == HAL_TIM_ACTIVE_CHANNEL_2) { YYY += 1; }}Now I am having the following behavior:I see the XXX and YYY counters are incremented but with the same speed. The incrementation is only depending on the 'htim3.Init.Period' the 'sConfigOC.Pulse' configuration is not used at all. Might that be a bug in CubeMx? I am using CubeMx Version 4.18
Any help would be very appreciated
Matthias
