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.

Sleep/wakeup routine with MSP430 F2272

Other Parts Discussed in Thread: MSP430WARE

Hello,

I'm making an app using msp430 F2272 to measure the battery voltage each second. It means that i have to do the measurement etc. then it must go to sleep and after 1 second do the same procedure again. Here is what i will use for measurment:

TACCTL0 &= ~CCIE;
ADC10CTL1 = INCH_1 + CONSEQ_2;

ADC10CTL0 = SREF_1 + REFON + REF2_5V + ADC10ON + ADC10SHT_3 + ADC10IE; // use internal ref, turn on 2.5V ref or 1.5V, set samp time = 64 cycles

ADC10AE0 |= 0x02 ; // analog input enable for A1

ADC10CTL0 |= ENC + ADC10SC; // Enable conversions
__bis_SR_register(CPUOFF + GIE); // LPM0, ADC10_ISR will force exit


while (!(ADC10CTL0 & ADC10IFG)); // while reading is finished

adcValue = ADC10MEM;
if (adcValue>= batLow)
{
LED_GREEN();
}
__bis_SR_register(LPM0_bits + GIE); // Enter LPM0 w/ interrupt
return adcValue;

Then I'm thinking of making a sleep() function. I have added that ISR but i'm not sure how to use it exactly.

Can you give me some ideas/suggestions and also what you think about the measurement function. I will appreciate any comment.


Vasil

  • How closely does this MSP430Ware example meet your needs?

    C:\TI\ccsv5\ccs_base\msp430\MSP430ware_1_40_00_24\examples\devices\2xx\MSP430F22x2_MSP430F22x4_Code_Examples\C\msp430x22x4_lpm3.c

  • Thanks for reply,

    It is similar yes. But why watchdog timer is used here?

    and sorry but I don't understand these two statements:

    BCSCTL1 |= DIVA_2;                    // ACLK/4  
    WDTCTL = WDT_ADLY_1000;   // WDT 1s/4 interval timer

    How to configure my clock to wakes-up in 1second.

    Sorry I'm a bit new in here.

    Vasil

  • Vasil Stoimenov said:
    BCSCTL1 |= DIVA_2;                    // ACLK/4  
    WDTCTL = WDT_ADLY_1000;   // WDT 1s/4 interval timer

    The MSp header files provide several convenience constants (constants with an underscore). Those with a number usualy are an enumeration of the different ocmbiunations for a bitfield.

    So if BCSCTL has a bitfield DIVAx, then DIVA_0..DIVA_n are the different possible combinations.

    For constants with two underscores and a number, the number is a meaning. While DIVA_2 means the 3rd option, DIVA__2 means the option with the value 2 (in this case /2).

    WDT_ADLY_1000 is a combined constant. It contains the settings for a specific operation mode (and the WDT password). You can lookup the exact meaning in the msp430x2272.h header file.

**Attention** This is a public forum