Tool/software: TI-RTOS
Morning,
We are currently experiencing problems with our custom board CC2640F128. We are attempting to capture analogue signals from a light sensor and several other sensors. The light sensor is the most critical one to get working so I will focus on that for now.
The code is based on the analogue light sensor example provided for the Launchpad in sensor controller studio. We simply change the pin to our light sensor pin and there is an if statement after the value has been retrieved which decides whether or not to raise a flag based on a threshold. Within out main program the program waits on this flag. When we run this program in sensor controller studio and graph it we can see that the sensor is working. The problem is that it often misses a the light sensor dropping below the threshold. It can maybe detect the drop below the threshold once every 15 times. We can see that the sensor is sampling quick enough to capture the whole event of the sensor dropping below the threshold but looks like it sometimes is not capturing this data...
1) Is the sensor core going into standby?
2) is the sampling rate not fast enough?
3) any advice on how to get this working?
After finding this problem we reverted back to using the ADC straight from the program. We simply measure the ADC in a while loop until it senses the drop below the threshold. This method does prove to be reliable enough to catch the drop below threshold but another problem arises. The device never seems to be able to go into standby mode, drawing around 200uA. When using sensor controller studio we were drawing around 20uA. We followed the example posted by Svendbt using the power constraints they provided. We also tried turning the clocks off after we have finished sampling. I assume that the ADC is not turning off as I think I read that the ADC core consumes around 200uA.
1) is there a command to turn off the ADC core?
2) the device consumes 200uA from startup without trying to access the ADC, does the ADC need to be initialised for low power?
Sensor controller studio code:
// Enable the ADC
adcEnableSync(ADC_REF_FIXED, ADC_SAMPLE_TIME_2P7_US, ADC_TRIGGER_MANUAL);
// Sample the light sensor
for (U16 n = 0; n < PIN_COUNT; n++){
//adcEnableSync(ADC_REF_VDDS_REL, ADC_SAMPLE_TIME_2P7_US, ADC_TRIGGER_MANUAL);
// select ADC input
adcSelectGpioInput(cfg.pAuxioAAnalogIn[n]);
// sample pin and store ADC value
adcGenManualTrigger();
adcReadFifo(state.ADCinternal[n]);
//adcFlushFifo();
//adcDisable();
}
if (input.LowHigh == 1) {
if (state.ADCinternal[3] < 1000) {
output.ADC[3] = 1;
}
} else if (input.LowHigh == 0) {
if (state.ADCinternal[3] > 1000) {
output.ADC[3] = 1;
}
}
fwScheduleTask(1);
Application ADC code:
static uint32_t adcSample(uint32_t PinToSample)
{
int SampleCount;
/* enable the clocks used for the ADC and power domains */
AUXWUCClockEnable(AUX_WUC_MODCLKEN0_ANAIF_M|AUX_WUC_MODCLKEN0_AUX_ADI4_M);
/* select the ADC pin */
AUXADCSelectInput(PinToSample);
/* Set up ADC */
AUXADCEnableSync(AUXADC_REF_FIXED, AUXADC_SAMPLE_TIME_2P7_US, AUXADC_TRIGGER_MANUAL);
/* Disallow STANDBY mode while using the ADC */
Power_setConstraint(Power_SB_DISALLOW);
for (SampleCount = 0; SampleCount < 2; SampleCount++)
{
/* Trigger ADC sampling */
AUXADCGenManualTrigger();
/* Wait in IDLE until done */
Semaphore_pend(ADChandle, BIOS_WAIT_FOREVER );
}
/* Disable ADC */
AUXADCDisable();
/* Allow STANDBY mode again */
Power_releaseConstraint(Power_SB_DISALLOW);
/* enable the clocks used for the ADC and power domains */
AUXWUCClockDisable(AUX_WUC_MODCLKEN0_ANAIF_M|AUX_WUC_MODCLKEN0_AUX_ADI4_M);
return tempAdcSample;
}
Any help with getting the sensor controller to run in low power mode whilst sampling at reasonable rate would be much appreciated.
Cheers,
Matt