Part Number: SENSOR-CONTROLLER-STUDIO
My application needs to collect data from :
- Dset (analog input) every 8ms
-Battery Voltage Monitor: set alarm if the voltage input drop to 0.5V
eventually, data inputs by bluetooth communication
My system:CC2650 launchpad
1. I have followed the example given, but I am not sure whether it will continue to run over the period.
2. Can I have a date and time during input ?
3. I do not know how to set 0.5V when having comparsion
4.To have bluetooth communication, should i set UART?
Dout
//Create variable int U16 int; //Enable the input of INT gpioEnableInputBuf(AUXIO_I_INT); //Input the INT's value into int gpioGetInputValue(AUXIO_I_INT; int); if (int == 1){ //Set DSET to be high gpioSetOutput(AUXIO_XD_DSET); // Select ADC input adcSelectGpioInput(AUXIO_A_DOUT); // Enable the ADC;reference voltage is 4.7V and the sampling time is 2.7us; Timer trigger adcEnableSync(ADC_REF_FIXED, ADC_SAMPLE_TIME_2P7_US, ADC_TRIGGER_AUX_TIMER0); // Start ADC trigger timer at 12.5Hz (8ms) timer0Start(TIMER0_MODE_PERIODICAL, 24000,3); // Loop until the application sets the exit flag while (state.exit == 0) { // Wait for the next ADC sample and store it U16 n = state.head; adcReadFifo(output.pSamples[n]); // Update the head index utilIncrAndWrap(n, BUFFER_SIZE; state.head); // If ALERT interrupt generation is enabled if (state.alertEnabled == 1){ // Calculate the number of samples currently stored S16 count = state.head - state.tail; if (count < 0) { count += BUFFER_SIZE; } // If above the configured threshold ... if (count >= cfg.alertThr){ // Generate ALERT interrupt fwGenQuickAlertInterrupt(); // Disable further generation to avoid unnecessary interrupts. It will be reenabled // by the application after handling the ALERT interrupt. state.alertEnabled = 0; } if (int==0){ //clear the output on Dset gpioClearOutput(AUXIO_XD_DSET); // Generate ALERT interrupt fwGenQuickAlertInterrupt(); // Disable further generation to avoid unnecessary interrupts. It will be reenabled // by the application after handling the ALERT interrupt. state.alertEnabled = 0; } } } // Stop the ADC trigger and flush the ADC FIFO timer0Stop(); adcFlushFifo(); // Disable the ADC adcDisable(); }
Battery Voltage Monitor
// Select VDDS as input
adcSelectIntInput(ADC_INPUT_VDDS);
// Enable the ADC
adcEnableSync(ADC_REF_FIXED, ADC_SAMPLE_TIME_2P7_US, ADC_TRIGGER_MANUAL);
// Measure and store the result
adcGenManualTrigger();
U16 adcValue;
adcReadFifo(adcValue);
output.adcValue = adcValue;
// Disable the ADC
adcDisable();
// Check whether to notify the application (every time when below, once when returning above)
if (cfg.alarmEnable == 1) {
if (adcValue < cfg.alarmThr) {
output.alarm = 1;
fwGenAlertInterrupt();
} else {
if (output.alarm == 1) {
output.alarm = 0;
fwGenAlertInterrupt();
}
}
}
// Schedule the next execution
fwScheduleTask(5);