Quantcast
Channel: MSP low-power microcontrollers
Viewing all articles
Browse latest Browse all 62309

Forum Post: RE: MSP430F5529 2 ADC12MEM Registers

$
0
0
Hi Clemens, see the code ,i did what you advised me and let me know for changes. thank you. #include int main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT ADC12CTL0 = ADC12SHT02 + ADC12ON + ADC12MSC; // Sampling time, ADC12 on ADC12CTL1 = ADC12SHP + ADC12CONSEQ_1; // Use sampling timer ADC12MCTL0 = ADC12INCH_0; // ref+=AVcc, channel = A0 ADC12MCTL1 = ADC12INCH_4 + ADC12EOS; // ref+=AVcc, channel = A1 ADC12IE = 0x01; // Enable interrupt ADC12IE = BIT4;// Enable interrupt for channel 4 ADC12CTL0 |= ADC12ENC; P6SEL |= 0x01; // P6.0 ADC option select P6SEL |= BIT4;// P6.4 ADC option select P6DIR |= BIT2 | BIT3 | BIT1; //for taking input for dc driver P4DIR |= BIT7; //for green led p4.7 output P1DIR |= 0x01; //for red led P1.0 output while (1) { ADC12CTL0 |= ADC12SC; // Start sampling/conversion __bis_SR_register(LPM0_bits + GIE); // LPM0, ADC12_ISR will force exit __no_operation(); // For debugger } } #pragma vector = ADC12_VECTOR __interrupt void ADC12_ISR(void) { // Vector 6: ADC12IFG0 if (ADC12MEM0 >= 0x7ff){ // ADC12MEM = A0 > 0.5AVcc? if (ADC12MEM1 <= 0x0ff){ P4OUT |= BIT7; // P1.0 = 0 P1OUT &=~ BIT0; P6OUT &=~ BIT1; P6OUT &=~ BIT2; P6OUT &=~ BIT3; /* P1OUT |= BIT0; // P1.0 = 1 P4OUT &=~ BIT7; P6OUT |= BIT1; P6OUT |= BIT2; P6OUT &=~ BIT3;*/ } } else{ P1OUT |= BIT0; // P1.0 = 1 P4OUT &=~ BIT7; P6OUT |= BIT1; P6OUT |= BIT2; P6OUT &=~ BIT3; /*P4OUT |= BIT7; // P1.0 = 0 P1OUT &=~ BIT0; P6OUT &=~ BIT1; P6OUT &=~ BIT2; P6OUT &=~ BIT3;*/ } __bic_SR_register_on_exit(LPM0_bits); // Exit active CPU }

Viewing all articles
Browse latest Browse all 62309

Trending Articles



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