cancel
Showing results for 
Search instead for 
Did you mean: 

Odd Behavior of TIM2 PWM Output on STM32U073

muratsimsek
Associate

In a system using FreeRTOS, there are currently two timers: TIM6 (the timer used by FreeRTOS) and TIM3 (a general-purpose timer). I am not experiencing any issues with these timers, and I can successfully run functions like interrupts. However, whenever I try to generate a PWM output using TIM7, I have not been able to achieve it.

Here is the main code.

muratsimsek_0-1732537382675.png

 

 

int main(void)
{

  /* USER CODE BEGIN 1 */

  /* USER CODE END 1 */

  /* MCU Configuration--------------------------------------------------------*/

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();

  /* USER CODE BEGIN Init */

  /* USER CODE END Init */

  /* Configure the system clock */
  SystemClock_Config();

  /* USER CODE BEGIN SysInit */

  /* USER CODE END SysInit */

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_ADC1_Init();
  MX_CRC_Init();
  MX_DAC1_Init();
  MX_TIM3_Init();
  MX_USART2_UART_Init();
  MX_TIM2_Init();
  /* USER CODE BEGIN 2 */
  HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_1); <---- STARTING PWM
  /* USER CODE END 2 */

  /* Init scheduler */
  osKernelInitialize();

  /* Call init function for freertos objects (in cmsis_os2.c) */
  MX_FREERTOS_Init();

  /* Start scheduler */
  osKernelStart();

  /* We should never get here as control is now taken by the scheduler */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */
  }
  /* USER CODE END 3 */
}

 

 

 

2 REPLIES 2
SofLit
ST Employee

Hello,


@muratsimsek wrote:

However, whenever I try to generate a PWM output using TIM7, I have not been able to achieve it.


But in the code, nothing about TIM7 but only TIM2:

  MX_TIM2_Init();
  /* USER CODE BEGIN 2 */
  HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_1); <---- STARTING PWM

 

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
SofLit
ST Employee

And your title: "Odd Behavior of TIM2 PWM Output on STM32U073" -> confusing information!

Need to clarify and fix.

Thanks

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.