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.

MSP430I2041: power reset

Part Number: MSP430I2041

Hi,

I have programmed my device for UART functionality. When I run the device using CCS debug window, it is working fine and and I am able to see the correct characters on serial terminal. I am facing some problems when the device is removed from power and then again connected.

When again connected, some erroneous characters are being sent to the serial terminal. The device works fine when I reprogram it. What should I do to ensure that correct characters are sent even after a power reset?

Best Regards,

Abhishek.

  • Hi Abhishek,

    Could you provide more detail on what you are actually seeing on the serial terminal window? Do you still see the expected characters in addition to the erroneous ones?

    Regards,
    Nathan
  • Hi Abhishek,
    * Do the connections from your PCB to your serial terminal include all 3 of Rx, Tx, GND (some people forget about the GND part)?
    * What type of power are you connecting to it? is it filtered? Can you create a simple C-L-C pi filter at the V+ from your power-to-PCB line?
  • Hi,

    When I program the board, everything is working fine. When I remove the power supply no character is seen on serial terminal (this is fine). When I connect the power supply , sometimes I am seeing a ',' and sometimes a blank space. I think that the device gets reset when I remove and connect the power supply. This reset affects the UART configuration. How to ensure that even after a power reset, the device functions as desired? This might have something to do with power reset interrupt but I am unable to incorporate this in my program.

    Best Regards,

    Abhishek.

  • Hi Abhishek,

    When you stay that you connect the power supply, are you talking about the USB cable, or an external power supply? I am assuming that you are using the USB cable to communicate with the PC, so is the USB cable connected while you are removing and reconnecting the power supply?

    Regards,
    Nathan
  • Hi,

        I am talking about removing the usb cable. I am programming my board through the ezFET lite available on MSP430F5529LP. The usb is being used for power, programming and UART communication.

    Best Regards,

    Abhishek.

  • Hi Abhishek,

    The device restarting should not be affecting the UART configuration. Could you post your UART configuration code (and your clock configuration code as well) so I can see if there are any issues that stand out there.

    I think it is possible that your UART commands are being sent out too quickly. When you run the debugger in CCS, your device has already been powered on, so this would not be an issue. Could you try putting a delay in main() before you sent out UART commands and see if this helps things?

    Regards,
    Nathan
  • Hi Abhishek,

    Has this issue been solved? If so, please mark it as answered. If no response soon, this thread will be closed due to inactivity.

    Regards,
    Nathan
  • Hi,

    No this issue is not solved yet.  What I am observing is that after every power cycle, UART is sending incorrect characters to the serial terminal. Please find the attached main.c and low_level_init.c files that I have included in my project.

    main.c

    #include "msp430.h"
    unsigned char i;
    void main(void) {
        WDTCTL = WDTPW | WDTHOLD;               // Stop watchdog timer
    
        P1SEL0 |=   BIT2 | BIT3;                // P1.2/3 eUSCI_A Function
        P1SEL1 &= ~(BIT2 | BIT3);
    
        UCA0CTL1 |= UCSWRST;                    // Hold eUSCI in reset
        UCA0CTL1 |= UCSSEL_2;                   // SMCLK
        UCA0BR0   = 0xAA;                       // 9600 baud
        UCA0BR1   = 0x06;
        UCA0MCTLW = 0xD600;                     // 16.384MHz/9600 = 1706.6667 (See UG)
        UCA0CTL1 &= ~UCSWRST;                   // Release from reset
        UCA0IE   |= UCRXIE;// Enable RX interrupt
        i='f';
    while(1)
    {
    	while (!(UCA0IFG&UCTXIFG)); // USCI_A0 TX buffer ready?
    	                 UCA0TXBUF = i;
    }
        __bis_SR_register(LPM0_bits | GIE);     // Enter LPM0
        __no_operation();                       // For debugger
    }
    

    low_level_init

    #include "msp430.h"

    #ifdef __TI_COMPILER_VERSION__
    int _system_pre_init(void)
    #elif __IAR_SYSTEMS_ICC__
    int __low_level_init(void)
    #elif __GNUC__
    extern int system_pre_init(void) __attribute__((constructor));
    int system_pre_init(void)
    #else
    #error Compiler not supported!
    #endif
    {
        unsigned long *jtagPwd = (unsigned long *)JTAG_DIS_PWD1;

        /* Feed the watchdog timer */
        WDTCTL = WDTPW | WDTCNTCL;

        /* Check JTAG password locations and disable JTAG if passwords don't match.
         * Else the JTAG will be enabled in the 64th cycle after reset.
         */
        if ((*jtagPwd != 0x00000000) && (*jtagPwd != 0xFFFFFFFF))
        {
            /* Disable JTAG */
            SYSJTAGDIS = JTAGDISKEY;
        }

        /* Calibration section
         * Check for the BORIFG flag in IFG1. Execute calibration if this was a BORIFG.
         * Else skip calibration
         */
        if (IFG1 & BORIFG)
        {
            /* Perform 2's complement checksum on 62 bytes of TLV data */
            unsigned int checksum = 0;
            unsigned char *TLV_address_for_parse = ((unsigned char *)TLV_START);
            unsigned int *TLV_address_for_checksum = ((unsigned int *)TLV_START + 1);

            do
            {
                checksum ^= *TLV_address_for_checksum++;
            } while (TLV_address_for_checksum <= (unsigned int *)TLV_END);

            checksum ^= 0xFFFF;
            checksum++;

            /* If check sum is not correct go to LPM4 */
            if (*((unsigned int *)TLV_START) != checksum)
            {
                /* Enter LPM4 if checksum failed */
                __bis_SR_register(LPM4_bits);
            }

            /* Check sum matched, now set calibration values */

            /* Calibrate REF */
            REFCAL1 = *(TLV_address_for_parse + TLV_CAL_REFCAL1);
            REFCAL0 = *(TLV_address_for_parse + TLV_CAL_REFCAL0);

            /* Calibrate DCO */
            CSIRFCAL = *(TLV_address_for_parse + TLV_CAL_CSIRFCAL);
            CSIRTCAL = *(TLV_address_for_parse + TLV_CAL_CSIRTCAL);
            CSERFCAL = *(TLV_address_for_parse + TLV_CAL_CSERFCAL);
            CSERTCAL = *(TLV_address_for_parse + TLV_CAL_CSERTCAL);

            /* Calibrate SD24 */
            SD24TRIM = *(TLV_address_for_parse + TLV_CAL_SD24TRIM);

            /* Clear BORIFG */
            IFG1 &= ~(BORIFG);
        }

        /* Feed the watchdog timer */
        WDTCTL = WDTPW | WDTCNTCL;

        /* Return value:
         *  1 - Perform data segment initialization.
         *  0 - Skip data segment initialization.
         */
        return 1;
    }

  • Hi Abhishek,

    You enable rx interrupts, but I do not see an ISR for the UART. If you do not have an ISR, enable rx interrupts could be causing an issue. Please try removing the line that enables rx interrupts and see if you still see the issue.

    Regards,
    Nathan
  • Hi,
    I removed the rx interrupt line but I am still facing the same issue. The problem is that while running the program from debug window, it is working fine but as soon as I terminate the debug session and power cycle the board (by removing usb and reconnecting it), I am not able to see any data on my TeraTerm serial terminal.

    Best Regards,
    Abhishek.
  • Hi Abhishek,

    Could you please elaborate on how you connected over UART to the terminal window? After reconnecting the USB, I believe teraterm will require you to reconnect to the serial port. However, your code will send out data over UART as soon as the MSP430 is powered up. Therefore, the characters will be sent out before they can be received by the terminal window, so you would never see them displayed.

    To fix this, if you are using a board with user buttons (such as a launchpad), I would suggest that you sent out the data over UART only on a button press, so that you can wait until you are properly connected to the terminal program before sending out the data. Alternatively, you could also try to verify this with a logic analyzer if you have one.

    Regards,
    Nathan
  • Hi,

    Thanks for the above reply. It is correct that first we setup the UART connection and then we should transmit characters. I implemented UART routine in ECHO mode where the controller sends data to PC only when it has received a character from PC. This worked fine and resolve my issue.

    Best Regards,

    Abhishek.

**Attention** This is a public forum