ae. How to properly configure RFM69CW wireless transceiver and transfer data?

Configuration

HopeRF RFM69CW transceiver is quite difficult to configure from scratch. PIC32MX250F128B and PIC18F26J50 SPI connections to RFM69CW schematics are here and here. Fortunately, the basic configuration is already inbuilt in to the transceiver’s microcontroller chip. The only things that we have to worry about are small changes to values of some configuration registers. Most of them are already noted in the Hoperf RFM69CW user manual (RFM69CW-V1.1.pdf) as default recommended values, the others must be set in accordance with the version of your module. For example: If you use 868 MHz module, you have to change the values of three registers that control carrier frequency:

pic.SPI1WriteReg(&H7, &HD9) ' Carrier frequency = 867,500032 MHz

pic.SPI1WriteReg(&H8, 0)

pic.SPI1WriteReg(&H9, 0)

The whole configuration procedure from VB.NET is now the following:

pic.SPI1Init()

pic.SPI1WriteReg(&H18, &H88) ' recommended value from RFM69CW user manual

pic.SPI1WriteReg(&H19, &H55) ' recommended value from RFM69CW user manual

pic.SPI1WriteReg(&H1A, &H8B) ' recommended value from RFM69CW user manual

pic.SPI1WriteReg(&H26, &H7) ' recommended value from RFM69CW user manual

pic.SPI1WriteReg(&H29, &HE4) ' recommended value from RFM69CW user manual

'Synchronisation word = AA2DD40101010101

pic.SPI1WriteReg(&H2F, &HAA)

pic.SPI1WriteReg(&H30, &H2D)

pic.SPI1WriteReg(&H31, &HD4)

pic.SPI1WriteReg(&H32, &H1)

pic.SPI1WriteReg(&H33, &H1)

pic.SPI1WriteReg(&H34, &H1)

pic.SPI1WriteReg(&H35, &H1)

pic.SPI1WriteReg(&H36, &H1)

pic.SPI1WriteReg(&H3C, &H8F) ' FIFO threshold = 15, Start condition = FIFO not empty- starts transmitting after the first byte s entered in FIFO.

pic.SPI1WriteReg(&H6F, &H30) ' recommended value from RFM69CW user manual

' carrier frequency = 867,500032 MHz

pic.SPI1WriteReg(&H7, &HD9)

pic.SPI1WriteReg(&H8, 0)

pic.SPI1WriteReg(&H9, 0)

pic.SPI1WriteReg(&H37, 0) ' fixed length packets of length = 1 byte

pic.SPI1WriteReg(&H38, 1)

pic.SPI1WriteReg(1, &H10) ' clear FIFO

pic.SPI1WriteReg(1, 4) ' set idle mode

Operation modes

Data transfer is relatively simple. There are a lot of examples on the internet for RFM69CW. There are 5 operation modes:

000 → Sleep mode (SLEEP)

001 → Standby mode (STDBY)

010 → Frequency Synthesizer mode (FS)

011 → Transmitter mode (TX)

100 → Receiver mode (RX)

If we include the two unused bits (0 and 1) that should be programmed as zero, we get the following operation modes:

00000 → Sleep mode (SLEEP)

00100 → Standby mode (STDBY)

01000 → Frequency Synthesizer mode (FS)

01100 → Transmitter mode (TX)

10000 → Receiver mode (RX)

Setting configuration register bit 6 to 1 enables listen mode from standby mode, but the listen mode can only be aborted by setting configuration bit 6 to 0 and configuration bit 5 to 1. Configuration bit 7 enables or disables sequencer to automatically change the operation mode as needed. If we are not using transmitter and receiver modes the contents of the configuration register, the available values of RegOpMode register would be:

00000000 = 0x00 → Sleep mode (SLEEP)

00000100 = 0x04 → Standby mode (STDBY)

00001000 = 0x08 → Frequency Synthesizer mode (FS)

00001100 = 0x0C → Transmitter mode (TX)

00010000 = 0x10 → Receiver mode (RX)

Transmitting and receiving data

Transmitting and receiving data is relative easy. It suffices to set the receiving RFM69CW mode RegOpMode register to 0x10 and transmitting RFM69CW mode RegOpMode register to 0xC. Now, we can start writing packets to FIFO (register address 0). Each byte is automatically transmitted from transmitting RFM69CW module FIFO to receiving RFM69CW module FIFO. So, all one has to do is to copy data to and from RFM69CW’s FIFOs.

ALSO READ:

- Packet based wireless communications

- How to get PIC18 SPI interface working?

- How to get PIC32 SPI interface working?