Iqrf Spi: Technical Guide
Iqrf Spi: Technical Guide
Technical guide
For TR-7xD
For IQRF OS v4.02 and v4.03D
Implementation at TR
SPI signal Function
TR pin Direction
SCK Serial Clock C6 / Q6 Issued by Master
SDI Serial Data In C7 / Q7 To TR
SDO Serial Data Out C8 / Q8 From TR
–SS Slave Select C5 / Q9 Issued by Master The SPI bus with a single Slave.
Implementation possibilities:
Under DPA: There are two ways absolutely different on principle:
DPA Peripheral is intended to exchange data between the TR and a peripheral (in this case via SPI). Refer to
IQRF DPA Framework Technical guide [3], chapter Peripherals.
DPA Interface is intended to control the TR in wireless Mesh network from a higher system (in this case via SPI).
It is a channel communicating via the DPA protocol (transferring DPA messages containing so called DPA
foursome and optional data). The DPA protocol corresponds to the DM and DS bytes of IQRF SPI protocol, see
chapter Packet structure. Refer to IQRF DPA Framework Technical guide [3], chapter Interfaces. DPA Interface is
typically used at network Coordinator. However, using at network Nodes is also possible.
Under IQRF OS: Example External SPI Master shows the implementation of the Master in C language. See IQRF
Startup package [4], folder Examples/Miscellaneous.
The rest of this document refers to SPI Slave implemented in IQRF OS.
If the Slave is configured to receive data, the received byte is copied to the bufferCOM then. More bytes can be
transferred by this repeated process in single packet and stored starting from bufferCOM[0].
The TR module operates according the following Slave specification:
Then the Master must wait for at least the T2 period before sending the next byte.
The SPI status of TR is indicated by the IQRF IDE when used with related IQRF development tools (e.g. CK-USB-04A):
Master: SPI_CHECK
Slave: SPISTAT
Where:
SPI_CHECK 0x00 SPI check. Available anytime.
SPI_CMD 0xF0 Data read / write (exchanged between the Master and bufferCOM at the Slave). Available in all
SPI ready modes. See Example 1 and Example 3.
0xFA The same as 0xF0. Intended for DPA. Available in Communication mode only. For DPA data
read use 0xF0, see above.
0xF5 Get TR Module Info. Available in Communication mode only.
For IQRF OS v4.02D:
16 B must be specified to be returned. 8 B Module Info (LSB first) and 8 B dummy data is
returned.
For IQRF OS v4.03D or higher:
16 B or 32 B must be specified to be returned.
If 16 B is specified, the 8 B Module Info (LSB first) and 8 B dummy data is returned.
If 32 B is specified, the 8 B Module Info (LSB first), 8 B dummy data and 16 B IBK
(Individual Bonding Key) is returned.
For Module Info format, refer to the IQRF OS Reference guide [2], function moduleInfo() and
Example 2.
0xF3 Write data to EEPROM. Write other TR configuration parameters. Available in Programming
mode only. See TR memories handling.
0xF2 Read data from EEPROM. Read other TR configuration parameters. Available in Programming
mode only.
0xF6 Write data to EEEPROM or Flash. Read data from EEEPROM. Write HWP configuration.
Available in Programming mode only.
0xFC Verify data in Flash. Read HWP configuration. Available in Programming mode only.
0xF9 Upload from proprietary secured .IQRF file provided by IQRF producer. Available in Programming
mode only.
SPISTAT SPI status (see the table above)
PTYPE:
b7 b6 b5 b4 b3 b2 b1 b0
CTYPE SPIDLEN
Tip: IQRF IDE SPI Test provides a powerful tool for SPI communication testing, including CRC calculation and checking.
3.6.1 Example 1
Sending data between Master and Slave
From Master: 00 // SPI_CHECK
From Slave: 80 // SPI_STATUS – TR is in communication mode
.
. // Master periodically sends SPI_CHECK to get TR status
.
From Master: F0.81.69.47.00 // Now the Master requires to send data "i"
// F0 81: SPI_CMD (PTYPE = 81: DM → DS, SPIDLEN = 1)
// 69: "i" in ASCII
// 47: CRCM (F0 xor 81 xor 69 xor 5F)
// 00: SPI_CHECK added to get SPI_STATUS: CRCM OK or Error
From Slave: 80.80.30.EE.3F // 5 B answer for 5 B issued by Master
// 80 80: 2 x SPI_STATUS – TR is in communication mode
// 30: dummy - current (undefined) content of bufferCOM
// EE: checksum (81 xor 30 xor 5F)
// 3F: SPI_STATUS: CRCM is OK
.
. // Master periodically sends SPI_CHECK to get TR status
.
Reading Module Info including IBK from TR via SPI (for IQRF OS v4.03D)
From Master: 00 // SPI_CHECK
From Slave: 80 // SPI_STATUS – TR is in communication mode
The term Upload is simplifiedly used for handling contents of all TR memories in programming mode throughout this
document.
For short, the EEPROM inside MCU is called EEPROM, while the on-board serial EEPROM is called EEEPROM
throughout this document.
For memory types, refer to the IQRF OS User’s guide, chapter Memories. Depending on memory type and purpose, data
to be uploaded can be stored in files with the following extensions:
.HEX
Standard Intel HEX format INHX8M generated by the C compiler. For the description, refer to CC5X C compiler User’s
guide (included in IQRF IDE) or IQRF DPA Framework Technical guide, chapter Custom DPA Handler Code at .hex
File.
.IQRF
A proprietary encrypted text format to upload IQRF OS or DPA plug-ins.
.TRCFNG
A proprietary binary format to store and subsequently upload TR configuration. Individual parameters are encoded as
follows:
Byte[0] – Byte[31] See IQRF DPA Framework Technical guide [3], chapter HWP configuration.
Byte[32] RFPGM parameters. See Setup RFPGM and IQRF OS Reference guide [2], function
setupRFPGM(x).
Byte[33] RF band. See Select RF band, parameter DM3.
Access key and User key are not exported / imported due to security.
See IQRF IDE Help, chapter TR configuration window how to create the .TRCFNG file from IQRF IDE.
Accessible range
Memory type Size Purpose File Access
Physical Virtual Index
Standard 3A00 - 3FFF 3A00 - 3FFF – 1536 words Application program or .HEX W V
HWP .IQRF W –
Flash
Extended 2C00 - 37BF 2C00 - 37BF – 3008 words and (optionally) Custom DPA .HEX W V
handler.
Optionally also OS plug-ins .IQRF W –
Configuration 37C0 - 37DF 37C0 - 37DF – 32 words TR (OS and HWP) configuration .TRCFNG W R*
0000 - 009F F000 – F09F – 160 B Application data
EEPROM
Standard .HEX W R
00A0 - 00BF F0A0 – F0BF – 32 B Application Info
Configuration 00C0 – 00DF F0C0 – F0DF – 32 B TR (OS and HWP) configuration .TRCFNG W R*
0200 - 41FF W
EEEPROM 0000 - 3FFF 0 – 1FF 16 KB Application data .HEX
0400 - 43FF R
* Access to configuration areas are allowed by appointed methods only. Addresses dedicated to configuration (in red) are
mentioned in this table just for information where the restricted locations are placed. Access password and User key
are nor readable.
Other parts of these memories (beyond the ranges specified in the table) are dedicated to IQRF OS or DPA and not
allowed to be accessed via the SPI Upload.
Addressable
by #pragma
.
0400 0000 400
.
09FF 07FF 03F
0A00 0800 040 0600 430
. .
2BFF
. . 2C00
. . .
1. Reset TR transceiver
Set all SPI interface pins at the Master to low levels.
Switch TR power supply Off
Wait 300 ms
Switch TR power supply On
Set the idle levels to SPI interface pins at the Master, see the Slave specification.
Caution: All addresses in .HEX files generated by CC5X compiler are multiplied by two.
Therefore, when handling with memories according to all the commands described below, all addresses read from
a .HEX file must be divided by two first.
All HEX addresses mentioned below mean the resulting addresses (thus divided by two already). See the Example in
chapter Write data to EEEPROM.
Individual memory types (see below) can be uploaded in any order, with the only exception: if the .IQRF file as well as
the Access password and/or User key are to be uploaded, the .IQRF file must be uploaded sooner.
Tip: Upload the Access password and User key as the last one(s).
4.3.1 EEPROM
Virtual EEPROM addresses (0xF000 to 0xF0FF) are used in .HEX files but physical addresses (0x00 to 0xFF) are used in
Upload commands.
Caution: The method described in this chapter is the only way to upload / download TR configuration and must strictly be
observed. Direct access to memory areas dedicated to the configuration by the procedures intended for
general access to Flash or EEPROM (described above) are not possible.
Setup RFPGM
SPI_CMD = 0xF3
DM1 = 0xC1
DM2 = 0x01
DM3 = x For meaning see IQRF OS Reference guide [2], function setupRFPGM(x).
IBK readable via command Get TR module info IBK not implemented Yes
–SS to SCK (falling edge), SCK (falling edge) to –SS (period T1) T1 = 10 μs T1 = 5 μs
T2 = 30 μs (non-networking RF)
Min. delay between bytes (period T2) T2 = from 100 μs to 700 μs
T2 = 150 μs (networking RF)
Slave select deactivating between bytes (period T3 *) Necessary (T3 = min. 20 μs) Not necessary (T3 = 0)
7 Document revision
181018 Updated for IQRF OS v4.03D. IBK is readable via command Get TR module info. References to the HEX
format description added into chapter Upload / download TR memory.
180319 Chapter TR Upload revised and extended, 3 tables with mapping of memories added.
171018 Introductory section in chapter TR memories handling extended, a Tip added.
171009 Caution added to chapter TR memories handling. Example added to chapter Write data to EEEPROM.
A typo bug in the .TRCNFG file name fixed.
170823 Updated for IQRF OS v4.02D.
170810 For TR-7xD and IQRF OS v4.01 or higher. TR Upload added.
160715 A bug (Nmax) in the table on page 4 fixed.
151106 Min. delay between SPI bytes changed for networking RF communication.
150608 First release for (DC)TR-7xD
8.5 Trademarks
The IQRF name and logo are registered trademarks of IQRF Tech s.r.o.
PIC, SPI, Microchip and all other trademarks mentioned herein are property of their respective owners.
8.6 Legal
All information contained in this publication is intended through suggestion only and may be superseded by updates
without prior notice. No representation or warranty is given and no liability is assumed by IQRF Tech s.r.o. with respect
to the accuracy or use of such information.
Without written permission, it is not allowed to copy or reproduce this information, even partially.
No licenses are conveyed, implicitly or otherwise, under any intellectual property rights.
The IQRF ® products utilize several patents (CZ, EU, US)