hello sir
I am doing small project on the lunch pad, using four channel of the ADC10 i want sample it for the continuous mode
So my problem is that sampling i can set as minimum possible using timer but i want know how much conversion time it will take and how can read as fast as possible
this is my code if any improvement is there plz answer me for it
//////////////////////////////////////////////////
#include <msp430.h>
int i;
int data[4],a,b,c,d,t,s1,s2;
signed int x,y;
int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
DCOCTL = DCO2 + DCO1 + DCO0 ; //setting for the 20Mhz
BCSCTL1 |= XT2OFF + RSEL0 + RSEL1 + RSEL2 + RSEL3 ; // Select lowest DCOx and MODx settings
for(i=5000;i<1;i--);
P1DIR |= BIT6;
// ADC confugration
ADC10CTL0 &= ~ENC; // Enable conversions
ADC10CTL0 |= SREF_1 + ADC10SHT_0 + MSC + REFON + REF2_5V + ADC10ON + ADC10IE;
ADC10CTL1 |= INCH_4 + SHS_1 + ADC10SSEL_3 + CONSEQ_3;
ADC10DTC1 = 0x04;
ADC10AE0 |= 0x1E; // 16 conversions
// ADC10SA = 0x200; // Data buffer start
// ADC10CTL0 |= ENC + ADC10SC;
// /* Configure Timer */
TACTL |= TASSEL_2 + TACLR; // ACLK, clear TAR,
TACCTL1 |= OUTMOD_2;
TACCTL0 &= ~CCIE;
TACCR0 = 10; // Do two channels, at
TACCR1 = 2; // Allow plenty of time for the
TACTL |= MC_1;
while(1)
{
// Wait if ADC10 core is active
ADC10SA = (int) &data; // Data buffer start
ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion ready
__bis_SR_register(CPUOFF + GIE); // LPM0, ADC10_ISR will force exit
d= data[0];
c= data[1];
b= data[2];
a= data[3];
t= a+b+c+d;
s1=((a+d)-(b+c));
s2=((a+b)-(c+d));
x= (s1*100/t);
y= (s2*100/t);
_NOP();
// x = (int)(((a+d)-(b+c))*100/(a+b+c+d));
// y = (int)(((a+b)-(c+d))*100/(a+b+c+d));
//
}
}
// ADC10 interrupt service routine
#pragma vector=ADC10_VECTOR
__interrupt void ADC10_ISR (void)
{
P1OUT ^= BIT6;
__bic_SR_register_on_exit(CPUOFF); // Clear CPUOFF bit from 0(SR)
}
In my application there need to sampling for the very small time like 10usec every 20hz signal with 10usce on period of the signal..so sir is there any new method which can help me more so please give me that method or above one is good enough for this work . In above method there is need to check the condition that the conversion is of ON time of the signal or else..