Currently Im using ez430-rf2500 10-bit ADC to sample 2 different signals. Im using the timer A as a trigger to sample both signals at 512 samples/sec.
Isit possible to have a code to check which channels is being sampled at the moment?
TACTL = TASSEL_1 + MC_1 + TACLR; // ACLK, Clear TAR, Up Mode
TACCTL1 = OUTMOD_3; // Set / Reset
TACCR0 = 32-1; // 512 samples per second
TACCR1 = 31;
ADC10AE0 |= 0x03;
ADC10CTL0 = SREF_1 + ADC10SHT_3 + REFON + ADC10ON + ADC10IE + REF2_5V;
ADC10CTL1 = INCH_1 + SHS_1 + CONSEQ_3;
ADC10CTL0 |= ENC; // Sampling and conversion start
By declaring a global variable sample_switch, and putting it in the main by using if-statements to check which channel it’s sampling at the moment. Will it work?
#pragma vector=ADC10_VECTOR
__interrupt void ADC10_ISR(void)
{
if(sample_switch == 0)
{ sample_switch = 1; }
else
{ sample_switch = 0; }
temp = ADC10MEM;
__bic_SR_register_on_exit(LPM3_bits); // Clear CPUOFF bit from 0(SR)
}