Skip to main content
Visitor II
January 22, 2024
Solved

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

  • January 22, 2024
  • 4 replies
  • 2325 views

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);

}

 

    This topic has been closed for replies.
    Best answer by hguan

    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).

     

    4 replies

    hguanAuthor
    Visitor II
    January 22, 2024

    The micro-controller is STM32U575

    Super User
    January 22, 2024

    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.

    hguanAuthorAnswer
    Visitor II
    January 23, 2024

    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).

     

    Graduate II
    January 23, 2024

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

    hguanAuthor
    Visitor II
    January 23, 2024

    Thanks KMill,

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

    Regards

    Graduate II
    January 23, 2024

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

    Screenshot 2024-01-23 at 13.11.16.png

    hguanAuthor
    Visitor II
    January 23, 2024

    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.