Jump to content
43oh

Be aware : Launchpad can retain old code in memory


Recommended Posts

Hi.

Lauchpad seems to keep some older code in memory and still execute it after new upload done !

 

 

L1 and L2 are LEDs

 

When  I upload this code :

#define L1 P1_0
#define L2  P1_6
void setup() {              
  pinMode(L1, OUTPUT);   
  pinMode(L2, OUTPUT);   
  digitalWrite(L1, HIGH);
 }
void loop() {
  digitalWrite(L1, HIGH);
  digitalWrite(L2, HIGH);
}

I got L1 and L2 lighted on, wicth is fine.

Next, when I upload this code :

#define L1 P1_0
#define L2  P1_6
void setup() {                
  pinMode(L1, OUTPUT);   
  pinMode(L2, OUTPUT);   
  digitalWrite(L1, HIGH);
 }
void loop() {
  digitalWrite(L1, HIGH);
 }

I got L1 and L2 lighted on, wicth is not fine !

Edited by bluehash
[ADMIN] Title edit. Was "Be aware : Launchpad is DANGEROUS (or can be)"
Link to post
Share on other sites

Next, when I upload this code :

#define L1 P1_0
#define L2  P1_6
void setup() {                
  pinMode(L1, OUTPUT);   
  pinMode(L2, OUTPUT);   
  digitalWrite(L1, HIGH);
 }
void loop() {
  digitalWrite(L1, HIGH);
 }
I got L1 and L2 lighted on, wicth is not fine !

 

It's also not surprising. PxOUT is not cleared on reset; since you enabled the pin for output, the previous setting is left unchanged. This is documented in the 2xx family user's guide (Table 8-2 Digital I/O Registers) from slau144j. A sufficiently long power-down might cure the problem, but in general if you're going to change the configuration of a GPIO from its power-up state you should set all the relevant registers.

Link to post
Share on other sites

The lesson here is you should always explicitly init all IO. Don't assume any IO will be in a know state on power up or reset. This is not retained code, but rather retained state.

retained state  ! I'll try to remember this.

 

But I'm from Arduino, and I've checked on it. It doesn't behave this way. No retained state on Arduino !

Is it because of different uC or is it because Arduino IDE does something hidden in background

Link to post
Share on other sites

retained state  ! I'll try to remember this.

 

But I'm from Arduino, and I've checked on it. It doesn't behave this way. No retained state on Arduino !

Is it because of different uC or is it because Arduino IDE does something hidden in background

Different uC.  Can't expect them to work the same.

Link to post
Share on other sites

If Energia is to provide the same interface as the Arduino API it emulates, it may be appropriate that it provide an initial configuration when invoking the pinMode command. Or it may not; I have no idea what sort of behavioral promises are made by either Arduino's normal API or Energia.

 

There could even be times when the value set before a reset is exactly what you want to inherit after a reset: that need is why there's the more general LOCKLPM5 feature on the chips that support LPM3.5 and LPM4.5 modes. Getting that level of control is why I prefer to interface directly with the hardware for things as trivial as this: then there's only one reference document I need to check.

Link to post
Share on other sites

I've got the information that Atmel reset all PORT to 0 on a reset.

On the other hand, TI on the MSP430 doesn't.

 

 

There could even be times when the value set before a reset is exactly what you want to inherit after a reset: that need is why there's the more general LOCKLPM5 feature on the chips that support LPM3.5 and LPM4.5 modes.

What are these different LPM3.5 and LPM4.5 modes means ? I've never heard about that ?

Link to post
Share on other sites

I've got the information that Atmel reset all PORT to 0 on a reset.

On the other hand, TI on the MSP430 doesn't.

So that's evidence supporting the possibility that Energia should work around that. Not a fight I'm interested in.

 

What are these different LPM3.5 and LPM4.5 modes means ? I've never heard about that ?

It's a feature of the more advanced MSP430 chips: ultra-low-power that shut everything down and power up back at the start of the application, with or without SRAM retention and other features, resulting in current use that's fractions of a microamp. It's present in the 5xx/6xx and 57xx/58xx/59xx families; you'd have to read the users guides for more details.
Link to post
Share on other sites

users guides ?

You mean datasheet ? Or is there a more general information about MSP I should read.

 

I'm new to MSP, and to uC. sorry for so many questions.

 

By the way, Lauchpad's users seem to be more evolved than Arduino's users. If I'm right, what's the point for LP's users to use Energia instead of CCS ?

 

Well, at least, for me, it's very helpful.

Link to post
Share on other sites

Specific devices (MSP430G2553, MSP430FR5739) have datasheets. These provide pin mappings, power consumption, available peripherals. Families of devices (2xx, FR57xx) have user's guides. These provide descriptions of each peripheral, what registers are available, and the effect of manipulating those registers. You need to be familiar with both to develop non-trivial applications. Look for them here.

 

Energia provides a familiar interface and lowers the barrier to entry for people familiar with Arduino. From everything I've heard it's a great solution; it's just not one that accommodates my control issues. For that, I developed BSP430.

Link to post
Share on other sites

CCS is an industry grade IDE for serious embedded development. For customers starting out or who prefer something more lightweight and portable, Energia is a better choice. 

 

Energia is also cool because the abstraction layer allows it to be architecture independent, so you can run the same sketches on MSP430, Tiva, C2000, etc. 

 

Finally, if you ever want to "graduate" to CCS, CCS version 6 has an Energia import feature, so you can take your sketches and APIs you are familar with, but also take advantage of full HW debugger and many other features of CCS. The idea is to have multiple points of entry for customers, so that they can develop applications in the most comfortable way. 

Link to post
Share on other sites

users guides ?

You mean datasheet ? Or is there a more general information about MSP I should read.

 

I'm new to MSP, and to uC. sorry for so many questions.

 

By the way, Lauchpad's users seem to be more evolved than Arduino's users. If I'm right, what's the point for LP's users to use Energia instead of CCS ?

 

Well, at least, for me, it's very helpful.

@@hary

No, user guide. In the case of the Launchpad's chips (the MSP430G2554 et al) you should probably start with reading the MSP430x2xx series family guide, which contains generic information about the series of chips. This includes clocks, GPIO, timers, etc. Then there is the data sheet specific to one or a very few chips. This contains electrical information (max source/sink current, bandwidths, etc.) and information specific to that chip, like which secondary functions exist on which pins (eg: where are which channels of your ADC located).

 

Energia does include libraries and is easier to install and use than CCS. In the latest realease CCS does support Energia sketches, but not everyone uses the newest CCS. Others use (or used to use) IAR, which was really good, but has more recently been surpassed by CCS (imho). If you like/prefer CCS, feel free to use it, the gap to using Energia sketches should be closed already.

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...