cancel
Showing results for 
Search instead for 
Did you mean: 

How to SYNC PWM?

PChia.2237
Senior

Hello,

i have now this working code on SPC560P without sync flag.

	   pwm_lld_start(&PWMD1, &pwm_config_pwm_cfg0);
	   pwm_lld_start(&PWMD2, &pwm_config_pwm_cfg0);
	   pwm_lld_start(&PWMD3, &pwm_config_pwm_cfg0);
	   pwm_lld_start(&PWMD4, &pwm_config_pwm_cfg0);
	   pwm_lld_enable_channel(&PWMD1, 0, PWM_PERCENTAGE_TO_WIDTH(&PWMD1, 5000));
	   pwm_lld_enable_channel(&PWMD2, 0, PWM_PERCENTAGE_TO_WIDTH(&PWMD2, 5000));
 
	   pwm_lld_enable_channel(&PWMD1, 1, PWM_PERCENTAGE_TO_WIDTH(&PWMD1, 5000));
          pwm_lld_enable_channel(&PWMD2, 1, PWM_PERCENTAGE_TO_WIDTH(&PWMD2, 5000));
	   pwm_lld_enable_channel(&PWMD3, 0, PWM_PERCENTAGE_TO_WIDTH(&PWMD3, 5000));
	   pwm_lld_enable_channel(&PWMD3, 1, PWM_PERCENTAGE_TO_WIDTH(&PWMD3, 5000));
	   pwm_lld_enable_channel(&PWMD4, 0, PWM_PERCENTAGE_TO_WIDTH(&PWMD3, 5000));

But of course output is not in phase (syncronized).

If i enable flag "Synchronized FlexPWM0" and i use this code :

	   pwm_lld_start(&PWMD1, &pwm_config_pwm_cfg0);
	   pwm_lld_enable_channel(&PWMD1, 0, PWM_PERCENTAGE_TO_WIDTH(&PWMD1, 5000));
  	   pwm_lld_enable_channel(&PWMD1, 1, PWM_PERCENTAGE_TO_WIDTH(&PWMD1, 5000));
 
	   pwm_lld_enable_channel(&PWMD1, 2, PWM_PERCENTAGE_TO_WIDTH(&PWMD1, 5000));
  	   pwm_lld_enable_channel(&PWMD1, 3, PWM_PERCENTAGE_TO_WIDTH(&PWMD1, 5000));
 
	   pwm_lld_enable_channel(&PWMD1, 4, PWM_PERCENTAGE_TO_WIDTH(&PWMD1, 5000));
  	   pwm_lld_enable_channel(&PWMD1, 5, PWM_PERCENTAGE_TO_WIDTH(&PWMD1, 5000));
 
	   pwm_lld_enable_channel(&PWMD1, 6, PWM_PERCENTAGE_TO_WIDTH(&PWMD1, 5000));
  	   pwm_lld_enable_channel(&PWMD1, 7, PWM_PERCENTAGE_TO_WIDTH(&PWMD1, 5000));

Only CH0 and CH1 output is working in phased.

No output on CH2,CH3,CH4,CH5,CH6,CH7.

What i have to do?

Thank you in advantages

10 REPLIES 10

Hi,

I mean my problem now is when i press the button, led ON only one time, after i press again the button, the led does not ON anymore. I mean like the led only trigger one time after press the button and it permanently OFF. So, how can i enable to make the led ON every time i press the button, i want the duty cycle 50% and period 5s?