📜 ⬆️ ⬇️

How I started working with nRF24LE or another way to program this chip

I got into the hands of the NRF24LE1E chips in a modular design with marking on the belly of the XL24LE1-D01 .
Here are these:

image

I took them for my own experiments, but this is not about that. The choice fell on this chip, since it already has its own processor based on the 8051, which is good news. I skimmed through the datasheet, and nothing seemed to cause questions. Like, we get - and we'll figure it out. And I have modules.

The first thing I encountered was how to program it? In other words - how to write firmware into it? In the datasheet there was a description of the programming procedure through the SPI port. Fine!
')
Before reinventing the wheel, I asked Google if anyone invented anything before me? As it turned out, invented. The local user MaksMS has a publication “We program nRF24LE1 via Raspberry PI and USBasp” , but it describes the method of working with Raspberry PI, or as an alternative to USBasp. I don’t have the first one, but I threw the second one into such a far corner and thought that I would never return to these AVR creations. But fate - the villain, dragged me back.

So, I found this USBasp and poured the proposed firmware into it. I assembled a programmer software for Windows, not without problems, by the way, but I collected it. I even managed to write down the example of the flashing diode offered by MaksMS. But it was worth the incredible effort. All this is written so quickly that it just causes disgust. Everything is raw and shaky. And flashing slowly enough.

In general, I decided to do something about it. I have long since moved on to the brainchild of STM and I have quite a lot of handkerchief with a percentage of STM32F103. I decided to try to reinvent the wheel. I took as an example the DFU from the STM USB FS library pack. This example comes with a smart programming utility and driver.



The screenshot above shows that in addition to the Internal Flash processor, there is also SPI and nRF. I just had a motherboard with a processor and an SPI flash soldered to it, and I decided to leave it. Well, you never know. Also added nRF as an additional memory area. It was necessary, of course, to dodge and "promappin" it already at 0x14000000, but, I think in a particular case, it is all the same.



On the DFU firmware side, this address is, of course, discarded.

I added a small “driver” to work with the nRF24LE1 chip - and, voila, you can flash the interface through the DFU. During the writing, there were some questions, such as "How long does the flash erase?" While I wait 10ms for each and read the status of the RDY and WEN bits, it takes about 3 expectations. But it was noted that if you wait for a smaller amount of time, for example, 1ms, then the write / erase operation of the flash may not end at all. I distract him or something ...

The second question: "What is the maximum speed you can work with percent on SPI?" Now the code is about the following:

SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex; SPI_InitStructure.SPI_Mode = SPI_Mode_Master; SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b; SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low; SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge; SPI_InitStructure.SPI_NSS = SPI_NSS_Soft; SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_64; SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; SPI_InitStructure.SPI_CRCPolynomial = 7; SPI_Init(SPI_SPI, &SPI_InitStructure); 

Divider 64, the main frequency of the processor 72MHz. I'm still satisfied, everything is faster than USBasp.

That seems to be all. I hope this will help someone.

Oh yes! Completely forgot to mention how to connect:

 #define SPI_SCK_PIN GPIO_Pin_13 /* PB.13 */ #define SPI_MISO_PIN GPIO_Pin_14 /* PB.14 */ #define SPI_MOSI_PIN GPIO_Pin_15 /* PB.16 */ #define SPI_CS_PIN GPIO_Pin_12 /* PB.12 */ #define SPI_PROG_PIN GPIO_Pin_10 /* PC.10 */ 

I think everything is clear.

The source code of the firmware can be found here , and now on GitHub . Eclipse project with GCC ARM plugin.

05/16/2015 + Added Git with the source of the project on the recommendation of beresovskiy

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


All Articles