Jump to content
43oh

delay() broken on MSP430FR4133? blink doesn't work


Recommended Posts

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 LED2

void 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 by bootchk
Link to post
Share on other sites

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.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...