cancel
Showing results for 
Search instead for 
Did you mean: 

how to configure flex pwm to give complementary pwm of 20 khz.

kjay
Associate II

.i need help with calculating clock and time peroid and waht is other pwm pin if pwm0 has d10 which is complemetary pin in spc56el70l5-disp

1 ACCEPTED SOLUTION

Accepted Solutions
zambrano.luigi
Senior III

Hi,

as already explained, when the synchronization is enabled, all the submodules are managed as a unique driver with 8 channels (ch0 = A0, ch1 = B0, ch2 = A1, ch3 = B1, ch4 = A2, ch5 = B2, ch6 = A3, ch7 = B3). So, if you want to enable the outputs A1 and B1, you have to activate in the PWM configuration the channels 2 and 3 (see Sync_Conf.JPG in attachment). In attachment you can find the modified version of your project in which I have enabled the channels A0, B0, A1 and B1 (in particular, I have configured B0 as the complementary of A0 and B1 as the complementary of A1). In the picture Sync_PWM_Waveforms.JPG you can see the output waveforms.

Best Regards,

Luigi

View solution in original post

82 REPLIES 82
zambrano.luigi
Senior III

Hi,

let me suggest you to download SPC5Studio from ST web site. It is a tool that allows you to easily configure our cores and generate specific applications for them. It also contains a lot of examples. Some of these are specific for the FlexPWM configuration. In attachment you can find an SPC5Studio project in which the FlexPWM0 of the core SPC56EL70L5 is configured to generate 2 complementary PWM signals with a duty cycle of 50% and a frequency of 20KHz, the PWMA0 on the pin D[10] and the PWMB0 on the pin D[11]. The project has been developed for the development board SPC56EL70L5DISP (Discovery Kit for the L Line.) , on which the pin D[10] is connected with the pin B23 on the external connector X6, and the pin D[11] is connected with the pin B3 on the external connector X6.

Best Regards,

Luigi

thank you so much .... i have doubt how to vary duty like 0-100.pwm_lld_enable_channel(&PWMD1, 0, PWM_PERCENTAGE_TO_WIDTH(&PWMD1, 5000)); here i change 5000 but it is not working total frequency u have is 80 Mhz and period of 400. is it like varying value 0-400 to percentage 0-100. that is also not working.

zambrano.luigi
Senior III

Hi, 

in the example that I provided you, the third parameter of the function pwm_lld_enable_channel is the duty cycle. The value PWM_PERCENTAGE_TO_WIDTH(&PWMD1, 5000) means you is setting a duty cycle of 50% of the whole PWM period. For example, if you change it to PWM_PERCENTAGE_TO_WIDTH(&PWMD1, 2500), you will have a duty cycle of 25% of the whole PWM period. The PWM period is obtained as number of ticks of the Clock Frequency (set to 80MHz in the project that I shared with you). In particular, a period of 400 ticks means the the PWM period is 400 / 80MHz = 5ms, i.e. the PWM frequency is 1 / 5ms = 20KHz. If you want to change the period, you can modify the Clock Frequency or you can modify the number of ticks. But, please, consider that the Clock Frequency is obtained by the Motor Control clock by dividing it for a prescaler, and the value of the prescaler can be 1, 2, 4, 8, 16, 32, 64 or 128. So, it is not possible to set any value for the Clock Frequency. In the project that I shared with you the Motor Control clock frequency is set to 80MHz and alsi the Clock Frequency is also set to 80MHz, so the prescaler is automatically configured to 1. 

Best Regards,

Luigi

kjay
Associate II

thank you ..you have been very helpful..

can you help me to get simple CAN transmission and reception using interrupts

with standard CAN in normal mode ..i find that example in spc studio difficult and hard to understand..

Hi,

the best way to proceed is a cross check between the FlexCAN low level driver included in SPC5Studio and the Reference Manual of the core. Then, if you will find a specific topic, please, feel free to contact us on the forum.

Best regards,

Luigi

kjay
Associate II

I want a simple CAN transmission of variable using standard mode can..please help..could you provide an example application

Hi,

have you given a look to the example SPC56ELxx_RLA CAN Test Application for DiscoveryPlus included in SPC5Studio? This should be aligned with your requirements because it simply uses the FlexCAN0 to send 3 messages in loopback. You can modify the sent message with your variable and everything should work fine.

Best Regards,

Luigi

kjay
Associate II

i have seen that i compiled and its working as it should be...in loop back mode ..i need example for configuring time quanta and transmitting in normal mode ...too many new functions in that i cannot able to send simple variable and recieve using interrupt ...can ID also confusing.... please help