SPRADL9 February   2025 CC1310

 

  1.   1
  2.   Abstract
  3.   Trademarks
  4. 1Introduction
    1. 1.1 Sensor Controller in Building Automation
    2. 1.2 TI Devices
      1. 1.2.1 CC13x4 Wireless MCUs
      2. 1.2.2 CC26xx Wireless MCUs
  5. 2Sensor Controller
    1. 2.1 Features
    2. 2.2 Sensor Controller Power Modes
      1. 2.2.1 Active Mode
      2. 2.2.2 Low Power Mode
      3. 2.2.3 Standby Mode
      4. 2.2.4 Switching Between Power Modes
        1. 2.2.4.1 24MHz - Startup From Standby and Return to Standby Energy
        2. 2.2.4.2 2MHz - Startup From Standby and Return to Standby Energy
    3. 2.3 Power Measurement Setup
      1. 2.3.1 EnergyTrace™ Software
      2. 2.3.2 Software
      3. 2.3.3 Current Consumption Measurements
      4. 2.3.4 Hardware
  6. 3Building Automation Use-Cases and Techniques using Sensor Controller
    1. 3.1 PIR Motion Detection
      1. 3.1.1 PIR Traditional Signal-Chain
      2. 3.1.2 Capacitor-less Motion Detection Block Diagram
      3. 3.1.3 Digital Signal Processing
        1. 3.1.3.1 Hardware
        2. 3.1.3.2 Digital Signal Processing
    2. 3.2 Glass Break Detection
      1. 3.2.1 Low-Powered and Low-Cost Glass Break Block Diagram
    3. 3.3 Door and Window Sensor
    4. 3.4 Low-Power ADC
      1. 3.4.1 Code Implementation in Sensor Controller Studio
      2. 3.4.2 Measurements
    5. 3.5 Different Sensor Readings with BOOSTXL-ULPSENSE
      1. 3.5.1 Capacitive Touch
      2. 3.5.2 Analog Light Sensor
      3. 3.5.3 Potentiometer (0 to 200kΩ range)
      4. 3.5.4 Ultra-Low Power SPI Accelerometer
      5. 3.5.5 Reed Switch
  7. 4Summary
  8. 5References

Code Implementation in Sensor Controller Studio

The following describes ADC code implementation in the Sensor Controller Studio.

Start with configuring the needed data structures and task resources:

Data structures:

  • cfg
    • resolution = 8
  • output
    • value
  • state
    • isLarger
    • nextVal

Task resources:

  • Analog Pins
    • PIN_ANALOG
  • COMPA
  • Reference DAC
  • RTC-Based Execution Scheduling
  • Delay Insertion

C Code

Initialization Code:

//Select SAR ADC input pin compaSelectGpioInput(AUXIO_A_PIN_ANALOG); fwScheduleTask(1);

Execution Code:

//Enable comparator compaEnable(COMPA_PWRMODE_ANY); 

state.nextVal = 0x0080; // 1/2 VDD 

output.value = 0; //Set the reference DAC output to 1/2 VDD refdacStartOutputOnCompaRef(state.nextVal); refdacEnable(REFDAC_PWRMODE_ANY,REFDAC_REF_VDDS); 

U16 currBit = cfg.resolution; 
U16 step = 64; 

while(currBit > 0){ //Update DAC value refdacChangeOutputValue(state.nextVal); //Wait for DAC to stabilize... 
//An additional slight delay for DAC and comparator to stabilize... 
refdacWaitForStableOutput(); 

fwDelayUs(10); //Read comparator output compaGetOutput(state.isLarger); if(state.isLarger == 1){ 
state.nextVal += step; //Increase DAC value for next iteration 
}
else{ 
state.nextVal -= step; //Decrease DAC value for next iteration 
} 

step >>= 1; //Divide step by 2 
currBit -= 1; 

//Update output value 
output.value |= (state.isLarger << currBit); 
} 
refdacStopOutput(); 

compaSelectIntRef(COMPA_REF_VSS); //Disable peripherals 
refdacDisable(); 
compaDisable(); 
fwScheduleTask(1);

Termination Code:

//Disable peripherals 
refdacDisable(); 
compaDisable();