Hi,
I've been looking through the code on the forum, but I haven't found an answer to my specific problem.
I need 2 channels on the ADC10 - each one sampled at different times.
A0 - has High/Lo values for trigger
A1 - when I sample, must get 2kHz samples to analyze.
Here's my code for the A0 sampling channel - which works. How do I add in the A1 ADC10 channel?
//Initialize the ADC10 Module
/*
* Use internal ADC10 bit as sample/hold signal to start conversion
* USE MODOSC 5MHZ Digital Oscillator as clock source
* Use default clock divider of 1
*/
ADC10_init(__MSP430_BASEADDRESS_ADC10_A__,
ADC10_SAMPLEHOLDSOURCE_SC,
ADC10_CLOCKSOURCE_ADC10OSC,
ADC10_CLOCKDIVIDER_1);
ADC10_enable(__MSP430_BASEADDRESS_ADC10_A__);
/*
* Sample/hold for 16 clock cycles
* Do not enable Multiple Sampling
*/
ADC10_setupSamplingTimer(__MSP430_BASEADDRESS_ADC10_A__,
ADC10_CYCLEHOLD_16_CYCLES,
ADC10_MULTIPLESAMPLESDISABLE);
//Convert data into signed, 2's complement format
ADC10_setDataReadBackFormat(__MSP430_BASEADDRESS_ADC10_A__,
ADC10_SIGNED_2SCOMPLEMENT);
//Configure Memory Buffer
/*
* Use input A0
* Use positive reference of AVcc
* Use negative reference of AVss
*/
ADC10_memoryConfigure(__MSP430_BASEADDRESS_ADC10_A__,
ADC10_INPUT_A0,
ADC10_VREFPOS_AVCC,
ADC10_VREFNEG_AVSS);
//Enable all window comparator HI + LO interrupts
ADC10_setWindowComp(__MSP430_BASEADDRESS_ADC10_A__, tmr.sense * 2000, (unsigned int)(tmr.sense * -2000));
ADC10_enableInterrupt(__MSP430_BASEADDRESS_ADC10_A__, ADC10HIIE + ADC10LOIE);
ADC10_startConversion(__MSP430_BASEADDRESS_ADC10_A__, ADC10_SINGLECHANNEL);
And here's the interrupt routine:
//ADC10 interrupt service routine
#pragma vector=ADC10_VECTOR
__interrupt void ADC10_ISR (void)
{
switch (__even_in_range(ADC10IV,12))
{
case 0: break; //No interrupt
case 2: break; //conversion result overflow
case 4: break; //conversion time overflow
// interrupt from MIC - if higher/lower than threshold
case 6: //break; //ADC10HI
case 8: //break; //ADC10LO
tmr.tstart = timeNow;
break;
case 12: break; //ADC10IFG0
case 10: break; //ADC10IN
default:
break;
}
}
Thanks,
Mechi