📜 ⬆️ ⬇️

CC1101 running a PIC controller or building a peer-to-peer network for a radio engineer

Prehistory

Some time ago, I participated in the design of a single data collection network. The network used the 869 MHz band and the SimpliciTI protocol. By its structure, the network was essentially peer-to-peer with the central node of data accumulation. However, the network was also provided with the option of data retransmission, although it was rather an auxiliary one.

It didn’t go further than the prototypes, although the case was very serious, right up to EMC certification.
One of the reasons for the failure was that the staff programmer failed to fully master the control of the CC1101 .

The thing is, the SimpliciTI package, taken from Texas Instruments, already has some default settings. These settings are far from optimal for the task of rarely collecting data (once a month) on a network that is located in a house with reinforced concrete walls, and is also affected by interference from various sources.
')
From the very beginning it was clear that the parameters should be, say, such, and not such. To set the parameters in the CC1101 there are a number of registers. This is all described, somewhat confused, but in the end, after some effort, it is mastered.

And so SmartRF Studio is taken, the necessary parameters are set in it, checked. After successful verification, these parameters would need to be transferred to real hardware. To do this, an application using SimpliciTI makes settings at the beginning of the program.

But it was not there! After a successful start, somewhere on some function from the SimpliciTI package, a rollback occurs to the parameters that were set by the developers of the package. And the programmer never found where this is going. In particular, it never managed to launch packets with a fixed length and FEC. And without the latter, the operation of the system in terms of signal fading and interference is almost impossible.

Naked CC1101 with PIC

The CC1101 has a built-in controller, so it can be controlled with the help of a quite clear command system via the SPI interface.

There was an idea, but what if you use the capabilities of the CC1101 itself in its pure form? Of course, it was not about creating something like One-Net, but about some elementary tools for building a peer-to-peer network with full use of the capabilities of the CC1101 chip.

Since the standard radio engineer is for the most part far from programming controllers, the PIC platform was chosen, since for these controllers there is such a language as PICBASIC .

I don’t know if C is taught today for radio engineers, but earlier they taught BASIC exactly, and it’s not a question to study it. Of course, TCP / IP cannot be written on BASIC, but simple actions like sending something somewhere to an address or accepting something, and even more so, this language perfectly describes reading registers through SPI. And the entire dialogue with CC1101 is a continuous exchange on SPI with registers and nothing else!

Practical implementation

Such a board based on PIC18F2455 was assembled.

image

It must be said that this prototype was assembled only to check the quality of communication when changing the parameters of the radio channel, so there are no interface connectors for connecting any sensors or other external devices. As can be seen in the picture, there are:
- indicator LED (2 color);
- sound emitter;
- 32768 Hz quartz for a real-time clock;
- USB interface;
- chip antenna;
- battery rechargeable from USB.

The scheme is presented here .

The circuit does not have a power switch, the antenna is shown conditionally.

This post does not provide a complete program, but it did not use absolutely all the features of the CC1101.

In particular, the WOR mode was not involved. The standby mode with the signal presence check was implemented directly with the PIC18F2455 and the real-time timer.

The main program is, of course, the exchange of SPI. On the other hand, when receiving, an interrupt to start processing should be triggered. An interrupt by the presence of a received packet is triggered by a GDO0 signal, appropriately configured. In order not to complicate the interrupt handler, the exchange over SPI is made in the polling variant based on the example presented here .

The main block of routines for managing the CC1101 via SPI is as follows:

wt_rd_reg:
'Read / Write Register
'
CS =% 0
pauseus 300
SSPBUF = NOW
Go clear
a [0] = SSPBUF 'read the first byte
SSPBUF = DAT '
Go clear
a [1] = SSPBUF 'read second byte
CS =% 1
return

wt_rd_fifo:
'Read-write FIFO
'
SSPBUF = DAT
Go clear
d [i] = SSPBUF 'read response byte
return

sndstrobe:
'Send control strobe to CC1101
'
CS =% 0
pauseus 300
SSPBUF = NOW
Go clear
a [0] = SSPBUF 'read the first byte
pauseus 800
SSPBUF = SNOP 'empty
Go clear
a [1] = SSPBUF 'read second byte
CS =% 1
return


let clear:
IF SSPIF = 0 Then let clear 'wait for SPI interupt flag
PauseUs 25 '25uS fudge factor
SSPIF = 0 'reset flag

Here:
NOW is the current command,
DAT - current data
d [i] - an array for storing data from a FIFO, cannot be less than the length of a FIFO,
CS - chip select.

Pauses are set experimentally. It is possible that other delays will require different delays or they can be significantly reduced.

For command codes you need to look at the basic description .

Register values ​​were recorded in the EEPROM PIC18F2455, from where they were read as needed, and the address in the EEPROM corresponds to the register address, which makes it easy to load the necessary values ​​and always check the settings.

Practical results

After the program was written, to the great joy it turned out that ALL functions could be started, including hardware filtering, whitening, FEC, etc. etc. Transfer of packages went from a half-kick.

The main thing is that it is clearly understood where a parameter changes, and how it happens, and what to do with it, and how to apply it. Using PICBASIC, everything is clear to the radio engineer without any knowledge of the C language and special skills in writing embedded applications.

There was no goal to lay out the program (s) in full. If it is interesting, it can be posted, but not on this site. Actually, if it is burningly interesting, then you can even organize something like a library.

References used

1. CC1101, all documentation
2. SmartRF Studio
3. Microengineering Labs, company website
4. CC1101_Tester, electrical circuit diagram
5. SPI, management in PICBASIC
6. CC1101, datasheet

Source: https://habr.com/ru/post/224521/


All Articles