Categories

Plume – Communication between the nRF and the STM32

Hi everybody,

As you may know, all the nRF that we will use in our project, will be the N51822QFAAC0. The C0 refers to an old version of Nordic SDK (4.4). However, with our eval kit, we were using SDK 5 because we had N51822QFAAG0. Our goal was to use the same chip, but PCBPool made a mistake. We have to deal with it. Yet, there are a lot of differences between these versions.  Some functionalities are only working using the new SDK.

Moreover, as explains in this post, the nRF has a 6 byte UART-buffer. But with the C0, the buffer is reduced to 1 byte. So, we have to choose an other protocol to communicate between the nRF and the STM32 using a software flow control.

Here is the frame specification I imagined to do that.

Note : This protocol that describes the frame to exchange data between our STM32F4xx and the nRF on the receiver is directly inspire from the API Frame Specification of Digi XBee module. For more information, go on Digi website.

Introduction

Our communication between the nRF and the STM32 requires that communication be done through a structured interface (data is communicated in frames in a defined order). This paper specifies how data and data responses are sent and received using a UART Data Frame.

UART data frame structure – with escape control characters

Type of message

For our system, we will send and receive only a few kind of message which will correspond to a type of data. As every type of message won’t be sent in both directions we can organize them into three categories.

STM32 > nRF

Data from the receiver coils :

  • Type of message : 0x23

  • Length : 20 bytes

nRF > STM32

Calibration data :

  • Type of message : 0xC

  • Length : 20 bytes

Sampling rate :

  • Type of message :

  • Length : 2 bytes

Both ways

 

Escape characters

When sending or receiving a UART data frame, specific data values must be escaped so they do not interfere with the UART data frame. To escape an interfering data byte, insert 0x7D and follow it with the byte to be escaped XOR’d with 0x20.

Data bytes that need to be escaped :

  • 0x7E – Frame Delimiter

  • 0x7D – Escape

  • 0x11 – ACK

  • 0x13 – Flush the nRF

ACK

When sending a frame from the STM to the nRF, we are not able to send more than 1 byte in a row, due to the buffer in the nRF. So, to deal with this problem, we have to define a software flow control ; when the nRF receive 1 byte, it sends an ACK to the STM.

CONCLUSION

The protocol is implemented on our board. We managed with Benjamin to test all the communication from the STM32 to the nRF to the computer (using a BLE dongle). It also works in the other way.

 

 

 

 

Guénolé Lallement

Twitter 

Commentaires fermés.