Teensy 4.0 nRF24L01+ stuck on begin()

Status
Not open for further replies.

morgoth90

Member
I have a nRF24L01+ with an adapter module like this one (https://www.addicore.com/1x-nRF24L01-Adapter-p/ad279.htm)
The pins are connected:
mosi -> pin11
miso -> pin12
sck -> pin13
ce -> pin4
csn ->pin5

vcc -> 3.3 on external power supply
gnd -> gnd on external power supply

teensy gnd -> gnd on external power supply

When I try to call radio.begin() the Teensy freeze, in the serial monitor is printed only
Test connection to modules

Code:
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

#define RADIO_CE 4  
#define RADIO_CSN 5

RF24 radio(RADIO_CE,RADIO_CSN);


void setupRadio()
{
  Serial.println("Test connection to modules");

  // Setup and configure rf radio
  radio.begin();
 
  Serial.println("Init ok");
  

  // Set the TX and RX addreses in the module
  radio.openWritingPipe(pipes[0]);
  radio.openReadingPipe(1,pipes[1]);

  // radio.setDataRate( RF24_2MBPS ) ;
  // radio.setPALevel( RF24_PA_MAX ) ;
  radio.enableDynamicPayloads() ;
  radio.setAutoAck( true ) ;
  radio.powerUp() ;
  radio.startListening();

  // Print out the configuration of the rf unit for debugging

  radio.printDetails();
}

This time I'm 100% sure I've never used 5v
 
just tried without the adapter module and I'm having the same comportment

EDIT: same with another nRF24L01+ board
 
Last edited:
i think max SPI speed for nRF unit is 10mhz. T4 default SPI rate is 12.5mhz. So maybe slow down T4 SPI clock...
 
Looking into the library code I found this
Code:
_SPI.setBitOrder(MSBFIRST);
_SPI.setDataMode(SPI_MODE0);
#if !defined(F_CPU) || F_CPU < 20000000
	_SPI.setClockDivider(SPI_CLOCK_DIV2);
#elif F_CPU < 40000000
	_SPI.setClockDivider(SPI_CLOCK_DIV4);
#elif F_CPU < 80000000
	_SPI.setClockDivider(SPI_CLOCK_DIV8);
#elif F_CPU < 160000000
	_SPI.setClockDivider(SPI_CLOCK_DIV16);
#elif F_CPU < 320000000
	_SPI.setClockDivider(SPI_CLOCK_DIV32);
#elif F_CPU < 640000000
	_SPI.setClockDivider(SPI_CLOCK_DIV64);
#elif F_CPU < 1280000000
	_SPI.setClockDivider(SPI_CLOCK_DIV128);
#else
	#error "Unsupported CPU frequency. Please set correct SPI divider."
#endif

Should I force a divider?

EDIT: tested, the lib set SPI_CLOCK_DIV64
 
Last edited:
The strange fact is that with other spi boards like the sd or the 1.8 tft display everything is working and the pin 13s led is blinking.
Blink that never happens with the nRF24L01
 
With the GettingStarted example the led remain off.

I think I've found the cause, in the RF24 lib these lines dows not enable spi transactions
Code:
#if defined (SPI_HAS_TRANSACTION) && !defined (SPI_UART) && !defined (SOFTSPI)
  #define RF24_SPI_TRANSACTIONS
#endif // defined (SPI_HAS_TRANSACTION) && !defined (SPI_UART) && !defined (SOFTSPI)
Without transactions SPI.transfer is freezing so adding a #define in the lib everything is working:
Test connection to modules
Init ok
STATUS = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1 = 0xf0f0f0f0e1 0xf0f0f0f0d2
RX_ADDR_P2-5 = 0xc3 0xc4 0xc5 0xc6
TX_ADDR = 0xf0f0f0f0e1
RX_PW_P0-6 = 0x20 0x20 0x00 0x00 0x00 0x00
EN_AA = 0x3f
EN_RXADDR = 0x02
RF_CH = 0x4c
RF_SETUP = 0x07
CONFIG = 0x0f
DYNPD/FEATURE = 0x3f 0x04
Data Rate = 1MBPS
Model = nRF24L01+
CRC Length = 16 bits
PA Power = PA_MAX

Now the question is why transactions are disabled by the lib?
 
Status
Not open for further replies.
Back
Top