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 level
  • fwWaitForEvSignalOrExitFlag() : 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

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.

Examples

Microsecond Delay

// Power up the sensor and wait 850 microseconds for it to get ready
gpioSetOutput(AUXIO_O_SENSOR_POWER);
fwDelayUs(850, FW_DELAY_RANGE_1_MS);

// 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 …

Constants

Name Description
FW_DELAY_RANGE_100_MS The specified delay may be up to 100000 microseconds
FW_DELAY_RANGE_100_US The specified delay may be up to 100 microseconds
FW_DELAY_RANGE_10_MS The specified delay may be up to 10000 microseconds
FW_DELAY_RANGE_10_US The specified delay may be up to 10 microseconds
FW_DELAY_RANGE_1_MS The specified delay may be up to 1000 microseconds
FW_DELAY_RANGE_200_US The specified delay may be up to 200 microseconds
FW_DELAY_RANGE_20_MS The specified delay may be up to 20000 microseconds
FW_DELAY_RANGE_20_US The specified delay may be up to 20 microseconds
FW_DELAY_RANGE_2_MS The specified delay may be up to 2000 microseconds
FW_DELAY_RANGE_500_US The specified delay may be up to 500 microseconds
FW_DELAY_RANGE_50_MS The specified delay may be up to 50000 microseconds
FW_DELAY_RANGE_50_US The specified delay may be up to 50 microseconds
FW_DELAY_RANGE_5_MS The specified delay may be up to 5000 microseconds
FW_WAIT_SIGNAL_ADC_DONE Pulsed each time an ADC measurement is don
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_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_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

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, #range)

Delays execution of the next line by the specified number of microseconds.

To avoid busy waiting, the delay is implemented using AUX Timer 0.

Parameter value(s)

  • #delay : Delay value in microseconds
  • #range : Delay range (FW_DELAY_RANGE_N_US or FW_DELAY_RANGE_N_MS), for example FW_DELAY_RANGE_5_MS allows for a delay between 1 and 5000 microseconds

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