There are a couple of things I wasn't able to figure from the datasheet and on the web.Right now, I would like to sample data from 4 channels (let's say, A3 - A0) when a timerA.1 event occours and send them through the UART. And I would like the entire system to use interrupts instead polling.
- if I DON'T set bit 0x02 on ADC10AE0, data on channel A1 is going to be sampled or the channel, being "unabled" is skipped? So, the second question comes:
- ADC operations and UART in g2553 are mutually exclusive?
- I can't figure exactly how the SHI signal works. I mean, I wrote the code to sample a finite number of time (continuously) for a single channel. So, I set timerA registers in order to trigger acquisition on TA1CCR1 EQ1 event - and I need the signals from the timer on port 2. I thought that after setting the registers, I needed to enable the conversion operations putting ENC=1; The code is here (but I can't figure where I am wrong):
char send=0;
char pos=0;
void main(){
//clock config
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
BCSCTL1 = CALBC1_1MHZ; // Set DCO, clock @1MHz
DCOCTL = CALDCO_1MHZ;//ADC
ADC10CTL1 = INCH_0 + SHS_1 +CONSEQ_2 + ADC10SSEL_0;// timer_A.out1, continuous mode, inpout channel 0 , ACLK (tot 1KHZ)
ADC10CTL0 = ADC10SHT_0 + SREF_1 + REFON + REF2_5V + ADC10ON + ADC10IE;// 4xADC_10CLK Use reference,
TACCR0=30;
//timer A config
P2DIR|=BIT0;
P2SEL|=BIT0;
TACCTL0 &= ~CCIE; // Disable timer Interrupt
TA1CCTL0=OUTMOD_4;// toggle mode for TA.0
TA1CCR0 = 999;// @1MhzCLK it should be 500HZ
TA1CCTL1=OUTMOD_3; //set/reset mode
TA1CCR1=500; //1KHz
TA1CTL=TASSEL_2 + MC_1; //start timer, up mode.
__bis_SR_register(GIE); // interrupt enabled
ADC10AE0 |= 0x01; // P1.1 ADC10 option select
ADC10CTL0 |= ENC;
while(1){
if(send){
send=0;
pos=0;
ADC10CTL0 |=ENC;
}
}
}
#pragma vector=ADC10_VECTOR
__interrupt void ADC10_ISR(void)
{
//increase pos counter. if pos > treshold, stop adc and enter main loop.
pos++;
if(pos>5) {
ADC10CTL0 &=~ENC;
send=1;
}
}
Any hint would be VERY appreciated.
Best regards,
Luca.