cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with generation PWM in Timer for STM32H750 (don't reach necessary frequency - 100 Mhz)

Ronil
Associate

STM32H740 Nucleo Kit board, Timer 1, Ch1 (PA8 output)

I used direct access to timer registers as a HAL library and the result was similar.

I can receive 10 MHz with direct access to register and   TIM1->PSC = 10;

But when  I set TIM1->PSC = 1 I don’t receive any signal from Timer1 with the next script 

 

"HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_1);

  RCC->APB2ENR |= RCC_APB2ENR_TIM1EN;

  TIM1->CR1 &= ~TIM_CR1_CEN;

  TIM1->PSC = 10;

  TIM1->ARR = 1;

  TIM1->CCMR1 &= ~TIM_CCMR1_OC1M;

  TIM1->CCMR1 |= TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1M_2;

  TIM1->CCMR1 |= TIM_CCMR1_OC1PE;

  TIM1->CCR1 = 1;

  TIM1->CCER |= TIM_CCER_CC1E;

  TIM1->CR1 |= TIM_CR1_ARPE;

  TIM1->BDTR |= TIM_BDTR_MOE;

  TIM1->CR1 |= TIM_CR1_CEN;

  RCC->AHB4ENR |= RCC_AHB4ENR_GPIOAEN;

  GPIOA->MODER &= ~GPIO_MODER_MODE8_Msk;  // Clear bits

  GPIOA->MODER |= GPIO_MODER_MODE8_1;     // Set to alternate function mode

  GPIOA->AFR[1] &= ~GPIO_AFRH_AFSEL8_Msk;  // Clear AF selection for PA8

  GPIOA->AFR[1] |= 1 << GPIO_AFRH_AFSEL8_Pos;  // Set AF1 for PA8

 

 

I also adjusted A8 for  RCC_MCO_1 and received finally 100 MHz, so I can confirm that my oscilloscope works properly. 

And I found here that is possible to make 100 MHz for the timer for STM32H7 via timer and PWM

my settings are here 

1.img_1.bmp2.img_2.bmp3.img_3.bmp

and the same problem for other Timers 

as example 

HAL_TIM_PWM_Start(&htim15, TIM_CHANNEL_2)

static void MX_TIM15_Init(void)

{

 

/* USER CODE BEGIN TIM15_Init 0 */

 

/* USER CODE END TIM15_Init 0 */

 

TIM_ClockConfigTypeDef sClockSourceConfig = {0};

TIM_MasterConfigTypeDef sMasterConfig = {0};

TIM_OC_InitTypeDef sConfigOC = {0};

TIM_BreakDeadTimeConfigTypeDef sBreakDeadTimeConfig = {0};

 

/* USER CODE BEGIN TIM15_Init 1 */

 

/* USER CODE END TIM15_Init 1 */

htim15.Instance = TIM15;

htim15.Init.Prescaler = 0;

htim15.Init.CounterMode = TIM_COUNTERMODE_UP;

htim15.Init.Period = 2;

htim15.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;

htim15.Init.RepetitionCounter = 0;

htim15.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;

if (HAL_TIM_Base_Init(&htim15) != HAL_OK)

{

Error_Handler();

}

sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;

if (HAL_TIM_ConfigClockSource(&htim15, &sClockSourceConfig) != HAL_OK)

{

Error_Handler();

}

if (HAL_TIM_PWM_Init(&htim15) != HAL_OK)

{

Error_Handler();

}

sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;

sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;

if (HAL_TIMEx_MasterConfigSynchronization(&htim15, &sMasterConfig) != HAL_OK)

{

Error_Handler();

}

sConfigOC.OCMode = TIM_OCMODE_PWM1;

sConfigOC.Pulse = 1;

sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;

sConfigOC.OCNPolarity = TIM_OCNPOLARITY_HIGH;

sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;

sConfigOC.OCIdleState = TIM_OCIDLESTATE_RESET;

sConfigOC.OCNIdleState = TIM_OCNIDLESTATE_RESET;

if (HAL_TIM_PWM_ConfigChannel(&htim15, &sConfigOC, TIM_CHANNEL_2) != HAL_OK)

{

Error_Handler();

}

sBreakDeadTimeConfig.OffStateRunMode = TIM_OSSR_DISABLE;

sBreakDeadTimeConfig.OffStateIDLEMode = TIM_OSSI_DISABLE;

sBreakDeadTimeConfig.LockLevel = TIM_LOCKLEVEL_OFF;

sBreakDeadTimeConfig.DeadTime = 0;

sBreakDeadTimeConfig.BreakState = TIM_BREAK_DISABLE;

sBreakDeadTimeConfig.BreakPolarity = TIM_BREAKPOLARITY_HIGH;

sBreakDeadTimeConfig.BreakFilter = 0;

sBreakDeadTimeConfig.AutomaticOutput = TIM_AUTOMATICOUTPUT_DISABLE;

if (HAL_TIMEx_ConfigBreakDeadTime(&htim15, &sBreakDeadTimeConfig) != HAL_OK)

{

Error_Handler();

}

/* USER CODE BEGIN TIM15_Init 2 */

 

/* USER CODE END TIM15_Init 2 */

HAL_TIM_MspPostInit(&htim15);

 

}

4.img_4.bmp

 

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

You can change it in the GPIO tab on the left.

TDK_0-1724764260830.png

 

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

5 REPLIES 5
TDK
Guru

Make sure pins are set to very high frequency. I bet the signal is there but with slow edges. What oscilloscope are you using?

If you feel a post has answered your question, please click "Accept as Solution".

Hello, thank you, I use PicoScope6404D (500 Mhz)

what do you mean about - "Make sure pins are set to very high frequency. " I use a timer and PWM and made only "Fast Mode" - Enable

I dont have access to GPIO via Cube 4.img_4.bmp

TDK
Guru

You can change it in the GPIO tab on the left.

TDK_0-1724764260830.png

 

If you feel a post has answered your question, please click "Accept as Solution".

ohhhh, it is works now, thank you so much, my god how did I miss this!!