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

MSP430F5529 2 ADC12MEM Registers

$
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,

I dont know how to use  CSTARTADD and ADC12CONSEQ_3(what should be the value of  "adc12conseq" as am using 2 channels from p6.0 and p6.4)

please assist me regarding my doubts and see my code ...........as i DINT GET PROPER SUPPORT inmy old thread so am openig new thread........

and no where in texas standard programs it is not given how to use CSTARTADD.please see the code and do some modification.

#include <msp430.h>
int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
ADC12CTL0 = ADC12SHT02 + ADC12ON + ADC12MSC; // Sampling time, ADC12 on
ADC12CTL1 = ADC12SHP+ADC12CONSEQ_3; // Use sampling timer, repeated sequence
ADC12MCTL0 = ADC12INCH_0; // ref+=AVcc, channel = A0
ADC12MCTL1 = ADC12INCH_4; // ref+=AVcc, channel = A1
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
}

thank you.


Viewing all articles
Browse latest Browse all 21951

Trending Articles



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