Beeker 0 Posted February 15, 2018 Share Posted February 15, 2018 Hi, I have a EK-TM4C1294XL evaluation kit and a BOOSTXL-EDUMKII board connected to it. I cannot get the RGB_LED_RANDOM example to work. The LED's work as if i change the analogWrite(ledRed, random(255)) to analogWrite(ledRed, 255) the LED comes on. Any value other than 255 results in the LED staying OFF. I have jumper J5 in the top position (1-2) which i believe is correct. What do i need to do, to get the PWM running? thanks Quote Link to post Share on other sites
Rei Vilo 695 Posted February 15, 2018 Share Posted February 15, 2018 Have you tried? uint8_t number = random(0, 255); analogWrite(ledRed, number); Quote Link to post Share on other sites
Beeker 0 Posted February 16, 2018 Author Share Posted February 16, 2018 Ive just tried that with no luck:- int ledRed = 39, ledBlue = 37, ledGreen = 38; // LED connected to digital pin 9 void setup() { // Initialize the pseudo-random number generator randomSeed(1); } void loop() { uint8_t number = 254; analogWrite(ledRed, number); // sets the value (range from 0 to 255) for 3 RGB channels: // analogWrite(ledRed, random(255)); // analogWrite(ledBlue, random(255)); // analogWrite(ledGreen, random(255)); // wait for 30 milliseconds before changing the color again // delay(300); } If i set uint8_t number = 255 then the LED turns on (RED), but any number other than 255 means it never comes on. Quote Link to post Share on other sites
Rei Vilo 695 Posted February 16, 2018 Share Posted February 16, 2018 That would mean this pin does not feature PWM. Quote Link to post Share on other sites
Beeker 0 Posted February 16, 2018 Author Share Posted February 16, 2018 If i'm understanding the documentation i have correctly, the RGB LED is wired to PWM channels. Plus the software i have is provided not written by myself, so i presume somebody has written and tested it. I must be doing something wrong but i don't see what! Quote Link to post Share on other sites
Rei Vilo 695 Posted February 17, 2018 Share Posted February 17, 2018 This code works for me. [edit] on LaunchPad LM4F120H5QR / TM4C123GH6PM. [/edit] #include "Energia.h" void setup() { pinMode(RED_LED, OUTPUT); pinMode(GREEN_LED, OUTPUT); pinMode(BLUE_LED, OUTPUT); Serial.begin(9600); Serial.println(); Serial.println("RGB\tR\tG\tB"); } void writeRGB(uint8_t valueRed, uint8_t valueGreen, uint8_t valueBlue) { analogWrite(RED_LED, valueRed); analogWrite(GREEN_LED, valueGreen); analogWrite(BLUE_LED, valueBlue); } void loop() { uint8_t valueRed = random(255); uint8_t valueGreen = random(255); uint8_t valueBlue = random(255); Serial.print(millis()); Serial.print("\t"); Serial.print(valueRed); Serial.print("\t"); Serial.print(valueGreen); Serial.print("\t"); Serial.print(valueBlue); Serial.println(); writeRGB(valueRed, valueGreen, valueBlue); delay(333); } And the video at vimeo.com/256190702. Quote Link to post Share on other sites
Rei Vilo 695 Posted February 17, 2018 Share Posted February 17, 2018 You need to initialise the outputs! As always, the more obvious the cause, the more difficult to find it! Quote Link to post Share on other sites
Beeker 0 Posted February 19, 2018 Author Share Posted February 19, 2018 This still isn't working. I've taken my code and added the pinMode() into the setup routine. Still no joy. Your supplied code didn't compile giving me errors that 'BLUE_LED' was not declared in this scope. I re-wrote the code so that i could get it to compile and whilst i'm seeing the serial port information, the RGB LED isn't coming on. As i can't get the PWM to work i have to now point the finger at the underlying code behind analogWrite() for my board EK-TMC1294XL. How would i go about writing my own analogWrite() routine, i.e. writing/reading to the micro registers directly? Quote Link to post Share on other sites
Rei Vilo 695 Posted February 19, 2018 Share Posted February 19, 2018 The code was for the LM4F120H5QR / TM4C123GH6PM. On the TM4C1294NCPDT, the LEDs aren't PWM. See the pins map! Select pins in violet instead on the pins map. Quote Link to post Share on other sites
Beeker 0 Posted February 20, 2018 Author Share Posted February 20, 2018 But those are the LED's that are on the EK-TM4C1294XL board. My query relates to the RGB LED that is on the BOOSTXL-EDUMKII board. The RGB LED is on pins 39,38,37 of the 40 pin stackable connectors. These map to header C1 on the EK-TM4C1294XL pins 2,3,4 which have PWM allocated to them. I'm not convinced the analogWrite(pin,duty) is supported on my board and im also confused as to what i pass in the pin argument - is it 39,38 or 37 or 2,3,4 depending on which pin i want the PWM on? This isn't clear. Thanks for all your help but i think im going to give up on this shortly. Quote Link to post Share on other sites
Rei Vilo 695 Posted February 20, 2018 Share Posted February 20, 2018 Unfortunately answer is the same. BOOSTXL-EDUMKII RGB LED uses pins 37, 38, 39 for PWM. But EK-TM4C1294XL does not provide PWM on pins 37, 38, 39 or pins 77,78,79. Quote Link to post Share on other sites
Beeker 0 Posted February 20, 2018 Author Share Posted February 20, 2018 Sorry, im still not getting this! I've attached the pin-outs for the eval board and also the booster pack. The eval board shows PWM assigned to the pins that map to the pins on the boostxl-edumkii RGB LED. To me, this shows that PWM should be available on the pins that map to the RGB LED. If the routine analogWrite(pin,duty) is able to provide PWM to those pins (the micro can) then all should be well. Quote Link to post Share on other sites
Rei Vilo 695 Posted February 20, 2018 Share Posted February 20, 2018 Energia implements a sub-set of the available features. If you want to uses PWMs, you'd need to work with Code Composer Studio. Quote Link to post Share on other sites
Beeker 0 Posted February 22, 2018 Author Share Posted February 22, 2018 Rei, could i ask one more question of you, not relate to the previous, but ill keep it here if thats ok? Im looking at some code that blinks an LED - BlinkWithoutDelay and it contains a line "const int ledPin = GREEN_LED; // the number of the LED pin" Where is the compiler getting the value of GREEN_LED from? I would like to see how this relates to the micro pin and then onto the booster pack pin or expansion port pin. From connecting up its on Pin 85 on the expansion header, but id like to see where this is declared. Thanks Quote Link to post Share on other sites
Rei Vilo 695 Posted February 22, 2018 Share Posted February 22, 2018 Have a look at the file pins_energia.h under ~/Library/Energia15/packages/energia/hardware/tivac/1.0.3/variants/EK-TM4C1294XL/pins_energia.h for macOS or at https://github.com/energia/tivac-core/blob/master/variants/EK-TM4C1294XL/pins_energia.h. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.