How to change PWM Alignment during run time?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
AyKo_4382201
Level 2
Level 2
10 replies posted 5 replies posted 5 questions asked

Hi,

I'm using CYBLE-416045-02 mcu and want to change PWM Alignment during run time.

Please Help.

Thanks

0 Likes
1 Solution
Len_CONSULTRON
Level 9
Level 9
Beta tester 500 solutions authored 1000 replies posted

AyKo,

If you allocated the PWM at the HAL-level, then you can make a call to cyhal_pwm_init_adv() (Hardware Abstraction Layer (HAL) )  In this call, there is a parameter for alignment.

You will probably have to perform a cyhal_pwm_free() first to have the halmgr free up the resources on the previously allocated PWM resource.

If you allocated the PWM at the PDL-level, I believe you need to perform the following steps:

  1. Cy_TCPWM_PWM_Disable();
  2. Cy_TCPWM_PWM_DeInit();
  3. change the .pwmAlignment varaible in the cy_stc_tcpwm_pwm_config_t  to the alignment type you want.
  4. Cy_TCPWM_PWM_Init();
  5. Cy_TCPWM_PWM_Enable();

Len

Len
"Engineering is an Art. The Art of Compromise."

View solution in original post

0 Likes
1 Reply
Len_CONSULTRON
Level 9
Level 9
Beta tester 500 solutions authored 1000 replies posted

AyKo,

If you allocated the PWM at the HAL-level, then you can make a call to cyhal_pwm_init_adv() (Hardware Abstraction Layer (HAL) )  In this call, there is a parameter for alignment.

You will probably have to perform a cyhal_pwm_free() first to have the halmgr free up the resources on the previously allocated PWM resource.

If you allocated the PWM at the PDL-level, I believe you need to perform the following steps:

  1. Cy_TCPWM_PWM_Disable();
  2. Cy_TCPWM_PWM_DeInit();
  3. change the .pwmAlignment varaible in the cy_stc_tcpwm_pwm_config_t  to the alignment type you want.
  4. Cy_TCPWM_PWM_Init();
  5. Cy_TCPWM_PWM_Enable();

Len

Len
"Engineering is an Art. The Art of Compromise."
0 Likes