Part Number: CC2640
Hi,
my requirement is to sample multiple channels (3 channels) at 500 Hz. I have the system running with manual trigger wherein the Sensor controller is called with RTCTick = 131. The resultant frequency is close to 500 Hz (but not quite).
I am putting down the implementation here.
# Init Code**************
// Schedule the first execution
fwScheduleTask(1);
# End Init Seq *********************
# Execution Code ******************
// Enable the ADC
adcEnableSync(ADC_REF_FIXED, ADC_SAMPLE_TIME_170_US,ADC_TRIGGER_MANUAL);
//Probe point pulse to check sampling rate
// Pull the GPIO High to indicate start of this sampling phase
gpioSetOutput(AUXIO_O_SAMPLING_PROBE);
for (U16 n = 0; n < SENSOR_OUTPUT_CNT; n++) {
U16 p = n;
// Select ADC input
adcSelectGpioInput(cfg.pAuxioASensorOutput[n]);
// Insert Delay to allow settling
fwDelayUs(150, FW_DELAY_RANGE_200_US);
// Sample and store the ADC value
adcGenManualTrigger();
n = output.head;
adcReadFifo(output.pSamples[n]);
utilIncrAndWrap(n, BUFFER_SIZE; output.head);
if(output.head==0){
fwGenAlertInterrupt();
}
n = p;
}
// Bring the GPIO Down to indicate end of this sampling phase
gpioClearOutput(AUXIO_O_SAMPLING_PROBE);
// Disable the ADC
adcDisable();
// Schedule the next execution
fwScheduleTask(1);
# End Execution Code
There's nothing in the Termination Code.
This code works. However, I want to get the ADC sampling using AuxTimer0 and I am unable to do it.
To start with I introduced the StartAuxTimer0(2000) in the init code, hoping that sampling would happen every 2000 us. The code got stuck moment I introduced the following statement in the execution code. Later I read that the adcEnableSync or, adcEnableAsync can't be introduced once StartAuxTimer0 has been started.
adcEnableSync(ADC_REF_FIXED, ADC_SAMPLE_TIME_170_US,ADC_TRIGGER_AUX_TIMER0);
Later I moved the adcEnableSync statement in Init routine before starting the AuxTimer0. The code ran but the ADC output was fixed and never changed with the input being provided input. I also tried out putting the StartAuxTimer0 in execution code after the adcEnableSync and stopping the AuxTimer0 at the end of the code before disabling the ADC. The code runs but clearly the sampling is not what I desire. And I do understand that the AuxTimer0 has to run continuously to get continuous train of samples and can't be started and stopped.
I have searched a lot to find the right way of implementing this but unfortunately the documentation on this topic is next to nil, Can you help me with a basic implementation of sampling using AuxTimer0, even if its for a single channel.