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.

CCS/MSP430F5132: Problem to wake up controller from LPM4 with comparator (change to Problem to go into LPM4 sleep mode)

Part Number: MSP430F5132
Other Parts Discussed in Thread: TIDA-00476, , MSP-FET

Tool/software: Code Composer Studio

I'm working on a solarcharger based on TIDA-00476  with this source en other examples  The software should be ok now.
For now I have one problem, If the battery voltage is lower then 11V  I init the comparator en put the controller in LPM4.

But I never can wakeup the controller again and I'm sure everything is ok?   I measure the pin en when I change the solar panel voltage
I can measure this on the pin. I also put the pin on min en max level but the comparator/ interrupt is not working.
I checked everyting (I think) in the datasheet so for me its complete.

This is where the battery is below 11V:


                    if (Battery_Voltage < BATTERY_MIN_VOLTAGE)  {// BV < 11v

                        Turn_Off_Boost_Stage();
                        LOAD_DISABLE;

                        init_Comparator_System_Reset();
                        __bis_SR_register(LPM4);

                    }




Init Comparator:

void init_Comparator_System_Reset(void) {

    System_reset_Mode_ON = 1;
    Load_Monitor_Mode_ON = 0;

    // clear all registers
    CBCTL0 = CBCTL1 = CBCTL2 = CBCTL3 = CBINT = 0;

    CBCTL0 |= CBIPEN + CBIPSEL_0;             // Enable V+, input channel CB0
    CBCTL1 |= CBPWRMD_1;                      // normal power mode
    CBCTL2 |= CBRSEL;                         // VREF is applied to -terminal

    CBCTL3 |= BIT0;                           // Input Buffer Disable @P1.0/CB0

    // #define CBREF1_10 (0x0A00)  /* Comp. B Int. Ref.1 Select 2 : 11/32 */
    CBCTL2 |= CBRS_1 + CBREF1_10 + CBREF0_10; // VCC applied to R-ladder; to be set after calculation

    __delay_cycles(7500);                     // delay for the reference to settle

    //TI recommends clearing CBIFG after configuring the comparator for proper interrupt behavior during operation.

    CBINT &= ~(CBIFG + CBIIFG);               // Clear any errant interrupts
    CBINT |= CBIE;                            // Enable CompB Interrupt on rising edge of CBIFG (CBIES=0)
    CBCTL1 |= CBON;                           // Turn On ComparatorB
}




// Comp_B ISR - FOR SYSTEM RESET AND OVERCURRENT PROTECTION


#pragma vector=COMP_B_VECTOR


__interrupt void Comp_B_ISR(void) {

    if (Load_Monitor_Mode_ON) {

        TURN_OFF_BOOST_STAGE;
        LOAD_DISABLE;
        Load_On = 0;

        OC_Triggered = 1;
        OC_Triggered_Counter = 0; //Take action for over current protection by setting a flag
    }
    else if (System_reset_Mode_ON) {

      PMMCTL0 |= PMMSWBOR;        // Software brownout reset. Setting this bit to 1 triggers a BOR. This bit is self clearing.
//    PMMCTL0 |= PMMSWPOR;        // Software power-on reset. Setting this bit to 1 triggers a POR. This bit is self clearing.
    }

    CBINT &= ~CBIFG;              // Clear Comp_B output interrupt flag //als hij hier komt is er altijd een interrupt
}

