Hello,
I am currently sampling the sensor1 data with a ADC channel as shown below in the code with sampling at 500Hz and sensing data after collecting 500 samples in 1 sec through uart.
#include <msp430.h>
#define Smclk 1048576u /* default frequency */
#define Size 500 /* size of result buffer */
__no_init volatile unsigned results[Size];
volatile int oldest = 0;
volatile int filled = 0;
int _system_pre_init(void)
{
WDTCTL = WDTPW | WDTHOLD;
return(1);
}
void main( void )
{
// Initialize ADC12_A to sample internal-temperature-sensor
REFCTL0 = REFMSTR + REFON;
ADC12CTL0 = ADC12SHT0_4 + ADC12REFON + ADC12ON;
ADC12CTL1 = ADC12SHS_1 + ADC12SHP + ADC12CONSEQ_2;
ADC12CTL2 = ADC12PDIV + ADC12RES_2;
ADC12MCTL0 = ADC12SREF_1 + ADC12INCH_10;
P2SEL = BIT2;
ADC12IE = ADC12IE0;
ADC12CTL0 |= ADC12ENC;
// Set up TA0CC1 to generate a 500 Hz square wave to start ADC12 conversion
TA0CCR0 = Smclk/(500) - 1;
TA0CCR1 = TA0CCR0 - 20;
TA0CCTL1 = OUTMOD_3;
TA0CTL = TASSEL_2 + MC_1;
while (1)
{
__bis_SR_register(CPUOFF + GIE);
// Do data processing here
// The oldest result is in results[oldest]
// ... ... ... ...
// ... ... ... ...
// ... ... ... ...
// This must be accomplished well within 2 msec.
// You may need to increase the core voltage and speed up MCLK
}
}
#pragma vector=ADC12_VECTOR
__interrupt void ADC12ISR(void)
{
if (oldest == 499)
{
oldest= 0;
}
else
{
oldest=oldest+1;
}
results[oldest]=ADC12MEM0;
__bic_SR_register_on_exit(CPUOFF);
}
Now, I want to read data of sensor2.The sensor1 and sensor2 will be collecting the pulse signals from different locations so I need a method to simultaneoulsy (or any other similar method) to read sensor1 and sensor2 so that I can check the variation of the pulse signals at different locations after obtaining the both.
Thanks.