Hi I am writing a code for MSP430F2013, I need to sample ADC every 5 minutes. ADC can be running all the time but I only need to read it every 5 minutes. I will be doing this for a period of 12 hours.
Any sugestion ?
Below is part of my code, I made a counting routine with "x" but I am not happy with this way.
while(1)
{
SD16CCTL0 |= SD16SC; // Set bit to start conversion
_BIS_SR(LPM0_bits + GIE); // Enter LPM0
P1SEL |= 0X40;
//***************************************************************************************
// 5 MINUTES SAMPLE TIME STARTS
//
CCR0 = 0xFFFF; // CCR1 COUNT VALUE FOR 5 MINUTES
TACTL = TASSEL_1 + MC_1 + ID_3; // SMCLK UP MODE
//***************************************************************************************
}
}
// Timer A0 interrup service routine
#pragma vector = TIMERA0_VECTOR
__interrupt void Timer_A (void)
{
x = x + 1;
Sample_x = Sample_x + 1;
Solar_Power = Solar_Power + Solar_Volts;
if (x == 18) // every sample is = 16s so count to 18 samples = 288s ( 4.8 minutes)
{
P1SEL &= ~ 0X40; // Turn LED ON
x = 0;
}
}