CC2640之協處理器Sensor Controller Studio中的COMPB

COMPB簡稱低功耗時鐘比較器Low-power clocked comparator

The COMPB peripheral is low-power clocked comparator that is updated at 32 kHz. COMPB can be used to continuously monitor slow signals and wake up the Sensor Controller from standby. Monitored signals include such as:

  • Power supply voltage
  • Analog sensor output

The COMPB positive input signal is connected to the input of the ADC peripheral.

The following reference voltages are available:

  • VDDS / 2
  • VDDS / 3
  • VDDS / 4
  • DCOUPL
  • DCOUPL / 2
  • DCOUPL / 3
  • DCOUPL / 4

An external resistor network can be used to scale the COMPB input so it matches the selected reference voltage.

The COMPB Event Trigger resource must be used to trigger Sensor Controller wake-up when the COMPB output toggles

Examples 
Initialization Code 
// Connect sensor output to COMPB
compbSelectGpioInput(AUXIO_A_SENSOR);

// Enable COMPB with reference = VDDS/2
compbEnable(COMPB_REF_VDDS_DIV2);

// The COMPB output will be valid after 10 cycles on the 32 kHz clock, so use the timer event trigger
// to wait for this. We need to round up to account for timer event trigger precision and rounding.
evhSetupTimerTrigger(0, 3, 0); // 750 us
state.initDone = 0; 
Event Handler Code 
// The first execution (triggered by the timer) must initialize the trigger level
if (state.initDone == 0) {
    compbGetOutput(state.currTriggerLevel);
    state.initDone = 1;
}

// If the COMPB output is low...
if (state.currTriggerLevel == 0) {

    ... Do something here ...

    // Setup COMPB output high as next trigger
    evhSetupCompbTrigger(0, 1, EVH_COMPB_TRIG_ON_MATCH);
    state.currTriggerLevel = 1;

// Otherwise (the COMPB output is high)...
} else {

    ... Do something here ...

    // Setup COMPB output low as next trigger
    evhSetupCompbTrigger(0, 0, EVH_COMPB_TRIG_ON_MATCH);
    state.currTriggerLevel = 0;
} 
Termination Code 
// The currently enabled COMPB or timer event trigger must be cancelled manually
evhCancelTrigger(0);

// Disable COMPB
compbDisable(); 
Constants 

Name
Description
COMPB_REF_DCOUPL
Use the DCOUPL pin as COMPB reference
COMPB_REF_DCOUPL_DIV2
Use the DCOUPL pin divided by 2 as COMPB reference
COMPB_REF_DCOUPL_DIV3
Use the DCOUPL pin divided by 3 as COMPB reference
COMPB_REF_DCOUPL_DIV4
Use the DCOUPL pin divided by 4 as COMPB reference
COMPB_REF_VDDS_DIV2
Use the VDDS pin divided by 2 as COMPB reference
COMPB_REF_VDDS_DIV3
Use the VDDS pin divided by 3 as COMPB reference
COMPB_REF_VDDS_DIV4
Use the VDDS pin divided by 4 as COMPB reference

Global Variables 
None. 
Procedures 
compbDisable 
Prototype: compbDisable() 
Disables the COMPB peripheral. 
compbEnable 
Prototype: compbEnable(intRef) 
Enables the COMPB peripheral.

When calling this procedure, the COMPB output is valid after 10 cycles on the 32 kHz clock.

This procedure must only be called when COMPB is disabled. To change COMPB configuration, call compbDisable() before re-enabling COMPB. 
Parameter value(s) 
intRef - Internal reference selection (COMPB_REF_XYZ) 
compbGetOutput 
Prototype: compbGetOutput(value) 
Returns whether the COMPB output is low (input below reference) or high (input above reference). 
Return value(s) 
value - The comparator output value, 0 if low, 1 if high 
compbSelectGpioInput 
Prototype: compbSelectGpioInput(auxio) 
Selects a GPIO pin as input for COMPB.

Note that calling this procedure also selects the same input for the ADC. 
Parameter value(s) 
auxio - External input selection (index of AUX I/O pin, 0-7) 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章