What do I have forgot?

  • Hi,

    I do not see anywhere in your code where you are trying to wake the device up from LPM4. Could please describe or show how you do this?

    Regards,
    Nathan
  • Hi Nathan,

    I thought that with a BrownOut reset he's also exit the LPM4?

    With the TI examples its not clear to me.

    In the datasheet it looks clear to me:

    regards,

    Rob Keij

  • When I look in the msp430f5132.h file  I see that the command use for entering the LPM4 in some examples looks not ok.

    and refering to the datasheet I have to use:

                           __bis_SR_register(LPM4_bits + GIE);  // Enter LPM4 with interrupts enabled

    and not        __bis_SR_register(LPM4);    (what i found in some examples)

    /* Low Power Modes coded with Bits 4-7 in SR */
    
    #ifdef __ASM_HEADER__ /* Begin #defines for assembler */
    #define LPM0                   (CPUOFF)
    #define LPM1                   (SCG0+CPUOFF)
    #define LPM2                   (SCG1+CPUOFF)
    #define LPM3                   (SCG1+SCG0+CPUOFF)
    #define LPM4                   (SCG1+SCG0+OSCOFF+CPUOFF)
    /* End #defines for assembler */
    
    #else /* Begin #defines for C */
    #define LPM0_bits              (CPUOFF)
    #define LPM1_bits              (SCG0+CPUOFF)
    #define LPM2_bits              (SCG1+CPUOFF)
    #define LPM3_bits              (SCG1+SCG0+CPUOFF)
    #define LPM4_bits              (SCG1+SCG0+OSCOFF+CPUOFF)
    
    #include "in430.h"
    #include <intrinsics.h>
    
    #define LPM0      __bis_SR_register(LPM0_bits)         /* Enter Low Power Mode 0 */
    #define LPM0_EXIT __bic_SR_register_on_exit(LPM0_bits) /* Exit Low Power Mode 0 */
    #define LPM1      __bis_SR_register(LPM1_bits)         /* Enter Low Power Mode 1 */
    #define LPM1_EXIT __bic_SR_register_on_exit(LPM1_bits) /* Exit Low Power Mode 1 */
    #define LPM2      __bis_SR_register(LPM2_bits)         /* Enter Low Power Mode 2 */
    #define LPM2_EXIT __bic_SR_register_on_exit(LPM2_bits) /* Exit Low Power Mode 2 */
    #define LPM3      __bis_SR_register(LPM3_bits)         /* Enter Low Power Mode 3 */
    #define LPM3_EXIT __bic_SR_register_on_exit(LPM3_bits) /* Exit Low Power Mode 3 */
    #define LPM4      __bis_SR_register(LPM4_bits)         /* Enter Low Power Mode 4 */
    #define LPM4_EXIT __bic_SR_register_on_exit(LPM4_bits) /* Exit Low Power Mode 4 */
    #endif /* End #defines for C */
    

  • I did a lot of tests with :

    __bis_SR_register(LPM4_bits + GIE);  // Enter LPM4 with interrupts enabled

    And it's seems to work well.......

    but changing back to :

    __bis_SR_register(LPM4);    (what i found in some examples)

    Also works now?

    But with earlyer test with discharge a battery the PCBA was not wake up if I added A solar panel voltage.

    I also did some test to be shure I was in LPM4 mode.  Without I had a current of 14,4mA  and with LPM4 on the current was 0,395mA

    so that is ok.

    So the only question for now is "Why the wakeup from LPM4  looks not so stable, do I forgot something"

    On the bench with test supplies It looks good now, but discharge a battery with real used values is 48 hours time.


    Is there something more that I have to take into account?


    Thanks for the advice,

    best regards,

    Rob Keij

  • I was busy with this problem the whole day, and the latest thing what I have found:

                           when I fast bring the battery voltage to <11V everything works fine, A good wake-up from LPM4             (LPM4 current 0,4mA)

                           When I slowly enter the <11V voltage everything look fine (but it's not), He never wake up from LMP4  (LPM4 current 10ma)

    I hope someone recognizes this problem.


    The hardware is based on the TIDA-00476 

    regards,

    Rob Keij

  • Hi Rob,

    __bis_SR_register(LPM4_bits + GIE); enters LPM4 with general interrupts enabled (that is what the GIE bit is doing). So __bis_SR_register(LPM4); will work if general interrupts have already been enabled (as some of the examples do). If you have not enabled general interrupts, then your device will not be able to wake up from LPM4. Please make sure you include the GIE bit, and that should fix that problem.

    Regards,
    Nathan
  • Hi Nathan,

    Thanks for the answer, but I already did use:

      __bis_SR_register(LPM4_bits + GIE);  // Enter LPM4 with interrupts enabled 

    And that works if I switch fast to lower than 11V.

    But if I reach the <11V slow the controller is not going into sleep (I think)
    The current of the PCBA is then 10mA instead of the 0,4mA 

    So I think that I have to rename the title in "Problem to enter the LPM4 mode" 

    Regards,

    Rob Keij

  • Hi Rob,

    First could you check the registers in CCS when the program should be in LPM4 to see if the correct bits are set? If they are, then it is possible that that extra current is being drawn from something else. Could you explain your setup so we can see if something else might be causing this issue?

    Regards,
    Nathan
  • Hi Nathan,

    Everyting is working ok  "if" I bring fast the battery voltage <11V   but in real time the voltage is going slow <11V
    I cant see/find someting is wrong with the hardware. 
    Please check this software if there is anyting stupid in it???
    I read the datasheet over and over but I can't find anything wrong.

    If the software looks ok I think its time to give up and the LPM4 isn't working for me so this type of Solar charger is useless.

    // If battery voltage is <11V I init the comparator, go to sleep (LPM4)  and wait for the solar panel voltage >15V 
    // when I fast bring the battery voltage to <11V everything works fine, A good wake-up from LPM4         (LPM4 current 0,4mA)
    // When I slowly enter the <11V voltage everything look fine (but it's not), He never wake up from LMP4  (LPM4 current 10ma)
    
    void init_Comparator_System_Reset(void) {
    
        System_reset_Mode_ON = 1;
        Load_Monitor_Mode_ON = 0;
    
        
        Turn_Off_Boost_Stage();               // PW_L en PW_H laag (No PWM drive)
        Deinit_TimerD_BOOST();                // deinit Boost timer
        LOAD_DISABLE;                         // Disable load
        Present_State = START_STANDBY_STATE;
     
        
        CBCTL0 = CBCTL1 = CBCTL2 = CBCTL3 = CBINT = 0; // clear all registers
    
        CBCTL0 |= CBIPEN + CBIPSEL_0;             // Enable V+, input channel CB0
        CBCTL1 |= CBPWRMD_1;                      // normal power mode
        CBCTL2 |= CBRSEL;                         // VREF is applied to -terminal
    
        CBCTL3 |= BIT0;                           // Input Buffer Disable @P1.0/CB0
    
        // #define CBREF1_10 (0x0A00)  /* Comp. B Int. Ref.1 Select 2 : 11/32 */
        CBCTL2 |= CBRS_1 + CBREF1_10 + CBREF0_10; // VCC applied to R-ladder; to be set after calculation
    
        __delay_cycles(7500);                     // delay for the reference to settle
    
        //TI recommends clearing CBIFG after configuring the comparator for proper interrupt behavior during operation.
    
        CBINT &= ~(CBIFG + CBIIFG);               // Clear any errant interrupts
        CBINT  |= CBIE;                           // Enable CompB Interrupt on rising edge of CBIFG (CBIES=0)
        CBCTL1 |= CBON;                           // Turn On ComparatorB
    
        #ifdef DEBUG
          Term_Send_Str_RP("I Initialized the comparator !!!       ",34,8);
          Term_Send_Str_RP("I'm going to sleep now                 ",35,8);
        #endif
    
    __bis_SR_register(LPM4_bits + GIE); // Enter LPM4 with interrupts enabled
    
    }
    
    
    // Comp_B ISR - FOR SYSTEM RESET AND OVERCURRENT PROTECTION
    #pragma vector=COMP_B_VECTOR
    __interrupt void Comp_B_ISR(void) {
    
        if (Load_Monitor_Mode_ON) {
    
            Turn_Off_Boost_Stage();
            LOAD_DISABLE;
            Load_On = 0;
    
            CBINT &= ~CBIFG;            // Clear Comp_B output interrupt flag
    
            OV_OC_Triggered = 1;
            OV_OC_Triggered_Counter = 0; //Take action for over current protection by setting a flag
        }
        else if (System_reset_Mode_ON) {
            CBINT &= ~CBIFG;            // Clear Comp_B output interrupt flag
            PMMCTL0 |= PMMSWBOR;        // Software brown out reset. Setting this bit to 1 triggers a BOR. This bit is self clearing.
        }
    }

  • Hi Rob,

    Have you checked the system registers to see if the device is actually in LPM4? I think there is a good chance that when you lower the voltage pass the threshold slowly, you are causing something else to be drawing higher power. Just looking at the overall power numbers does not necessarily indicate whether the device is in LPM4, especially if it part of a larger system.

    Regards,
    Nathan
  • Hi Nathan,

    Im trying to analize the system registers, but I have a problem with the debugger. 
    After I run fsclean its stil not work.  If I fix that I report what I have found.

    thanks,

    Rob 

  • I have a MSP-FET430UIF and as I can see this is not usable as debugger I mis a xml file (says the compiler)
    I'm going to order the newest MSP-FET debugger, I hope I can find the problem in a few days.......
    I let you now if I have checked the system registers...

    Thanks,

    Rob
  • Hi Rob,

    Do you have any updates on this?

    Regards,
    Nathan
  • Hi Nathan,

    thanks for your patience,

     I still can not read the registers. I have a new debugger but I can get the debugger work.  

    But....  I discover a problem in the TIDA-00476  design.  After I fixed this problem the current was always 

    to high (10mA)  I thought this must be 0.5mA   but later I read that this was in the original design 5mA.

    With the hardware correction the PCBA was always wake up from the sleep mode.  (I hope I can check the registers later)

    Thinking about the fixed problem and my measurement of 0,4 mA instead of 5mA (TIDA-00476  50mW /12V = 4.7mA)   (and my 10mA)  I changed my hardware design.
    If the Battery is lower than 11V (with load) I disable the  3.3V (A voltage from the solarpanel enables the 3.3V supply).

    At the end of next week I have the new PCB but for now I measure with my modification 0.5mA  and because I disabled the 3.3V I don't need the LPM4 sleep mode.

    This is good for the battery deep discharge protection.  but I'm still going for a good LPM3 / 4 working if the sunlight is low and the battery is empty (worst case working).


    I hope I have a update next week,

    Regards,

    Rob 

**Attention** This is a public forum