NRF24L01+ Send Only? (Solved)

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Mystery solved!
My socket is no good. Perhaps it is "sock it to me time?"

How very odd. Much puzzled.

I've been using these NRF24L01+ modules to send and receive data for a while, putting them is several playthings and generally having a lot of fun with them.

But today, I put one in a gadget, and it won't receive. It sends messages, but only if I don't use the autoack feature, which I usually do use. If I use autoack, the program gets stuck in the loop waiting for bits 4 or 5 in the status register.

while ((st & ((1<<5) | (1<<4)))==0) 
   st = NRFReadRegister(RG_STATUS); // Packet acked or timed out

Maybe my SPI isn't set right and MISO isn't an input? Also, if I try to read back register 0, I get 0, not 0b00111111.

void spiopen(void)
{
	SPIDir = SPIPort.DIR ;
	SPIPort.DIRCLR = (1<<SPIMI);
	SPIPort.DIRSET = (1<<SPIMO) | (1<<SPISC) | (1<<SPISS) ; // Make sure slave select is an output
	SPIC.CTRL = SPI_ENABLE_bm | SPI_MASTER_bm | SPI_MODE_0_gc | SPI_PRESCALER_DIV64_gc;
}

uint8_t spi(uint8_t val)
{
	SPIC.DATA = val ;
	while(!(SPIC.STATUS & (1<<7)));
	return SPIC.DATA;
}

I've tried setting MISO to an output and toggling it. I see the appropriate pin on the NRF module toggling. I've tried different modules from different suppliers.

Didn't find the solution while composing this message and retesting things, so I guess I'll hit submit.

I still haven't figured out how my older toys worked without flushing the tx buffer which seems to be needed on the newer ones. Shoot, "Tommy and Timmy" still talk to each other without the flush tx command

void NRFSendPacketNoAck(uint8_t *ToAddress, uint8_t *Packet, uint8_t Length)
{
	uint8_t ModeIs = NRFReadRegister(RG_CONFIG);
	NRFModeTX();		// Make sure in TX mode
	NRFSetTxAddress(ToAddress);
	NRFWriteRegister(RG_EN_AA,0);				// Disable auto ack on pipes 0 and 1

	CHIPSELECT { spi(CMD_FLUSH_TX); };

	CHIPSELECT
	{
		spi(CMD_WR_TX_PLOAD);
		for (uint8_t i = 0; i>5) & 1;
}

uint8_t NRFReceivePacket( uint8_t * Packet)
{

	if ((NRFReadRegister(RG_STATUS)&(1<<6))==0) return 0;
	CELOW ;
	CHIPSELECT
	{
		spi(CMD_R_RX_PL_WID);
		pw = spi(0);
	}

	if (pw>32)
	{
		CHIPSELECT
		{
			spi(CMD_FLUSH_RX);
		}
		NRFWriteRegister(RG_STATUS,(1<<6)) ;
		return 0;
	}

	CHIPSELECT
	{
		spi(CMD_RD_RX_PLOAD);
		for(uint8_t i = 0; i<32; i++) Packet[i] = spi(0);
	}
	NRFWriteRegister(RG_STATUS,(1<<6)) ; // Clear the RX_DR interrupt
	CEHIGH ;
	return 1;
}

void NRFInit(uint8_t pSpeed)
{
	// Set the required output pins
	CSHIGH;
	CELOW;
	_delay_ms(200);
	//for(uint8_t i = 0; i

(Who misspelt /code?)

If you don't know my whole story, keep your mouth shut.

If you know my whole story, you're an accomplice. Keep your mouth shut. 

Last Edited: Fri. Dec 6, 2013 - 03:36 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I thought it might be because I forgot to put

	PORTC.PIN4CTRL = (3<<3) ;
	PORTC.PIN5CTRL = (3<<3) ;
	PORTC.PIN6CTRL = (3<<3) ;
	PORTC.PIN7CTRL = (3<<3) ;

And I had forgotten. Well, now it doesn't send either. I suppose that might be an improvement

If you don't know my whole story, keep your mouth shut.

If you know my whole story, you're an accomplice. Keep your mouth shut. 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Was the socket confirmed to be the real cause of the problem?
If you just swapped modules around and it started working, be very careful of some compatibility issues on those cheap NRF modules.

The issue only seems to show up when using the auto-ack feature which is why I'm suspicious.

-carl

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Also shows up when trying to receive. Found it by probing signals with my trusty xminilab and a test program to twiddle the pins. On the "bottom" side of the board, I saw the signal I expected to find on the MISO line, on the module, I saw a low level 60Hz signal.

Of course, then I was able to reproduce the same symptom by playing a silly game using all 4 pwm outputs from the timer on the lower half of port c. SPI is on the upper half of port C, on this xMega.

If you don't know my whole story, keep your mouth shut.

If you know my whole story, you're an accomplice. Keep your mouth shut.