This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

RTOS/TM4C129ENCPDT: TM4C129ENCPDT PWM

Part Number: TM4C129ENCPDT


Tool/software: TI-RTOS

 We work with CCS 7.2.13 and board TM4C129ENCPDT.

Is it possible to configure two PWM with different period simultaneously?

uint16_t pwmPeriod0 = 3000;
uint16_t pwmPeriod1 = 10000;

PWM_Params_init(&params);
params.period = pwmPeriod0;
pwm0 = PWM_open(Board_PWM0, &params);

params.period = pwmPeriod1;
pwm1 = PWM_open(Board_PWM1, &params);

while (1) {
PWM_setDuty(pwm0, duty0);  duty0= (duty0+ dutyInc);

PWM_setDuty(pwm1, duty1);duty1= (duty1+ dutyInc);
}

Task_sleep((UInt) arg0);

}

Thanks,Sabina

 

 

 

  • Hello Sabina,

    It looks like you are wanting to use two separate PWM channels generators, yes? If so, that should be no problem as far as output goes. The 'configuration' would not be simultaneous, but the output would be.

    If you are having issues with this, please elaborate further on what you are/are not seeing (only one channel active, neither channel active, etc.) and also if you have success with getting a single channel running and that it is trying to add the second which is causing you issues.

    Edited on 9/14 to clarify points raised by cb1 on below discussion.

  • May I respectfully disagree?     Do note the poster's request:

    Sabina Greenberg101872 said:
    Is it possible to configure two PWM with different period simultaneously?

    To me - her desire for "simultaneous" configuration cannot be achieved!      Review of poster's code shows (normal) "sequential" code execution - which does not register as "simultaneous!"  

    Now it may be that "what was meant" was, "Can two PWM channels - each operating @ different periods - be realized (achieved)?"    And that answer is, "Yes" - but w/the proviso that these channels are not contained w/in the (same) PWM Generator!     (the 2 channels w/in any PWM Generator must "share" their period - but (may) operate @ different Duty Cycles)

    Posters so often (too often) make requests - yet fail to justify their motivation.     Poster's word, "simultaneously" forces a precision upon the answer - which I believe has been "missed!"   (thus the award of "Verify" proves "misleading" to future readers - and should be remedied...)      Again - one cannot (simultaneously) configure two PWM channels!    Unstated is, "Why such (lowly) configuration "alignment" - is of (any) interest?"

    It is noted that poster has awarded a "Verify" to herself - as well - which is "outside the intent" of such "Verified Answer!"    If we are to comply w/poster's writing - only ONE posting here deserves the "Verify."

  • Does it mean that we CAN NOT configure BY THE SAME TIME two or more different PWMs with the DIFFERENT period?

  • Sabina Greenberg101872 said:
    Does it mean that we CAN NOT configure BY THE SAME TIME two or more different PWMs with the DIFFERENT period?

    This depends upon your definition of, "By the same time!"    Code you showed - or that anyone may create - executes SEQUENTIALLY - thus there will be a delay (however slight) between each PWM Generator's configuration!     (this is so as each PWM Generator is based upon a different PWM Register - and ONLY ONE such register may be accessed at a time!)

    As my earlier post (only one here unverified) noted - "you MAY achieve TWO Different PWM OUTPUTS" - each with unique (i.e. different if desired) periods!    And again - you must employ TWO DIFFERENT PWM Generators to achieve this.  (I believe that your MCU has FOUR PWM Generators w/in each PWM Module.    (and you may have TWO such modules)

    Do note that once configured - and then enabled - both PWM channels - will output signals of the same or different periods - provided you've chosen and enabled PWM Outputs from TWO DIFFERENT PWM GENERATORS.   (i.e. PWM0, PWM1, PWM2, PWM3)    PWM Outputs from the same PWM Generator (i.e. PWM0 - for instance) will always SHARE the SAME PERIOD!   Is this now clear?

    Why is "simultaneous configuration" (NOT OUTPUT) important to you?   We can accept simultaneous OUTPUT - but NOT simultaneous configuration.   (which makes (w/out explanation) little sense...)

  • I mean simultaneous OUTPUT of two or more PWMs (PWM0 with 3000Hz, PWM1 with 400Hz,...), not simultaneous configuration, sorry for confusing...
  • Sabina Greenberg101872 said:
    I mean simultaneous OUTPUT of two or more PWMs (PWM0 with 3000Hz, PWM1 with 400Hz,...)

    That IS what I thought!    (as I had twice written - thank you (now) for confirming.)

    And - for the specific example you provide (i.e. PWM0 & PWM1) the answer REMAINS NO!    Again - as I've detailed (several times now) PWM0 & PWM1 "stem from the SAME PWM Generator" - do they not?    Thus their periods are "locked together" - yet their Duty Cycles may be individually controlled...

    Note that each PWM Generator controls TWO PWM Outputs.   You must choose TWO DIFFERENT PWM Generators - with one OUTPUT from each - and THIS ENABLES "INDEPENDENT PERIODS" FOR EACH PWM OUTPUT!    Even when - and especially when - both PWM Outputs are "simultaneously" operating!

    The different PWM Generators are properly identified as: "PWM_Gen_0, PWM_Gen_1, PWM_Gen_2, PWM_Gen_3."    PWM_Gen_0 controls: "PWM_OUT_0 & PWM_OUT_1"; likewise PWM_Gen_1 controls: "PWM_OUT_2 & PWM_OUT_3 - and so on!     Thus to achieve two PWM outputs of different periods - two different PWM Generators must be configured & enabled and then made to output!  

    Might you now award the proper verify to the (only) posts which Correctly Answered your request?   (all of the correct ones stand "unverified" - every incorrect one was "awarded" - SO improper...)

  • Thank you - the 1st responding poster used the language, "Two Separate PWM Channels" yet "PWM Channels" does not fully/adequately describe the fairly complex relationship between PWM Generators and their two, linked output channels.

    What you are attempting (achieving 2 PWM Outputs @ different frequencies/periods) can ONLY result when PWM Outputs from DIFFERENT PWM GENERATORS (NOT PWM CHANNELS) are configured, enabled and commanded to output... Glad that you persisted and have NOW succeeded!

  • Hi cb1,

    I edited my original post slightly to not have misleading wording in it in case others stumbles into this thread as well. Thanks for helping to clear up the differences.