cancel
Showing results for 
Search instead for 
Did you mean: 

CH_1N is missing when configure TIM17 to generate CH_1 and CH_1N simultaneously

hguan
Associate III

Hi,

I configured the TIM17 as "Output Compare CH1 CH1N" with "Toggle on Match mode". The CH1 signal is correct but there is no CH1N output at all. The source codes are listed below. Any comment? Thanks.

The initialization call:

if(HAL_TIM_OC_Start_IT(&htim17, TIM_CHANNEL_1) != HAL_OK)

{

Error_Handler();

}

and the Init function:

static void MX_TIM17_Init(void)

{

TIM_OC_InitTypeDef sConfigOC = {0};

TIM_BreakDeadTimeConfigTypeDef sBreakDeadTimeConfig = {0};

 

htim17.Instance = TIM17;

htim17.Init.Prescaler = 1;

htim17.Init.CounterMode = TIM_COUNTERMODE_UP;

htim17.Init.Period = Beacon_TIM17_Period_value;

htim17.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;

htim17.Init.RepetitionCounter = 0;

htim17.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;

if (HAL_TIM_Base_Init(&htim17) != HAL_OK)

{

Error_Handler();

}

if (HAL_TIM_OC_Init(&htim17) != HAL_OK)

{

Error_Handler();

}

sConfigOC.OCMode = TIM_OCMODE_TOGGLE;

sConfigOC.Pulse = 0;

sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;

sConfigOC.OCNPolarity = TIM_OCNPOLARITY_LOW;

sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;

sConfigOC.OCIdleState = TIM_OCIDLESTATE_RESET;

sConfigOC.OCNIdleState = TIM_OCNIDLESTATE_RESET;

if (HAL_TIM_OC_ConfigChannel(&htim17, &sConfigOC, TIM_CHANNEL_1) != 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(&htim17, &sBreakDeadTimeConfig) != HAL_OK)

{

Error_Handler();

}

/* USER CODE BEGIN TIM17_Init 2 */

 

/* USER CODE END TIM17_Init 2 */

HAL_TIM_MspPostInit(&htim17);

}

 

1 ACCEPTED SOLUTION

Accepted Solutions
hguan
Associate III

Thanks TDK.

Yes, I missed the function call of HAL_TIMEx_PWMN_Start. After using the function, the CH1N output appeared on PB7.

 

I encountered another issue. The PB7 output is only about 2.3V, at the same time, the PB9 output is near3.3V.

What I expect the pair of output signals should be perfectly balanced and inverse to each other in order to drive a beacon piezo.

There are no loads connected to the two pins but the CH1N output seems quite different to CH1.PB7 and PB9 are all configured the same way (Push pull, Low speed and fast mode disable).

 

View solution in original post

7 REPLIES 7
hguan
Associate III

The micro-controller is STM32U575

TDK
Guru

The PWMN signal must be started with HAL_TIMEx_PWMN_Start. I don't see that in your code anywhere, are you calling it?

> CH1N output

At least I think you're expecting a PWM output based on this. If not, please explain what output you're expecting. There is only a single timer 1 channel register.

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

Thanks TDK.

Yes, I missed the function call of HAL_TIMEx_PWMN_Start. After using the function, the CH1N output appeared on PB7.

 

I encountered another issue. The PB7 output is only about 2.3V, at the same time, the PB9 output is near3.3V.

What I expect the pair of output signals should be perfectly balanced and inverse to each other in order to drive a beacon piezo.

There are no loads connected to the two pins but the CH1N output seems quite different to CH1.PB7 and PB9 are all configured the same way (Push pull, Low speed and fast mode disable).

 

This sounds like a h/w design issue. What loads do you have attached to output pin?

hguan
Associate III

Thanks KMill,

They are open states right now. No load has been attached to these pins except the probe.

Regards

hguan
Associate III

Hi KMill,

Agree with you. It is a hardware design issue. By checking the schematics, the PB7 in fact is connected to a resistor. Will start a new revision of the schematics shortly.

Appreciate your help.

 

Double check the settings for PWR Mode in the MX configurator (the IOC file).

Screenshot 2024-01-23 at 13.11.16.png