In order to determine the presence of activity, IEEE 802.15.4 requires that the received signal power within the channel bandwidth can be sampled.
To prevent the channel signal from being decoded, the shortcut between the READY event and the START task should be disabled before putting RADIO in RX mode. The energy detection (ED) measurement time, where RSSI samples are averaged, is 8 symbol periods, corresponding to 128 µs. The standard further specifies the measurement to be a number between 0 and 255, where 0 indicates received power less than 10 dB above the selected receiver sensitivity. The power range of the ED values must be at least a 40 dB linear mapping with accuracy of ±6 dB. See section 6.9.7 Receiver ED in IEEE 802.15.4 for further details.
The following example shows how to perform a single energy detection measurement and convert to IEEE 802.15.4 scale.
IEEE 802.15.4 ED measurement example
#define ED_RSSISCALE 4 // From electrical specifications
uint8_t sample_ed(void)
{
int val;
NRF_RADIO->TASKS_EDSTART = 1; // Start
while (NRF_RADIO->EVENTS_EDEND != 1) {
// CPU can sleep here or do something else
// Use of interrupts are encouraged
}
val = NRF_RADIO->EDSAMPLE * ED_RSSISCALE; // Read level
return (uint8_t)(val>255 ? 255 : val); // Convert to IEEE 802.15.4 scale
}
For scaling between hardware value and dBm, see Clear channel assessment (CCA).
The mlme-scan.reqprimitive of the MAC layer uses the ED measurement to detect
channels where there might be wireless activity. To assist this primitive, a tailored mode
of operation is available where the ED measurement runs for a defined number of iterations
keeping track of the maximum ED level. This is engaged by writing the EDCNT field of the
EDCTRL register to a value different from
0, where it will run the specified number of iterations and report the
maximum energy measurement in the EDSAMPLE register.
The scan is started with the EDSTART task and the
end indicated with the EDEND event. This
significantly reduces the interrupt frequency and therefore power consumption. The following
figure shows how the ED measurement will operate depending on the EDCNT and EDPERIOD fields
of the EDCTRL register.
The scan is stopped by writing the EDSTOP task. It is followed by the EDSTOPPED event when the module has terminated.