10 years, 9 months ago.

Using nRF24L01 Module with FRDM Board

I tried using the given library with my FRDM Board by changing the pin names in the example program, but I keep getting the following error (via serial monitoring): "nRF24L01P: Unknown getTxAddress width value 0". I tried to dig deeper into the nRF24L01 library files and the getTxAddress() command, but I don't quite know what the problem is. Is it possible to use this library with the FRDM Board? Or is it not compatible due to some port masking or other reasons?

/media/uploads/harshb/error.png

EDIT: Solution Found

I did a few more searches regarding the SPI interface onboard the KL25Z. I realized two things:

  1. The SPI on the KL25z supports 8-bit wide registers, compared to the 16-bit on the other boards. The nRF24L01 library actually uses 8-bit wide registers. From the library:

nRF24L01P::nRF24L01P(PinName mosi, 
                     PinName miso, 
                     PinName sck, 
                     PinName csn,
                     PinName ce,
                     PinName irq) : spi_(mosi, miso, sck), nCS_(csn), ce_(ce), nIRQ_(irq) {

    mode = _NRF24L01P_MODE_UNKNOWN;

    disable();

    nCS_ = 1;

    spi_.frequency(_NRF24L01P_SPI_MAX_DATA_RATE/5);     // 2Mbit, 1/5th the maximum transfer rate for the SPI bus
    spi_.format(8,0);                                   // 8-bit, ClockPhase = 0, ClockPolarity = 0

So the library itself doesn't pose any issues.

2. I found that the PTD1 (the SCK pin for the one SPI interface onboard the KL25z) is actually an output to the Blue LED. This was the problem because in the example code, Led 1 and Led 2 are being used for visual feedback:

DigitalOut myled1(LED1);
DigitalOut myled2(LED2);

There are two fixes to this, the first is to simply use the Red and Green LED's instead of the Blue:

DigitalOut greenLED(LED_GREEN);
DigitalOut redLED(LED_RED);

(Note: The Blue LED will still light up because it is directly associated with the SCK pin)

The second fix is to use PTC5 instead of the default PTD1 for SCK (Not my find, credit goes to http://mbed.org/forum/bugs-suggestions/topic/4419/?page=1#comment-22056). This combined with changing the LED's was the ideal solution for me:

nRF24L01P my_nrf24l01p(PTD2, PTD3, PTC5, PTD0, PTD5, PTA13);    // mosi, miso, sck, csn, ce, irq

DigitalOut greenLED(LED_GREEN);
DigitalOut redLED(LED_RED);

Question relating to:

Thanks for sharing the solution.

posted by Martin Kojtal 02 Jul 2014

Hello,

I am working on a project where I would like to use nRF24L01 with FRDM-KL46Z48M board.. However I am a bit confused about which mbed pins to connect to the nRF24L01 pins ?

What should be the proper update for the pins in this line in order to get the code working as the freedom board does not have p5, p6, p7, p8, p9, p10 pins ?

nRF24L01P my_nrf24l01p(p5, p6, p7, p8, p9, p10); mosi, miso, sck, csn, ce, irq

Can you please look at this question http://developer.mbed.org/questions/4950/Connecting-nRF24L01-to-FRDM-KL46Z48M-Boa/ ?

posted by Moustafa Alzantot 19 Oct 2014

1 Answer

9 years, 9 months ago.

thank you Harsh Bhatt for correction. It works on KL25Z!

Accepted Answer