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.

MSP430G2131: Two Questions: 1: What is the "Part Number"?? ; 2: What line of code to change to change sleep time?

Part Number: MSP430G2131
Other Parts Discussed in Thread: MSP430G2553, MSP-EXP430G2ET

Tool/software:

Q1:  I have a MSP-EXP-430G2ET Development Kit. I can find NOTHING in the docs or on the board that tell me what the "Part Number" is, but this is required to ask a question here. I GUESSED the Part Number for this Question! What is the "Part Number" - or Where can I find the "Part Number"???

Q2: I have got a sample code working, but I am struggling to understand what is going on in the code, and what I need to change to make the "sleep time" longer. The code is: /home/guest/ide/default/msp430g2xx3_lpm3_vlo.c/msp430g2xx3_lpm3_vlo.c

I would like to change the "sleep time" to a longer value - let's say twice as long. I can only guess that the code that must be changed is the line '__bis_SR_register(LPM3_bits + GIE);', but cannot even guess at what value to change it to. Can someone show me how this is done?

#include <msp430.h>

int main(void)
{
BCSCTL1 |= DIVA_1; // ACLK/2
BCSCTL3 |= LFXT1S_2; // ACLK = VLO
WDTCTL = WDT_ADLY_1000; // Interval timer
IE1 |= WDTIE; // Enable WDT interrupt
P1DIR = 0xFF; // All P1.x outputs
P1OUT = 0; // All P1.x reset
P2DIR = 0xFF; // All P2.x outputs
P2OUT = 0; // All P2.x reset
P3DIR = 0xFF; // All P3.x outputs
P3OUT = 0; // All P3.x reset
while(1)
{
int i;
P1OUT |= 0x01; // Set P1.0 LED on
for (i = 8000; i>0; i--); // Delay
P1OUT &= ~0x01; // Reset P1.0 LED off
__bis_SR_register(LPM3_bits + GIE); // Enter LPM3
}
}

#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=WDT_VECTOR
__interrupt void watchdog_timer (void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(WDT_VECTOR))) watchdog_timer (void)
#else
#error Compiler not supported!
#endif
{
__bic_SR_register_on_exit(LPM3_bits); // Clear LPM3 bits from 0(SR)
}
  • Q1: MSP-EXP-430G2ET  is used for evaluate MSP430G2553, so the part number should be MSP430G2553

    Q2: 

    '__bis_SR_register(LPM3_bits + GIE);',

    this code is used to go into low power mode, the sleep time is when the watch dog timer wake up the device from the low power mode. So you can change the watch dog timer interrupt time to change the sleep time that you can change the code below

    WDTCTL = WDT_ADLY_1000; // Interval timer
  • The available choices for clock divider using the watchdog are very limited and this example uses the longest interval. You could change DIVA but that can get you at best four times the interval.

    For much longer delays, you have to put a counter into the interrupt service routine. Increment each time and wakeup after the desired number of counts.

  • Gary - What am I missing ??

    Here's the change I made:

    // WDTCTL = WDT_ADLY_1000; // Interval timer
    WDTCTL = WDT_ADLY_2000; // (modified) Interval timer
    But I got a compile error:
    [5]&gt;> Compilation failure
    [6]subdir_rules.mk:7: recipe for target 'msp430g2xx3_lpm3_vlo.obj' failed
    [7]"../msp430g2xx3_lpm3_vlo.c", line 77: error #20: identifier "WDT_ADLY_2000" is undefined
    [8]"../msp430g2xx3_lpm3_vlo.c", line 90: remark #1527-D: (ULP 2.1) Detected SW delay loop using empty loop. Recommend using a timer module instead
    [9]"../msp430g2xx3_lpm3_vlo.c", line 90: remark #1527-D: (ULP 2.1) Detected SW delay loop using empty loop. Recommend using a timer module instead
    [10]1 error detected in the compilation of "../msp430g2xx3_lpm3_vlo.c".
    [11]gmake: *** [msp430g2xx3_lpm3_vlo.obj] Error 1
    [12]gmake: Target 'all' not remade because of errors.
    I'm guessing that this is a constant - maybe it has only certain defined values??? If so, where are those listed??
  • David,

    Thanks - I finally found the 'DIVA' definitions in the 'msp430G2553.h' file (things are hard to find here methinks).

    So, I see what you meant by 4X.

    What I don't see is the interrupt service routine... what is that named & where do I find it?

    Another question is this: Do you think it would be simpler to add a RTC - or some other external wake-up source?

    Is there an example for an external wake-up source?

  • What I don't see is the interrupt service routine... what is that named & where do I find it?

    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    
    #pragma vector=WDT_VECTOR
    
    __interrupt void watchdog_timer (void)
    
    #elif defined(__GNUC__)
    
    void __attribute__ ((interrupt(WDT_VECTOR))) watchdog_timer (void)
    
    #else
    
    #error Compiler not supported!
    
    #endif
    
    {
    
     __bic_SR_register_on_exit(LPM3_bits); // Clear LPM3 bits from 0(SR)
    
    }

  • David - having some issues with the "Cloud" Studio/Dev Env... Seems the Debugger keeps failing to initialize. I don't know what the problem is - I'll reply once I get this straightened out.

  • I've no idea what's going on... after deleting the initial project, and then re-loading it:

    1. It builds OK

    2. trying to start the debugger yields a message I can't copy, but goes something like this: "Debug session initialization failed. See console for details"  BUT the console is empty

    3. so frustrating... any idea what's wrong with this? I can still compile & debug the BlinkLED example.

  • Please download Install the latest version of Eclipse® CCS

    And test the project and you can send the project  here if you have issue with it.

  • Gary,

    I appreciate your trying to help - really I do. However, there seems to be a problem with the "Eclipse CCS" that you have recommended I install - it's the same problem I encountered previously, and it's the reason I have relied upon this "Cloud CCS" solution - which now also appears to have crashed and burned!

    Here's the problem: After starting the installation, I see the following screen displayed:

     screenshot of install window

    Note that in the listing of "Unsupported Boards" is the line: MSP430G2 LaunchPad [MSP-EXP430G2]

    This is my board - at least AFAICT. My development board was bought recently, and it is marked as "MSP-EXP430G2ET". That certainly appears to be the board that is listed as an "Unsupported Board";  if I am wrong, please let me know. But I see no point in going through a large, complex software installation only to end in another failed development tool.

    another attempt to upload installer dialog screenshot

    And my apologies - I can't seem to upload the installer screenshot. I have no idea what the problem is, but I am weary of fighting your website.

  • Gary: here's the screenshot

    yet another try

    Finally able to upload the screenshot!

  • Ok, I do not use macOS, it seems you can try it on a windows PC or you can try CCS theia.

    Or you can try our new products that MSPM0 family devices that have more better peripherals and lower price than the MSP430G2 devices.https://www.ti.com/lit/an/slaae74a/slaae74a.pdf 

  • David,

    apologies for the pace of this, but I got derailed by a "CloudCCS" issue, and questions re the CCS install on my Mac.

    Anyway: I've struggled a bit to get this set up, but just earlier this evening I managed to get everything loaded into CCS (12.8):

    • msp430g2xx3_lpm3_vlo.c
    • msp430g2553.h

    and got the example running again!

    I've modified the C source, swapping DIVA_1 for DIVA_3, and now running w/ an approx 24 sec delay. But I need more delay - at least 30 minutes, preferably an hour. You mentioned a counter in the ISR; can you give some hints on how to structure that?

    I guess I should post this as a new question???  Please advise.

  • If you need help writing a simple loop...

  • Once it is marked as solved, you should start a new question.

    But to get a delay check out some of the timer interrupt examples. Generally, you can set up an interrupt for every second and increment a count, when the count reaches the number of seconds you need you set a volatile flag and reset the count.

    In the main routine, you keep testing this flag, when it changes state you do your action, and then reset the flag.

  • I'm not thin-skinned David, and I trust that you're not either... so K-My-A :)

  • Keith, thanks - that helps!  I'll try it & post a new question if I have problems.

**Attention** This is a public forum