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.

MSP430G2553: Watchdog timer stops the ADC conversion

Part Number: MSP430G2553

Hi,

I am facing a difficulty where after the watchdog timer expires the ADC stops working. All other parts of the code works fine but the ADC reads out 0. But after resetting the power, the ADC starts working. Also, if the watchdog timer expires again then ADC starts working.

What could be the possible reason for this?

Thanks

Nitish

  • Hi Nitish

    The WDT only can generate a PUC(power up clear) signal. It is different from POR(power on reset).

    When you reset device ,the ADC may convert a new data and working normally.

    But PUC may clear the ADCMEM register so you may find the ADC reads as 0.

    Hope this may help you.

    Best Regards

    Junkai

  • Hi

    I understand that it wipes out the ADCMEM but it should fill it out again with data once it has been asked to do  the ADC conversions. But even after 10-15 minutes I don't see the ADC reading other than 0. But due to same error if I make the watchdog timer to expire again, then ADC starts reading the actual values again.

    What could be the possible reason for this?

    Thanks

    Nitish

  • Hi Nitish

    You mean the first time WDT PUC the ADC read as 0(you mean ADC didn't convert), WDT PCU occur again the ADC work normally?

    could you attach your code? I may check if there is any  problem.

    Thanks

    Best Regards

    Junkai

  • Hi,

    What I meant was ADC just stops and just reads 0x00 in the buffer register storing ADC result via DMA. I got a workaround for this problem by putting ADC10SA = 0x00 before initializing the ADC. So now whenever the watchdog timer expires the ADC10SA = 0 is the first statement to be executed before initializing the ADC again (as the code starts again from the beginning after watchdog expires) and magically it started working.

    Also, is it correct to put ADC10SA = 0 as be default it is 0x0200 and in the initialization part I point it to some other memory location. Or should I avoid writing to 0x00 and just write the memory address where the flash end?

    Thanks

    Nitish

  • Hi Nitish,

    Is it convenient to post your program? Or private mail sending? So that we can analysis the problem you described, it seems that this problem is solved magically, but you may encounter other problems if we do not find the root cause.

    Best Regards

    Johnson

  • Here is the part of my code. If the P1.0 pin is puuled high to 3.3 V then it goes into the infinite loop and watchdog timer expires. You will find that the ADC stops working. But if you remove the comment from ADC10SA = 0, then even  after watchdog expires the ADC keeps working.

    #include <msp430.h> /** * main.c */ static int ADCbuf[4]; /* Array for ADC readings */ static int Values[4]; static int i = 0; void MON_Init(void); void Get_ADC_Val(void); void main(void) { WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer /* Initialize MCU */ MON_Init(); _BIS_SR(GIE); /* Enable Interrupts (ADC Op required) */ WDTCTL = (WDTPW + WDTCNTCL + 1); for(;;) { Get_ADC_Val(); if(Values[3] >= 900) { while(1); } WDTCTL = (WDTPW + WDTCNTCL + 1); } } void MON_Init(void) { DCOCTL = CALDCO_12MHZ; BCSCTL1 = CALBC1_12MHZ; BCSCTL2 = 0x00; //ADC10SA = 0; ADC10CTL0 &= ~ENC; ADC10AE0 |= 0x0F; ADC10CTL0 = SREF_0|ADC10SHT1|ADC10SR|MSC|ADC10ON; ADC10CTL1 = INCH_3|ADC10DIV_0|ADC10SSEL_3|CONSEQ_1; ADC10DTC0 = ADC10CT; ADC10DTC1 = 0x04; ADC10SA = (unsigned) ADCbuf; ADC10CTL0 |= ENC + ADC10SC; while (ADC10CTL1 & ADC10BUSY) {;} } void Get_ADC_Val(void) { ADC10CTL0 |= (ENC + ADC10SC); while (ADC10CTL1 & ADC10BUSY) {;} for(i=0; i<4; i++) { Values[i] = ADCbuf[i]; } }

  • Hi Nitish,

    I made a little modification to your code, you can experiment it.

    #include <msp430.h>
    
    /**
     * main.c
     */
    static int ADCbuf[4];        /* Array for ADC readings */
    static int Values[4];
    static int i = 0;
    void MON_Init(void);
    void Get_ADC_Val(void);
    
    void main(void)
    {
        WDTCTL = WDTPW | WDTHOLD;   // stop watchdog timer
        /* Initialize MCU */
        MON_Init();
        _BIS_SR(GIE);               /* Enable Interrupts (ADC Op required) */
        WDTCTL = (WDTPW + WDTCNTCL + 1);
    
        for(;;)
        {
            Get_ADC_Val();
    //        if(Values[3] >= 900)
    //        {
    //            while(1);
    //        }
            WDTCTL = (WDTPW + WDTCNTCL + 1);
        }
    
    }
    
    void MON_Init(void)
    {
        DCOCTL = CALDCO_12MHZ;
        BCSCTL1 = CALBC1_12MHZ;
        BCSCTL2 = 0x00;
    
        //ADC10SA = 0;
        ADC10AE0 |= 0x0F;
        ADC10CTL0 = SREF_0|ADC10SHT1|ADC10SR|MSC|ADC10ON;
        ADC10CTL1 = INCH_3|ADC10DIV_0|ADC10SSEL_3|CONSEQ_1;
    
        ADC10DTC0 = ADC10CT;
        ADC10DTC1 = 0x04;
    
        while (ADC10CTL1 & ADC10BUSY)
        {;}
    
    }
    
    void Get_ADC_Val(void)
    {
        ADC10CTL0 &= ~ENC;
        while (ADC10CTL1 & ADC10BUSY) ;
        ADC10SA = (unsigned) ADCbuf;
        ADC10CTL0 |= ENC + ADC10SC;
    
        for(i=0; i<4; i++)
        {
            Values[i] = ADCbuf[i];
        }
    }
    

    Best Regards

    Johnson

  • Hi Nitish,

    I haven’t heard from you for six days, so I’m assuming you were able to resolve your issue. If this isn’t the case, please click the "This did NOT resolve my issue" button and reply to this thread with more information. If this thread locks, please click the "Ask a related question" button and in the new thread describe the current status of your issue and any additional details you may have to assist us in helping to solve your issues.

    Best Regards,

    Johnson

**Attention** This is a public forum