Other Parts Discussed in Thread: MSP430F5529
Hello all,
I am working with an MSP430F5529 USB Experimenter's Board. I am using the following code snippet.
The code is successfully storing the sample values into signal_vector. I am able to display them on the LCD screen.
I would like to sample from another ADC pin, and display those conversion results simultaneously.
Would I be able to add lines to this existing code to read from multiple pins, or would I have to restructure the code entirely?
Thanks!
-Vincent
EDIT: How viable would it be to add the highlighted lines (to use P6.6 additionally)? I am trying it out now. Would there be a possibility for timing issues or other errors?
//*****************************************************************************
// Acquire signal on channel A7
//*****************************************************************************
void AcquireSignal(void)
{
unsigned char i;
// ADC configuration
ADC12CTL0 = ADC12SHT02 + ADC12ON; // Sampling time 16 cycles, ADC12 on
ADC12CTL1 = ADC12CSTARTADD_7 + ADC12SHP; // Use sampling timer
ADC12CTL1 = ADC12CSTARTADD_6 + ADC12SHP;
ADC12MCTL7 = ADC12INCH_7; // Use A7 as input
ADC12MCTL6 = ADC12INCH_6;
ADC12CTL0 |= ADC12ENC; // Enable conversions
P6SEL |= BIT7; // P6.7 ADC option select (A7)
P6SEL |= BIT6;
// Timer configuration
TA0CCTL0 = CCIE; // CCR0 interrupt enabled
TA0CCR0 = freq; // Sampling frequency
TA0CTL = TASSEL_2 + MC_1 + TACLR; // SMCLK, upmode, clear TAR
// Trigger off
trigger = 0; // Turn off trigger flag
i = 0; // Sample counter
while(i < 90)
{
__bis_SR_register(LPM0_bits + GIE); // LPM0, TimerA0 ISR will force exit
ADC12CTL0 |= ADC12SC; // Start sampling/conversion
while (!(ADC12IFG & BIT7)); // wait channel A7 EOC
while (!(ADC12IFG & BIT6));
if (trigger == 0) // If trigger flag is off
{ // check sample
if ((ADC12MEM7 >> 6) > val_level) trigger = 1; // Trigger flag is on
}
if (trigger == 1) // If trigger flag is on
{
signal_vector [i] = 54 - ( ADC12MEM7 >> 6); // Store sample
if (signal_vector [i] > 53) signal_vector [i] = 54;
if (signal_vector [i] < 10) signal_vector [i] = 10;
//store value from P6.6 in a similar fashion
i++; // Increment sample counter
}
}
TA0CTL = 0x00; // Stop TimerA0
}