bootchk 0 Posted June 19, 2016 Share Posted June 19, 2016 (edited) Never mind: I was wrong, Blink does work out of the box, see the answers below. Blink sketch doesn't work out of the box. I substitute __delay_cycles(10000000) and it works (led blinks.) I also coded it in C and it works. I am thinking there is a bug in the delay() function. In the code below, if I comment out the call to delay(), the green led blinks. If the call to delay() is in the code, the led does not blink. I presume delay() never returns or otherwise gets lost. Even if the parameter is 1. I have not used mspdebug and gdb to debug it, since mspdebug complains it can't find the FET. I did try reading the code for delay() in wiring.c Context: Ubuntu 16.04 64 bit Energia release 17 Launchpad MSP-EXP430FR4133 Code: #define LED LED2void setup() { WDTCTL = WDTPW | WDTHOLD; // initialize the digital pin as an output. pinMode(LED, OUTPUT); //PM5CTL0 &= ~LOCKLPM5;}void myDelay() { //delay(1000000); // <- NOT WORKING, I tried many values including 1 __delay_cycles(1000000);}void loop() { digitalWrite(LED, HIGH); // turn the LED on (HIGH is the voltage level) myDelay(); digitalWrite(LED, LOW); // turn the LED off by making the voltage LOW myDelay();} Edited June 20, 2016 by bootchk Quote Link to post Share on other sites
Fmilburn 445 Posted June 19, 2016 Share Posted June 19, 2016 Hi @@bootchk, I don't have a FR4133 but the problem probably is that you have turned off the WDT and Energia uses it. Try removing the following line: WDTCTL = WDTPW | WDTHOLD; Also, change the delay() to something like 100 instead of 1000000 (1000 seconds). Try the blink example and other examples in the IDE. Quote Link to post Share on other sites
bootchk 0 Posted June 20, 2016 Author Share Posted June 20, 2016 Sorry, you are correct, the blink sketch DOES work. Thanks. (I don't know why I chased down this rabbit hole, I was thrashing in updating the firmware or uploading.) Why would Energia be using the WDT? Also, I recall code to enable interrupts in the body of delay(), but not code to disable them. I need to read it more carefully. Quote Link to post Share on other sites
Fmilburn 445 Posted June 20, 2016 Share Posted June 20, 2016 @@bootchk Why would Energia be using the WDT? Some of the microcontrollers in the MSP430 line have limited resources, including timers, and the WDT is used for delay(). Conflicts can occur in the functions used by Energia/Arduino if the underlying hardware registers are modified. tripwire 1 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.