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.

MSP430FR2355: Jump to specific code after reset

Part Number: MSP430FR2355


After hitting the reset button I would like to run a small routine and then jump to a specific line in my code.  Can someone share how to do this?

  • Maybe you should explain where you're headed with this. It would be only slightly glib to say that C already provides this -- the specific code line is the first line of main().

    If you want to do some operations before main is called you can use one of the "boot hooks", e.g. _system_pre_init [Ref CC User Guide (SLAU132S) Sec 6.9.1].

    C doesn't allow you to jump from some line in some function to some (other) line in some other function. You could write assembly to do this, but then dealing with the stack and register allocations are your problem.

  • I have a radio with a group ID located on it.  This ID also lives within the MSP.  I have a specific location within the MSP where a default group ID exists as well in the event user wants to do a 'reboot' of sorts and start over.  I would like to hit the reset but on the MSP, jump to the NMI (or similar vector) at which point I flush the existing group ID and reload the default group ID onto the radio.....I have a routine already existing to write to the radio.  I was hoping that within the ISR I might flush the FRAM space THEN I could jump to main and from there have a flag that would call the radio routine to re-configure that particular radio register.....

    1.  Which ISR would I want to use?

    2.  Can I have the ISR do some small task while inside it then jump to main or do I basically need to place all this within a conditional in main?

    Thanks

  • While C does provide a mechanism to jump anywhere, it requires that you execute setjump() first so it can store the information required to perform that jump.

    But what you really want is a way to do something special at reset. The way I have dealt with this is to check for a special condition after reset. For example, I have 4 buttons that the user(s) can press but usually one at a time. At power on I check to see if two particular buttons are pressed. If so, I call the configuration code. Once complete, operation resumes as usual.

  • This sounds sort of like a Factory Reset or maybe a One-Time Registration kind of mechanism. For those, you don't want it to happen regularly or accidentally. System Resets (presumptively) happen all the time -- battery runs down, someone generates a spark nearby, cat walks on the Reset button.

    Do you have another button? One thing I've seen done is you hold that button down and then push the Reset button; main looks to see if the button is held down (maybe for some duration) and acts accordingly. If you have a UART command interpreter, you could have a command that erases the relevant FRAM then generates one of the software-generated Resets (vide one of your recent questions). The goal is to make it just enough trouble to do that it won't happen accidentally.

  • Hmmmm.....I don't have any extra buttons and all buttons have multiple meanings already (that is they all have 'momentary' functions AND they all have '> 2 second' functions......

    I guess to start with I don't completely understand the mechanisms for generating the NMI....user guide talks to this point but from reading it I don't know whether the SYSNMI or UNMI could somehow be leveraged here.....Seems to me that pushing the reset button (BOR) should jump into one of those ISRs after the NMIIE had been enabled but it doesn't....

  • I haven't tried this (I'm not smart enough to give up my RST button), but I would start with the recommendations in UG Sec 1.7 and Table 1-11. 

    Have you disconnected the debugger?

  • I'm going with your earlier recommendation....Seems to work well....That is I already have a trap within my statistics function for if two buttons are held for >2 seconds, along with the buttons that were the culprits....I've decided to act on that positively now as a flag for reset.....I then just do the :

    WDCTL |= 0xDEAD; 

    after my clear FRAM, and reconfig the radio register 

    all seems to work 

    Thanks for the help!

**Attention** This is a public forum