2024-12-25 09:16 AM - last edited on 2024-12-26 12:27 AM by SofLit
Hi, I implemented and tested the example TIM_OCActive, which is included in the STM32Cube_FW_G0_V1.6.2 package, using a NUCLEO-G071RB and the STM32CubeIDE version 1.17.0.
As the trigger signal for the oscilloscope I generated a 10 ms wide pulse by adding lines 3 and 4 in the below code snippet.
Question: although the trigger pulse is written only to the TIM1 CH1 output (PA8), it appears for all four channels, as can be seen in the below oscilloscope screenshot. Please explain that. Thank you!
/* Generate pulse (set/reset) TIM1 CH1 output pin as trigger
* reference for the oscilloscope */
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_8, GPIO_PIN_SET);
HAL_Delay(10);
/*## Start signals generation ##*/
/* Start channel 1 in Output compare mode */
if(HAL_TIM_OC_Start(&htim1, TIM_CHANNEL_1) != HAL_OK)
{
/* Starting Error */
Error_Handler();
}
2024-12-26 12:18 AM
Do you see those pulses also if you remove the HAL_GPIO_WritePin() line, leaving just the delay?
JW
2024-12-26 07:19 AM - edited 2024-12-26 08:26 AM
edit: misunderstood what was being asked.
2024-12-28 07:22 AM - edited 2024-12-28 07:24 AM
Hello Jan, thank you for your response and question. I appreciate you taking the time for this.
The answer to your question is No., the pulses at channels 1-4 are not present without writing to PA8 (Ch1). Please see the three figures below for details.
Is there an answer to my original question why writing to PA8 (CH1) affects all four channels?
Figure 1. Timer 1 signals WITH the 10 ms pulse added only to CH1.
Figure 2. Timer 1 signals WITHOUT the 10 ms pulse (original example code).
Figure 3.
2024-12-30 07:17 AM
> The answer to your question is No., the pulses at channels 1-4 are not present without writing to PA8 (Ch1).
Third figure looks to me much like Yes.
All 4 pins are at that point already set as AF in their respective GPIO_MODER register, so setting GPIO output level for any of them does nothing.
What you see is consequence of pins being set up with pullup. The timer outputs are not enabled yet at that point (by TIMx_CCER.CCxE and, as TIM1 is an Adcanced timer, also by TIMx_BDTR.MOE) - that comes only when you call HAL_TIM_OC_Start().
JW