COMPB Event Trigger

Description

Use COMPB to trigger Event Handler Code

This resource uses COMPB (low-power clocked comparator) to trigger an Event Handler Code task code block. Triggering can either occur at high or low level (no transition required) or at rising or falling edge on the COMPB output.

This can typically be used to monitor analog signals such as:

  • Power supply voltage
  • Analog sensor output

The COMPB peripheral must be enabled separately using the COMPB resource.

The trigger can be set up from within the Initialization Code , Execution Code or Event Handler Code task code blocks.

The trigger is one-shot.

Note : Enabling this resource will cause the AUX domain to run at 32 kHz (instead of having no clock) when the Sensor Controller and System CPU are in standby mode. The resulting AUX domain clock switching increases slightly the time to enter and exit standby mode for both Sensor Controller and System CPU.

Event Trigger Mapping

The CC13x0/CC26x0 chip family supports up to 1 event trigger in total per project. The Code Generator Panel displays an error message if this number is exceeded.

Access the Task Panel to map event trigger(s) to Event Handler Code task code blocks:

  • Ensure that one or more event trigger resources are enabled
  • Below these resources, select the number of simultaneous event triggers for the task
  • Map the event index(es) to Event Handler Code task code blocks. The event indexes start at 0 for each task.

While the number of event triggers and mapping of event indexes to task code blocks are static, the event indexes can be reused for different types of event triggers. For example, it is possible to alternate between a timer trigger and a GPIO trigger for one event index.

If a new event trigger is set up using an already active event index, the previously set up event trigger is cancelled.

The Termination Code must call evhCancelTrigger() for each used event index, so that the last set up event triggers do not occur after the task has been stopped.

Trigger Timing

If both Sensor Controller and System CPU are in standby mode when the COMPB event trigger occurs, the wake-up is delayed by approximately 350 us. This delay includes:

  • Vector fetch + running two instructions to trigger wake-up (at 32 kHz in standby)
  • Wake-up trigger signal propagation (at 32 kHz in standby)
  • AUX domain wake-up

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.
evhSetupTimer1Trigger(0, 3, 0); // 750 us
state.initDone = 0;

Event Handler Code A

// 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 event trigger must be cancelled manually
evhCancelTrigger(0);

// Disable COMPB
compbDisable();

Procedures Overview

Name Brief description
evhCancelTrigger() Cancels a previous call to an event trigger setup procedure (for example evhSetupGpioTrigger() ) with matching event index, including any pending Event Handler Code execution if the trigger already has occurred. More …
evhSetupCompbTrigger() Sets up the COMPB output to trigger execution of the Event Handler Code . More …

Constants

Name Description
EVH_COMPB_TRIG_ON_EDGE COMPB trigger type: Generated on transition, edge from inverse level is required
EVH_COMPB_TRIG_ON_MATCH COMPB trigger type: Generated on match, edge from inverse level is not required

Global Variables

None.

Procedures

evhCancelTrigger

Prototype: evhCancelTrigger(#evIndex)

Cancels a previous call to an event trigger setup procedure (for example evhSetupGpioTrigger() ) with matching event index, including any pending Event Handler Code execution if the trigger already has occurred.

This procedure should be called from the Termination Code if the task can be stopped by the application while an event trigger is enabled.

Parameter value(s)

  • #evIndex : Event index to be cancelled

evhSetupCompbTrigger

Prototype: evhSetupCompbTrigger(#evIndex, #level, #type)

Sets up the COMPB output to trigger execution of the Event Handler Code . The trigger is one-shot.

The trigger occurs as soon as the COMPB output matches or transitions to the selected level. The Event Handler Code then starts when the Sensor Controller is idle or in standby.

Parameter value(s)

  • #evIndex : Event index to be triggered
  • #level : The COMPB output level that shall generate the trigger (1 = high level / rising edge, 0 = low level / falling edge)
  • #type : COMPB trigger type (EVH_COMPB_TRIG_ON_MATCH to trigger immediately on match, or EVH_COMPB_TRIG_ON_EDGE to wait for a transition to the level)