The task algorithm is divided into four types of code blocks:
- Initialization Code: Runs one time when the task is started through the task control interface
- Performs one-time hardware initialization to reduce execution time
- Sets up task data and hardware for special behavior during the first execution
- Schedules the next iteration of the Execution Code and (or) sets up an Event Handler Code trigger
- To run iterations of the Sensor Controller task, one or both of the following code blocks can be implemented:
- Execution Code: Runs each time the task is scheduled for execution (based on periodic ticks from the real-time counter (RTC))
- Executes the task algorithm, for example sampling capacitive touch buttons, simple data filtering, processing and buffering
- Alerts the System CPU application to perform data exchange or signalize events when needed (for example when an array of ADC samples is full)
- Schedules the next iteration of the Execution Code and (or) sets up an Event Handler Code trigger
- Event Handler Code: Runs one time when the trigger that was set up occurs, (for example, an edge or level on an AUX I/O pin, or after a variable delay):
- The timer trigger is typically used to run Sensor Controller tasks at irregular intervals or to follow up on actions performed by the Execution Code
- The GPIO trigger is typically used to respond to external interrupts
- Other event triggers are available, depending on the device family
- Alerts the System CPU application to perform data exchange or signalize events when needed (for example, when accelerometer data indicates movement)
- Sets up another Event Handler Code trigger, if needed
- Termination Code: Runs one time when the task is stopped through the task control interface
- Shuts down hardware left active between task iterations
- Performs final (partial) data exchange, if needed
The CC13x0 and CC26x0 device family supports one event trigger and one Event Handler Code block per project.
The CC13x2 and CC26x2 device family supports three independent event triggers and up to three Event Handler Code blocks per project.