Skip to main content
kjay
Associate III
July 1, 2019
Solved

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

  • July 1, 2019
  • 59 replies
  • 27260 views

.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

    This topic has been closed for replies.
    Best answer by zambrano.luigi

    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

    59 replies

    kjay
    kjayAuthor
    Associate III
    September 14, 2019

    hi,

    i have to capture duty cycle of the pwm which has 85 to 115khz frequency..can u provide me example of configuring and efficient capture of duty cycle..i need to be accurate because it contains sensor diagnostics information as duty cycle.thank you

    zambrano.luigi
    ST Employee
    September 16, 2019

    Hi,

    the input capture functionality in the SPC56EL is based on the eTImer module. Since the eTImer module is based on 16bit counters, the maximum frequency measured by the ICU driver (without overflow) is

    2^16 * (ICU low level driver Frequency).

    ICU low level driver frequency is the frequency setting within the ICU low level driver component. This frequency must sadisfy the following formula

    ICU low level driver Frequency = Motor Control Clock Frequency / eTimer Prescaler

    where the eTimer Prescaler can be equal to 1, 2, 4, 8, 16, 32, 64 or 128.

    So, if you know the maxim frequency that you want to measure, you can select the ICU low level driver frequency and the Motor Control Clock frequency in order to have a right value for the eTimer Prescaler.

    Regards,

    Luigi

    zambrano.luigi
    ST Employee
    September 16, 2019

    Hi,

    if you open the Pin Map Wizard (graphic pin editor, please, see picture in attachment) to edit the pins, you cannot use the standard edit view till you don't close the Pin Map Wizard. In other words, there is only one active edit view at a time, the standard view or the Pin Map Wizard.

    Best Regards,

    Luigi

    kjay
    kjayAuthor
    Associate III
    September 16, 2019

    THANKS I NEED TO CLARIFY another thing to activate complementary on pwm A0 and B0 we use

     pwm_lld_start(&PWMD1, &pwm_config_pwmcfg);

    and

    pwm_lld_enable_channel(&PWMD1, 0, PWM_PERCENTAGE_TO_WIDTH(&PWMD1,5000));

    and to activate same frquency complemetary on A1 and B1 what should i update on the coding....

    pwm_lld_enable_channel(&PWMD1, 1, PWM_PERCENTAGE_TO_WIDTH(&PWMD1,5000));

    adding above line is enough or not............cause it has pwmd1 and channel 1...if i add this it is not working

    zambrano.luigi
    ST Employee
    September 16, 2019

    Hi,

    if you open the Pin Map Wizard (graphic pin editor, please, see picture in attachment) to edit the pins, you cannot use the standard edit view till you don't close the Pin Map Wizard. In other words, there is only one active edit view at a time, the standard view or the Pin Map Wizard.

    Best Regards,

    Luigi

    zambrano.luigi
    ST Employee
    September 16, 2019

    Hi,

    if the option Synchronized FlexPWM1 is disabled, each PWM driver manages a FlexPWM submodule with 2 channels (A and B). So, A0 and B0 are the channel 0 and channel 1 of the PWMD1, while A1 and B1 are the channel 0 and the channel 1 of the PWMD2. So, A0 and B0 are activated by the following instructions

    pwm_lld_enable_channel(&PWMD1, 0, ...

    pwm_lld_enable_channel(&PWMD1, 1, ...

    while A1 and B1 are activated by following instructions

    pwm_lld_enable_channel(&PWMD2, 0, ...

    pwm_lld_enable_channel(&PWMD2, 1, ...

    Otherwise, if the option Synchronized FlexPWM1 is enabled, or the 4 submodules of the FlexPWM0 are synchronized. In this case the whole FlexPWM0 is managed by a unique driver (PWMD1) with 8 channels (A0 = 0, B0 = 1, A1 = 2, B1 = 3, A2 = 4, B2 = 5, A3 = 6 and B3 = 7). So, A0 and B0 are activated by the following instructions:

    pwm_lld_enable_channel(&PWMD1, 0, ...

    pwm_lld_enable_channel(&PWMD1, 1, ...

    while A1 and B1 are activated by following instructions

    pwm_lld_enable_channel(&PWMD1, 2, ...

    pwm_lld_enable_channel(&PWMD1, 3, ...

    Best Regards,

    Luigi

    kjay
    kjayAuthor
    Associate III
    September 17, 2019

    thanks for the answer ...i have issue...ii have to use 2 chip select pins for DSPI0...i havegot result using single chipselect...how can i use another cs...i have to switch between cs0 and cs1 for 2 sensor inside the program..can you give me an example..

    zambrano.luigi
    ST Employee
    September 17, 2019

    Hi,

    if you enable the synchronization, you have also to update the PWM cofiguration (pwmcfg), enabling within the configuration all the needed channels. In particular, when the synchronization is enable, the PWM driver configuration allows to enable 8 channels and not only 2.

    Best Regards,

    Luigi

    kjay
    kjayAuthor
    Associate III
    September 18, 2019

    could you please elaborate and give me example..please answer my dspi question..

    kjay
    kjayAuthor
    Associate III
    September 20, 2019

    i have issue...ii have to use 2 chip select pins for DSPI0...i havegot result using single chipselect...how can i use another cs...i have to switch between cs0 and cs1 for 2 sensor inside the program..can you give me an example..

    zambrano.luigi
    ST Employee
    September 24, 2019

    Hi,

    sorry for the delay. Your usage case is the typical case with one master and two slaves. In order to manage it:

    1. in the board component configure 2 chip selects for the master (for example, CS0 and CS1) and connect CS0 with the CS of the first slave and CS1 to the CS of the second slave
    2. in the DSPI settings define 2 different configurations, one with PCS Line to PCS0 and another with PCS Line to PCS1. Then, if the first configuration is loaded (with the function spi_lld_start), the master will be able to communicate only with the first slave. If the second configuration is loaded, the master will be able to communicate only with the second slave. If you want to switch between the first and the second slave, you have to unload the previous configuration (with the function spi_lld_stop) and load the new one (with the function spi_lld_start).

    Best regards,

    Luigi

    kjay
    kjayAuthor
    Associate III
    October 18, 2019

    is there any plug in or extension that i can use for MISRA C standrad checking in SPC5studio...if answer is no ..can you suggest how to check my code compatibility with MISRA C standard which is originally written in SPC5 studio from your experience..\thank you..

    zambrano.luigi
    ST Employee
    October 18, 2019

    Hi,

    SPC5Studio allows to run a MISRA check on an SPC5Studio project if you have installed in your PC a specific tool, called PClint. In that case, it is possible to add the path of the tool within SPC5Studio and run the tool directly from SPC5Studio on a specific SPC5Studio project. Please, consider that most of the code within SPC5Studio is MISRA compliant.

    Regards,

    Luigi