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.

MSP430F5659: Reset method used in USB BSL through python-msp430-tools

Part Number: MSP430F5659
Other Parts Discussed in Thread: MSP430F5502

Hi,

I need to know what type of reset is triggered on the MSP when using the -r flag for the python-msp430-tools BSL updater ()

This is so that my code can differentiate from when it software resets itself vs when and update was performed. What will the value of the SYSRSTIV be after an update is performed with the reset flag?

Thanks,

Kevin

  • Hello Kevin,

    Unfortunately, python-msp430-tools is not an official TI tool, so my help will be limited. Looking through the documentation, it appears that the "-r" flag triggers a software reset that performs a normal device reset that will start the program that is specified in the reset interrupt vector.

    https://python-msp430-tools.readthedocs.io/en/latest/target.html#msp430-bsl-target

    For SYSRSTIV, you can learn more about how it works in the user's guide.

    https://www.ti.com/lit/slau208

    Regards,

    James

  • Hi James,

    Thanks for the info. I was not able to find all the info I needed from the user's guide on this so I performed some experiments that have left me even more confused.

    Our board has a USB port so all of these are executed with the board plugged in and the logging over the USB CDC interface.

    I wrote some code that would execute various types of software resets of the MSP430F5502 and then it logs out the SYSRSTIV value upon startup. Some of the resets seem to be working correctly and some are not.

    Here are my results:

    First plugged into USB port:

    - SYSRSTIV = 0x02, this is expected since the BOR would have executed since the board was unpowered.

    Trigger a SW POR reset: ( PMMCTL0 = PMMPW | PMMSWPOR; )

    - The board disconnects and the USB does not re-enumerate. This one makes no sense to me since any other reset I trigger causes the board to enumerate the USB connection.

    Trigger a SW BOR reset: ( PMMCTL0 = PMMPW | PMMSWBOR; )

    - The board disconnects and then enumerates.

    - SYSRSTIV = 0x00, this should be 0x06 according to the reference manual

    Trigger a PMM password violation ( PMMCTL0 = PMMSWPOR; ) // Note the missing password, this does not trigger the POR

    - The board disconnects and then enumerates.

    - SYSRSTIV = 0x20, this is correct according to the reference manual and is a PMMKEY violation

    Trigger a watchdog timeout

    - The board disconnects and then reenumerates.

    - SYSRSTIV = 0x16, this is correct according to the reference manual and is a WDT timeout.

    Is there an explanation for why the SW resets seem to not be showing up correctly in the SYSRSTIV vector but the other resets I have tried to trigger show up correctly?

    Additionally, why would the system not enumerate after the PMMSWPOR reset when all of the other resets cause a proper reset and enumeration.

    Thanks,

    Kevin

  • Hi Kevin,

    Apologies for the delay here. Thanks for your detailed post and testing.

    I think the issue you're seeing is related to writing to the entire PMMCTL0 register rather than just setting the PMMSWPOR. This is going to clear the last two bits in PMMCTL0, setting PMMCOREV = 0. However, you should never change Vcore more than one level at a time - see section 2.2.5 Decreasing Vcore in the F5xx/6xx user's guide www.ti.com/lit/pdf/slau208. I would apply this approach to the other writes to PMMCTL0 as well.

    Please check out the following thread for more details.

    Why is setting PMMCOREV necessary for SW POR reset?

    Also, this device has several errata unfortunately, so it may be beneficial to read through the erratasheet.

    Regards,

    James

  • Hi James,

    Thanks for the response. I changed the experimental code I was running to use either one of these two lines:

    PMMCTL0 = PMMPW | PMMSWPOR | PMMCLT0_L;

    OR

    PMMCTL0 = PMMPW | PMMSWBOR | PMMCLT0_L;

    When I use the PMMSWPOR everything now works as expected.

    However when I use the PMMSWBOR everything resets and the MSP reenumerates with the host however I am still seeing the SYSRSTIV set to 0x00 instead of 0x06 as expected. Is there something else special with the SW BOR that I need to be doing?

    Thanks,

    Kevin

  • Hi Kevin,

    Kevin Lannen said:

    Thanks for the response. I changed the experimental code I was running to use either one of these two lines:

    PMMCTL0 = PMMPW | PMMSWPOR | PMMCLT0_L;

    OR

    PMMCTL0 = PMMPW | PMMSWBOR | PMMCLT0_L;

    When I use the PMMSWPOR everything now works as expected.

    That's great to hear.

    Kevin Lannen said:
    However when I use the PMMSWBOR everything resets and the MSP reenumerates with the host however I am still seeing the SYSRSTIV set to 0x00 instead of 0x06 as expected. Is there something else special with the SW BOR that I need to be doing?

    I don't have a good explanation for why this happens. I do suspect it's something related to the USB communication or the application code.

    I took my MSP-EXP430F5529 LaunchPad, created a short code example that turns on a LED after a SWBOR reset and verified that it works. Here's my code for your reference. See the Description for more details about how it works. You could modify it to simply set a GPIO high if a SWBOR occurs, and that may help you track down any communication or other issues that may be happening.

    /* --COPYRIGHT--,BSD_EX
     * Copyright (c) 2020, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     *
     *******************************************************************************
     * 
     *                       MSP430 CODE EXAMPLE DISCLAIMER
     *
     * MSP430 code examples are self-contained low-level programs that typically
     * demonstrate a single peripheral function or device feature in a highly
     * concise manner. For this the code may rely on the device's power-on default
     * register values and settings such as the clock configuration and care must
     * be taken when combining code from several examples to avoid potential side
     * effects. Also see www.ti.com/grace for a GUI- and www.ti.com/msp430ware
     * for an API functional library-approach to peripheral configuration.
     *
     * --/COPYRIGHT--*/
    //******************************************************************************
    //
    // MSP430F552x Demo - SYSRSTIV Reset Interrupt Vector Register
    //
    // Description: This code can be used on the MSP-EXP430F5529 LaunchPad to easily
    //              identify the last cause of reset. For this example, the LEDs
    //              are turned off at startup and turned on if the associated
    //              reset event occurred. LED1 turns on after a RST/NMI BOR.
    //              LED2 turns on after a SW BOR. After programming and power cycling
    //              the LaunchPad, push the RST button (S3) and LED1 turns on.
    //              Likewise, push the S1 button to trigger the SW BOR event and LED2
    //              turns on. Both LEDs stay off after power cycling the LaunchPad.
    //              Due to the limited number of LEDs, the code inside the various
    //              switch statements can be modified to demonstrate the other
    //              BOR, POR or PUC events.
    //
    // ACLK = 32.768kHz, MCLK = SMCLK = default DCO~1MHz
    //
    // James Evans
    // Texas Instruments Inc.
    // April 2020
    // Built with CCS v10.0.0
    //******************************************************************************
    
    /* SYSRSTIV Definitions (see Table 1-26 in SLAU208) */
    #define SYSRSTIV_NONE           (0x0000)       /* No Interrupt pending */
    #define SYSRSTIV_HW_BOR         (0x0002)       /* SYSRSTIV : BOR */
    #define SYSRSTIV_RSTNMI_BOR     (0x0004)       /* SYSRSTIV : RST/NMI BOR */
    #define SYSRSTIV_PMM_SW_BOR     (0x0006)       /* SYSRSTIV : PMM Software BOR */
    #define SYSRSTIV_LPM5WU_BOR     (0x0008)       /* SYSRSTIV : Port LPM5 Wake Up BOR */
    #define SYSRSTIV_SECYV_BOR      (0x000A)       /* SYSRSTIV : Security violation BOR */
    #define SYSRSTIV_SVSL_POR       (0x000C)       /* SYSRSTIV : SVSL POR */
    #define SYSRSTIV_SVSH_POR       (0x000E)       /* SYSRSTIV : SVSH POR */
    #define SYSRSTIV_SVML_OVP_POR   (0x0010)       /* SYSRSTIV : SVML_OVP POR */
    #define SYSRSTIV_SVMH_OVP_POR   (0x0012)       /* SYSRSTIV : SVMH_OVP POR */
    #define SYSRSTIV_PMM_SW_POR     (0x0014)       /* SYSRSTIV : PMM Software POR */
    #define SYSRSTIV_WDTTO_PUC      (0x0016)       /* SYSRSTIV : WDT Time out PUC */
    #define SYSRSTIV_WDTKEY_PUC     (0x0018)       /* SYSRSTIV : WDTKEY violation PUC */
    #define SYSRSTIV_KEYV_PUC       (0x001A)       /* SYSRSTIV : Flash Key violation PUC */
    #define SYSRSTIV_PERF_PUC       (0x001E)       /* SYSRSTIV : PERF periph/config area fetch PUC */
    #define SYSRSTIV_PMMKEY_PUC     (0x0020)       /* SYSRSTIV : PMMKEY violation PUC */
    
    #include <msp430.h>
    
    void main (void) {
        // Stop watchdog timer
        WDTCTL = WDTPW+WDTHOLD;                   // Stop WDT
    
        // Initialize GPIO inputs
        P2DIR &= ~BIT1;                           // P2.1 set as input (S1)
        P2REN |= BIT1;                            // Enable internal
        P2OUT |= BIT1;                            //    pull-up resistor
    
        // Initialize GPIO outputs
        P1DIR |= BIT0;                            // P1.0 set as output (LED1)
        P1OUT &= ~BIT0;                           // Clear LED1
        P4DIR |= BIT7;                            // P4.7 set as output (LED2)
        P4OUT &= ~BIT7;                           // Clear LED2
    
        // Determine the cause of previous reset event
        switch (__even_in_range(SYSRSTIV, SYSRSTIV_PMMKEY_PUC))
        {
    
            case SYSRSTIV_NONE:         // No Interrupt pending
                P1OUT &= ~BIT0;         // Reset LED 1
                P4OUT &= ~BIT7;         // Reset LED 2
                break;
    
            case SYSRSTIV_HW_BOR:       // SYSRSTIV : BOR
                __no_operation();
                break;
    
            case SYSRSTIV_RSTNMI_BOR:   // SYSRSTIV : RST/NMI
                P1OUT |= BIT0;          // Turn on LED1
                break;
    
            case SYSRSTIV_PMM_SW_BOR:   // SYSRSTIV : SW BOR
                P4OUT |= BIT7;          // Turn on LED2
                break;
    
            case SYSRSTIV_LPM5WU_BOR:   // SYSRSTIV : Port LPM5 Wake Up
                __no_operation();
                break;
    
            case SYSRSTIV_SECYV_BOR:    // SYSRSTIV : Security violation
                __no_operation();
                break;
    
            case SYSRSTIV_SVSL_POR:     // SYSRSTIV : SVSL
                __no_operation();
                break;
    
            case SYSRSTIV_SVSH_POR:     // SYSRSTIV : SVSH
                __no_operation();
                break;
    
            case SYSRSTIV_SVML_OVP_POR: // SYSRSTIV : SVML_OVP
                __no_operation();
                break;
            case SYSRSTIV_SVMH_OVP_POR: // SYSRSTIV : SVMH_OVP
               __no_operation();
               break;
    
            case SYSRSTIV_PMM_SW_POR:   // SYSRSTIV : SW POR
                __no_operation();
                break;
    
            case SYSRSTIV_WDTTO_PUC:    // SYSRSTIV : WDT Time out
                __no_operation();
                break;
    
            case SYSRSTIV_WDTKEY_PUC:   // SYSRSTIV : WDTKEY violation
                __no_operation();
                break;
    
            case SYSRSTIV_KEYV_PUC:     // SYSRSTIV : Flash Key violation
                __no_operation();
                break;
    
            case SYSRSTIV_PERF_PUC:     // SYSRSTIV : peripheral/config area fetch
                __no_operation();
                break;
    
            case SYSRSTIV_PMMKEY_PUC:   // SYSRSTIV : PMMKEY violation
                __no_operation();
                break;
    
            default: break;
        }
    
        // Endless loop
        while(1)
        {
            __no_operation();
            if (P2IN & BIT1)            // If S1 button was not pushed,
            {
                __no_operation();       // Do nothing
            }
            else                        // If S1 button was pushed,
            {
                __delay_cycles(10000);          // Delay for switch debounce
                PMMCTL0 = PMMPW | PMMSWBOR;     // Trigger SW BOR
            }
        }
    }

    Regards,

    James

  • Hi James,

    It looks like it was an issue with the USB code doing something to reset that value. I moved where I was checking the SYSRSTIV to above where we initialized the USB and set the PMM_setVCore and now I am getting the expected values on this.

    I do have one additional question that goes back to my original question about the python-msp430-tools though. You said it is not an official TI tool but I found the other day that it is used by the MSP430 USB Firmware Upgrade Example which is available here: software-dl.ti.com/.../index_FDS.html as the python_firmware_upgrader. It seems that if TI is using this as an example for how to do this then TI should provide support for it?

    We would also like to see the msp430-tools support python3 since python 2 is now end of life.

    Thanks for the support.

    Kevin

  • Hi Kevin,

    Kevin Lannen said:
    It looks like it was an issue with the USB code doing something to reset that value. I moved where I was checking the SYSRSTIV to above where we initialized the USB and set the PMM_setVCore and now I am getting the expected values on this.

    That's great to hear! Thanks for letting us know.

    Kevin Lannen said:

    I do have one additional question that goes back to my original question about the python-msp430-tools though. You said it is not an official TI tool but I found the other day that it is used by the MSP430 USB Firmware Upgrade Example which is available here: software-dl.ti.com/.../index_FDS.html as the python_firmware_upgrader. It seems that if TI is using this as an example for how to do this then TI should provide support for it?

    We would also like to see the msp430-tools support python3 since python 2 is now end of life.

    The Python Firmware Upgrader tool was built upon python-msp430-tools which is an open-source toolset for downloading MSP430 code, located at
    pypi.python.org/.../python-msp430-tools. This package is just replicated within the MSP430 Python Firmware Upgrader.

    I'd recommend reaching out to the python-msp430-tools author, Chris Liechti, at cliechti@gmx.net to request Python 3 support.

    Regards,

    James

**Attention** This is a public forum