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.

PWM not working in TM4C1294 Connected Launchpad

Other Parts Discussed in Thread: ENERGIA

I am uploading the Fade example of energia to the connected launchpad.

But the LED is not fading, it is just blinking.

I tried other pins also like PF3 and PG0 and I checked the output using a multimeter since I don't have an oscilloscope. But the output is about 2.7v and not reducing.

*/

int brightness = 0;    // how bright the LED is
int fadeAmount = 5;    // how many points to fade the LED by

void setup()  { 
  // declare pin 14 to be an output:
  pinMode(GREEN_LED, OUTPUT);
} 

void loop()  { 
  // set the brightness of pin 9:
  analogWrite(GREEN_LED, brightness);    

  // change the brightness for next time through the loop:
  brightness = brightness + fadeAmount;

  // reverse the direction of the fading at the ends of the fade: 
  if (brightness == 0 || brightness == 255) {
    fadeAmount = -fadeAmount ; 
  }     
  // wait for 30 milliseconds to see the dimming effect    
  delay(30);                            
}

  • Hello Subhojyoti,

    I am not well versed with Energia, but what is analogWrite? If it is a DAC output then TM4C does not have a DAC.

    Regards
    Amit
  • Poster may note that "nowhere" w/in his code does (any) mention of "PWM" appear.   Such may be required - is not that true?

    My car (similarly) "not working" until I enter - press "Start."

    We note that a, "DAC-like" output may be massaged from a PWM signal via the application of a suitable R-C network.   As always - that PWM must be properly configured and then enabled - code poster presents omits both - thus it is poster's code (and investigation) which registers, "Not working."

  • AnalogWrite is used to generate PWM only...It is a library function of energia.
    Here are details on that: energia.nu/.../
  • That's good - but like Amit my firm is "no fan" of energia.

    One can change the perceived brightness of an Led via, "unfiltered PWM." (usually - via an R-C filter/network - the PWM signal is converted to a reasonably steady DC voltage - and that change in (PWM induced) voltage directly impacts Led brightness.)

    Now as you report "blinking" - usually that indicates that your PWM Rate is too low (i.e. frequency of the PWM is too low). I'd suspect that a PWM frequency of 100Hz (minimum) would be required so that the "blinking" you note will transition to, "variable Led brightness."

    You must discover "how to raise the frequency of your PWM signal."
    Note: I could view your code earlier - I see just the code's skeleton, now...

    [edit]  I followed your link - learned that the (claimed) PWM frequency is ~490Hz.   That should be adequate to produce the "fading" effect you seek.

    Also noted was "NO listing" for TM4C w/in that Analog_Write function.   Several MSP parts were listed.   Usually PWM can only "easily & efficiently" be achieved upon certain TM4C pins - designed for such usage.   These "PWM welcoming" pins are confined to:

    • TM4C pins designated as "Timer"
    • TM4C pins designated as "PWM" (PWM Generator controlled)

    Should the pin you've chosen NOT be among those 2 categories - I doubt your energia function will succeed.   Does "Green Led" meet those classifications, shown above?

    Further - your comments w/in your code appear "sloppy" as they refer (both) to "Green Led" as pin 14 - later pin 9!  "Green Led" may save you - but "attention to such detail" IS required!   (if you don't care - why should others?)

    There's a university student here, "Luis Afonso" who has published a blog which deals w/TM4C and energia.    Your search targeting Luis should yield a link to his blog...   (search performed in your behalf by my staff)

    https://sites.google.com/site/luiselectronicprojects/home

  • Also keep in mind that LED brightness is usually very nonlinear. The difference between barely visible and full brightness might only be a few steps.

    Robert