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

Forum Post: msp430f5529 with ADC12MEM

$
0
0
Dear sir, I want to use two channels for ADC input and am storing it to ADC12MEM0 for channel 0 (p6.0) AND ADC12MEM1 for channel 4(p6.4) .I am using P6.0 as channel 1, and P6.4 as channel 2, please see my code and let me know the thing what am doing is right or not. #include int main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT ADC12CTL0 = ADC12SHT02 + ADC12ON; // Sampling time, ADC12 on ADC12CTL1 = ADC12SHP; // Use sampling timer ADC12IE = 0x01; // Enable interrupt for channel 0 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 doing some project on this pins 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){ //CAN I DO LIKE THIS BY TAKING THE SIGNAL FROM P6.4 AND STORE IT IN ADC12MEM1 P4OUT |= BIT7; // P1.0 = 0 P1OUT &=~ BIT0; P6OUT &=~ BIT1; P6OUT &=~ BIT2; P6OUT &=~ BIT3; } else{ P1OUT |= BIT0; // P1.0 = 1 P4OUT &=~ BIT7; P6OUT |= BIT1; P6OUT |= BIT2; P6OUT &=~ BIT3; } __bic_SR_register_on_exit(LPM0_bits); // Exit active CPU }

Viewing all articles
Browse latest Browse all 62388

Trending Articles



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