Delay Insertion¶
Description¶
Insert timer delays or wait for events in task code
The following types of delays are supported:
fwDelayUs()
: Waits for at least the specfied number of microseconds- CC13x0/CC26x0 uses AUX Timer 0 to wait for up to 100 milliseconds.
- CC13x2/CC26x2 and CC13x4/CC26x4 use the microsecond delay timer to wait for up to 65535 microseconds.
fwDelayInstrCycles()
: Waits for exactly the specified number of instruction cycles (1/12 microseconds each), up to 255 instruction cycles.fwWaitForEvSignal()
: Waits forever for an event signal to equal the specified levelfwWaitForEvSignalOrExitFlag()
: Waits for an event signal to equal the specified level, or for the application to set an exit flag variable (that is, any data structure member) to the specified value- Note that this procedure runs code continuously, and therefore uses more current than the other wait/delay procedures
- After the specified event level occurs there is a random delay of between 1 and 4 instructions
fwWaitForTwoEvSignals()
: Waits for one or both of two event signals to equal the specified levelsfwWaitForEvSignalUs()
: Waits for an event signal to equal the specified level, or until the specified number of microseconds have elapsed
Note that an extra delay (approximately 3 clock cycles at 48 MHz) is introduced when the System CPU switches between HF RCOSC and HF XOSC. This typically happens before and after the radio is used.
- For AUX domain hardware that runs at 24 MHz, this will cause a permanent delay
- For AUX domain hardware that runs at 2 MHz or 32 kHz, this will sometimes cause temporary jitter
Examples¶
Microsecond Delay¶
// Power up the sensor and wait 850 microseconds for it to get ready
gpioSetOutput(AUXIO_O_SENSOR_POWER);
fwDelayUs(850);
// Sample the sensor and store the ADC value
adcGenManualTrigger();
adcReadFifo(output.adcValue);
Instruction Cycle Delay¶
// Generate a 2 microsecond pulse (gpioSetOutput() and gpioClearOutput() take one instruction cycle each)
gpioSetOutput(AUXIO_O_SENSOR_POWER);
fwDelayInstrCycles(23);
gpioClearOutput(AUXIO_O_SENSOR_POWER);
Procedures Overview¶
Name | Brief description |
fwDelayInstrCycles() |
Delays execution of the next line by the specified number of instruction cycles (1/12 microseconds each). More … |
fwDelayUs() |
Delays execution of the next line by the specified number of microseconds. More … |
fwWaitForEvSignal() |
Waits for an event signal to equal the specified level. More … |
fwWaitForEvSignalOrExitFlag() |
Waits for an event signal to equal the specified level, or for the specified exit flag variable (that is, any data structure member) to equal the specified value. More … |
fwWaitForEvSignalUs() |
Waits for an event signal to equal the specified level, or until the specified number of microseconds have elapsed. More … |
fwWaitForTwoEvSignals() |
Waits for both or any one of two event signals to equal the specified levels. More … |
Constants¶
Name | Description |
FW_WAIT_SIGNAL_ADC_DONE |
Pulsed each time an ADC measurement is done |
FW_WAIT_SIGNAL_ADC_FIFO_ALMOST_FULL |
High while the ADC FIFO contains 3 or more samples |
FW_WAIT_SIGNAL_ADC_FIFO_NOT_EMPTY |
High while the ADC FIFO contains 1 or more samples |
FW_WAIT_SIGNAL_AON_BATMON_BAT_UPD |
High for two SCLK_MF clock periods when there is an update of AON_BATMON:BAT |
FW_WAIT_SIGNAL_AON_BATMON_TEMP_UPD |
High for two SCLK_MF clock periods when there is an update of AON_BATMON:TEMP |
FW_WAIT_SIGNAL_AUXIO_BASE |
AUXIO (base + index) |
FW_WAIT_SIGNAL_COMPA_OUTPUT |
Comparator A output |
FW_WAIT_SIGNAL_COMPB_OUTPUT |
Comparator B output |
FW_WAIT_SIGNAL_MCU_EV |
The event signal selected by EVENT:AUXSEL0 |
FW_WAIT_SIGNAL_PWR_DWN |
Low while any part of the system (MCU domain, AUX domain and/or JTAG) is in active mode, or VDDR recharge is in progress |
FW_WAIT_SIGNAL_SCLK_LF |
The SCLK_LF clock (32 kHz) |
FW_WAIT_SIGNAL_SYS_ACTIVE |
High while any part of the system (MCU domain, AUX domain and/or JTAG) is in active mode |
FW_WAIT_SIGNAL_TDC_DONE |
Low while a TDC measurement is in progress, high after a TDC measurement is done |
FW_WAIT_SIGNAL_TIMER0_EV |
Timer 0 event output |
FW_WAIT_SIGNAL_TIMER1_EV |
Timer 1 event output |
FW_WAIT_SIGNAL_TIMER2_EV0 |
Timer 2 event 0 output |
FW_WAIT_SIGNAL_TIMER2_EV1 |
Timer 2 event 1 output |
FW_WAIT_SIGNAL_TIMER2_EV2 |
Timer 2 event 2 output |
FW_WAIT_SIGNAL_TIMER2_EV3 |
Timer 2 event 3 output |
FW_WAIT_SIGNAL_TIMER2_PULSE |
Timer 2 narrow pulse output |
FW_WAIT_SIGNAL_VDDR_RECHARGE |
High while the system recharges VDDR |
Global Variables¶
None.
Procedures¶
fwDelayInstrCycles¶
Prototype: fwDelayInstrCycles(delay)
Delays execution of the next line by the specified number of instruction cycles (1/12 microseconds each). The delay must be in the range 1 to 255 instruction cycles.
If the specified delay is a constant, the resulting delay is exactly the specified number of instruction cycles.
If the specified delay is a variable, there is an overhead of 1 or 2 instruction cycles + RAM load instructions, if any.
Note that the delay is implemented using busy waiting, and will therefore consume more power than for example fwDelayUs()
.
Parameter value(s)¶
- delay : Delay in number of instruction cycles (1 to 255)
fwDelayUs¶
Prototype: fwDelayUs(delay)
Delays execution of the next line by the specified number of microseconds.
To avoid busy waiting, the delay is implemented using the microsecond delay timer.
The delay is independent of power modes (active and low-power) and switching between power modes.
Parameter value(s)¶
- delay : Delay value in microseconds (1-65534)
fwWaitForEvSignal¶
Prototype: fwWaitForEvSignal(signal, #level)
Waits for an event signal to equal the specified level.
Parameter value(s)¶
- signal : The event signal to wait for (FW_WAIT_SIGNAL_XYZ)
- #level : Event signal level to wait for
fwWaitForEvSignalOrExitFlag¶
Prototype: fwWaitForEvSignalOrExitFlag(signal, #level, exitFlagVar, #exitValue)
Waits for an event signal to equal the specified level, or for the specified exit flag variable (that is, any data structure member) to equal the specified value.
This allows the System CPU application to abort Sensor Controller wait conditions, for example to stop a continuously running Sensor Controller task.
Note that this procedure runs code continuously, and therefore uses more current than for example fwWaitForEvSignal()
.
After the specified event level occurs there is a random delay of between 1 and 4 instructions.
Parameter value(s)¶
- signal : The event signal to wait for (FW_WAIT_SIGNAL_XYZ)
- #level : Event signal level to wait for
- exitFlagVar : Address of the exit flag variable (use the # operator to get the address)
- #exitValue : Exit flag variable value that triggers exit
fwWaitForEvSignalUs¶
Prototype: fwWaitForEvSignalUs(signal, #level, timeout)
Waits for an event signal to equal the specified level, or until the specified number of microseconds have elapsed.
Parameter value(s)¶
- signal : The event signal to wait for (FW_WEV_SIGNAL_XYZ)
- #level : Event signal level to wait for
- timeout : Timeout value in microseconds (2-65535)
fwWaitForTwoEvSignals¶
Prototype: fwWaitForTwoEvSignals(#waitForBoth, signalA, #levelA, signalB, #levelB)
Waits for both or any one of two event signals to equal the specified levels.
Parameter value(s)¶
- #waitForBoth : 1 to wait for both event signals to equal the specified levels, 0 to wait for any one event signal to equal its specified level
- signalA : Event signal A to wait for (FW_WAIT_SIGNAL_XYZ)
- #levelA : Event signal A level to wait for
- signalB : Event signal B to wait for (FW_WAIT_SIGNAL_XYZ)
- #levelB : Event signal B level to wait for