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

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

image

I took them to my own experiments, but this is not about that. The choice fell on this chip, since it already has its own processor based on 8051, which cannot but rejoice. I flipped through the datasheet, and it seemed that nothing arose. Like, we get it - and then we'll figure it out. And now I have the modules.

The first thing I came across 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 had invented anything before me? As it turned out, they invented it. The local MaksMS user has a publication “Programming nRF24LE1 via Raspberry PI and USBasp” , but it describes a method for working with Raspberry PI, or as an alternative to USBasp. I don’t have the first one, but I threw the second 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 collected the programmer's software for Windows, not without problems, by the way, but I did. I even managed to write down the example proposed by MaksMS'om with a blinking diode. But it was an incredible effort. All this is written in such a hurry that it simply causes disgust. Everything is raw and shaky. And it flashes quite slowly.

In general, I decided to do something about it. I have long since switched to the brainchild of STM and I have quite a lot of scarves with the STM32F103 process. I decided to try to invent a bicycle. Based on the example of DFU from the STM USB FS library package . For this example comes a smart programming utility and driver.



The screenshot above shows that in addition to the Internal Flash processor, there are 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. Of course, I had to dodge and “promote” it already at 0x14000000, but I think in a particular case it doesn’t matter.



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

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

second question: “What is the maximum speed I can work with with 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 processor frequency is 72MHz. So far I'm happy, everything is faster than USBasp.

That’s all, it seems. Hope this helps someone.

Oh yes! I 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 here.

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

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

Also popular now: