EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

MSP430G2553 ADC triggering by Timer A

Started by nikolanikolovvv December 16, 2012
I want to trigger ADC10 of msp430G2553 from timer A without interrupt ,but my code doesn't make conversation...

The sampling rate is 0.2Hz i want to take one sample every 5 seconds and store 100 samples in RAM memory.

#include // Header file for this device
#include
#include
#define LED0 BIT0
#define LED1 BIT6
#define NSAMPLES 100
//ADC conversion result array
unsigned int value[NSAMPLES];
unsigned int result=0;
void ConfigureAdc(void)
{
WDTCTL = WDTPW + WDTHOLD;

P1SEL|=BIT5;
P1SEL2|=BIT5;
ADC10CTL1 = INCH_5 + ADC10DIV_0 + SHS_1 + ADC10SSEL_3 + CONSEQ_2 ;
ADC10CTL0 = SREF_0 + ADC10SHT_3 + MSC + ADC10ON ; //Vcc & Vss as reference..
TACTL=TASSEL_2 + MC1;
TACCR0= 0xFFFF;
TACCR1= 0x7300;

TACCTL0=OUTMOD_7;

ADC10AE0 |= BIT5; //P1.5 ADC option
ADC10DTC0C10CT;
ADC10DTC1|=NSAMPLES;
}
void main(void) {

P1DIR |= LED0 + LED1;

P1OUT &= ~(LED0 + LED1);

ConfigureAdc();

for(;;)
{
__delay_cycles(1000);

ADC10SA=(unsigned short) value;
// Sampling and conversion start
if (value[5]>511)
{
P1OUT &= ~(LED0 + LED1);
P1OUT |= LED1;
}
else
{
P1OUT &= ~(LED0 + LED1);
P1OUT |= LED0;}
}
}

Beginning Microcontrollers with the MSP430


The 2024 Embedded Online Conference