Quantcast
Channel: MSP low-power microcontroller forum - Recent Threads
Viewing all articles
Browse latest Browse all 22172

Compiler/MSP430FR2111: In the LPM3, ADC sample is abnormal on A0 Pin?

$
0
0

Part Number:MSP430FR2111

Tool/software: TI C/C++ Compiler

Good Day, I used Sequence of Channels Mode to sample A0, A1 channels. The same voltage is applied to the A0,A1 pins. However, the  sample values is different in LPM3   and the sample values is same in active mode . Why is the reason? The codes is following:

INT16U g_Result[2][164] ={0} ;  // A0 g_Result[0],A1 g_Result[1]
INT8U g_AdcCount;
INT8U g_ResutNum;
 
int main(void) 
{
    WDTCTL = WDTPW | WDTHOLD;  
    InitSystemClock();	//MCLK =8MHz, SMCLK = off ,REFO(~32768Hz) is source of  ACLK = 32768Hz
    
    P1SEL0 |= BIT0 + BIT1;
    P1SEL1 |= BIT0 + BIT1;
    PM5CTL0 &= ~LOCKLPM5; 
    
    ADCCTL0 = ADCSHT_4| ADCMSC ;                    
    ADCCTL1 = ADCSHP  | ADCSSEL_0 | ADCCONSEQ_1;    //ADCSC Trriger,Sequence of Channels Mode
    ADCCTL2 = ADCRES_1 ;                            
    ADCMCTL0 = ADCSREF_1 | ADCINCH_1;               //REF =1.5V 
    ADCIE |= ADCIE0;   
    
    PMMCTL0_H = PMMPW_H;                    
    PMMCTL2 |= INTREFEN ;                   
    while(!(PMMCTL2 & REFGENRDY)); 
    
    
    TB0CCTL0 |= CCIE;                                             
    TB0CCR0 = 7;                                  // set 244us        
    TB0CTL = TBSSEL__ACLK | MC_1 | TBCLR;  
    
    __bis_SR_register(GIE|LPM3_bits );
    
    while(1);
    
}

#pragma vector = TIMER0_B0_VECTOR
__interrupt void Timer_B (void)
{
    g_AdcCount = 1;
    if(g_ResutNum > 163)
    {
        g_ResutNum = 0;
    }
    ADCCTL0 |= ADCON| ADCENC | ADCSC;      //ADC start                            
}

#pragma vector=ADC_VECTOR
__interrupt void ADC_ISR(void)
{
    switch(__even_in_range(ADCIV,ADCIV_ADCIFG))
    {
        case ADCIV_NONE: 
            break;                              
        case ADCIV_ADCOVIFG: 
            break;             
        case ADCIV_ADCTOVIFG: 
            break;            
        case ADCIV_ADCHIIFG: 
            break;             
        case ADCIV_ADCLOIFG: 
            break;             
        case ADCIV_ADCINIFG: 
            break;             
        case ADCIV_ADCIFG:
     
            g_Result[g_AdcCount][g_ResutNum] = ADCMEM0;

            if(g_AdcCount == 0)
            {
                g_ResutNum++;
            }
            else
            {
                g_AdcCount--;
            }
           
            break;                                             
        default: 
            break; 
    }  
}

the data of A0,A1 is following:

When I change "__bis_SR_register(GIE|LPM3_bits );" to "__bis_SR_register(GIE);" ,  the CPU is always active. The samples datas is normally , the data graph :


Viewing all articles
Browse latest Browse all 22172

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>