cancel
Showing results for 
Search instead for 
Did you mean: 

How to put Delay or offset Between two PWM Pulse.

Bhavik
Associate III

Hello Members,

I am new to STM32 MCUs. I am trying to generate PWM and try to modify on fly and it works. But my requirement is to have a delay between two pulse on time and it should not align to each other on any edge. Please see the photo to understand the expected output.

So requirement is, How to put Delay or offset Between two or multiple PWM Pulse?

0693W00000JQD45QAH.jpg 

MCU: STM32L476

STM32CubeIDE 1.8.0

Thanks

Bhavik

1 ACCEPTED SOLUTION

Accepted Solutions
KnarfB
Principal III

The most flexible way is to use combined PWM mode available on some timers. You need 2 timer channels per PWM. This allows you to set the offset for each of the 4 edges indivually. With CubeMX like:

0693W00000JQDMDQA5.pnghth

KnarfB

View solution in original post

5 REPLIES 5

Read Combined PWM mode subchapter of TIM chapter.

You can't do this with any arbitrary channel, though.

JW

KnarfB
Principal III

The most flexible way is to use combined PWM mode available on some timers. You need 2 timer channels per PWM. This allows you to set the offset for each of the 4 edges indivually. With CubeMX like:

0693W00000JQDMDQA5.pnghth

KnarfB

@KnarfB​ Thanks for quick reply I tried the mentioned setting but It wont work.

As mentioned I am using STM32L476RG Nucleo Board for testing. Any Clue?

I'm using Nulceo-STM32L432KC here, should be quite similar.

Did you start the PWM channels in the code:

  HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_1 );
  HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_2 );
  HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_3 );
  HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_4 );

hth

KnarfB

@KnarfB​ I am doing that. But They pulse value calculation I am not doing correctly so it is not working.

I come to know how to do it and I am able to do it.

See the photo.

0693W00000KZe22QAD.jpg 

Thanks for your input.

Soon Will post my answer with all the details so it may useful to others.