need help about nrf24L01

I have C8051F340 with the nrf24L01.

Now the transmitter can give the TX_DS interrupt but the reciever can’t gets the RX_DR interrupt and can’t get any data in the RX FIFO. After trans TX FIFO is also empty.So i think the trans is working well.

I am able to communicate through SPI to the nrf24L01.I read Internal regs that i used and they are set right but the reciever wont recieve any bytes.

These are part of code.

trans:

void main(void)
{
	......
while(1)
	{
//		sta=SPI_Read(READ_REG+STATUS);
		if(en_send)
		{
			en_send=0;
			TX_Mode();
		}
		if(IRQ==0)
		{

			sta=SPI_RW_Reg(WRITE_REG+STATUS,0x70);	/
			SPI_Read(READ_REG+FIFO_STATUS);

			
			if(RX_DR)				
			{
				CE=0;
				SPI_Read_Buf(RD_RX_PLOAD,rx_buf,TX_PLOAD_WIDTH);
				flag=1;
			}
//			sta=SPI_Read(READ_REG+STATUS);
			
		}
	}
}

receive:

void main(void)
{
	......
	RX_Mode();
	while(1)
	{
//		sta=SPI_Read(READ_REG+STATUS);
		if(en_send)
		{
			en_send=0;
			TX_Mode();
		}
		if(IRQ==0)
		{

			sta=SPI_RW_Reg(WRITE_REG+STATUS,0x70);	/
			SPI_Read(READ_REG+FIFO_STATUS);

			
			if(RX_DR)				
			{
				CE=0;
				SPI_Read_Buf(RD_RX_PLOAD,rx_buf,TX_PLOAD_WIDTH);
				flag=1;
			}
//			sta=SPI_Read(READ_REG+STATUS);
			
		}
	}
}

initialize:

void RX_Mode(void)
{
	  CE=0;
	  SPI_RW_Reg(WRITE_REG + SETUP_AW, 0x03);
  	SPI_Write_Buf(WRITE_REG + RX_ADDR_P0, TX_ADDRESS, TX_ADR_WIDTH); 

  	SPI_RW_Reg(WRITE_REG + EN_AA, 0x00);     
  	SPI_RW_Reg(WRITE_REG + EN_RXADDR, 0x01);  
  	SPI_RW_Reg(WRITE_REG + RF_CH, 92);        
  	SPI_RW_Reg(WRITE_REG + RX_PW_P0, TX_PLOAD_WIDTH);	 
  	SPI_RW_Reg(WRITE_REG + RF_SETUP, 0x07);   
  	SPI_RW_Reg(WRITE_REG + CONFIG, 0x0f);     

  	CE = 1; 								  
}
void TX_Mode(void)
{
	  CE=0;
	
  	SPI_RW_Reg(WRITE_REG + SETUP_AW, 0x03);
	  SPI_Write_Buf(WRITE_REG + TX_ADDR, TX_ADDRESS, TX_ADR_WIDTH);    

// 	SPI_Write_Buf(WRITE_REG + RX_ADDR_P0, TX_ADDRESS, TX_ADR_WIDTH); 
  	SPI_Write_Buf(WR_TX_PLOAD, tx_buf, TX_PLOAD_WIDTH);      
	  SPI_Read(READ_REG+FIFO_STATUS);		
	

 	 SPI_RW_Reg(WRITE_REG + EN_AA, 0x00);
	  SPI_RW_Reg(WRITE_REG + EN_RXADDR, 0x01);  
  	SPI_RW_Reg(WRITE_REG + SETUP_RETR, 0x00); 
  	SPI_RW_Reg(WRITE_REG + RF_CH, 92);        
  	SPI_RW_Reg(WRITE_REG + RF_SETUP, 0x07);   
  	SPI_RW_Reg(WRITE_REG + CONFIG, 0x0e);     

	CE=1;
	delay(9600);
	CE=0;

}

Check my response to your email and see if that helps.

now i found parts of regs are not default values before i initialize them.Parts of them change the value i will initialize .

why this happen?

after i erase the code i turn off the power then turn on again.now the regs are right.

i found when i reset the program,the reg ‘CD’ is set high,the value is ‘0x01’.Is this may the reason i can’t receive? why this happen?

CD is “carrier detect.” This register going high just means that the 24L01 detected some sort of signal in the band of your selected RF channel. It will not affect receiving or transmitting in any way.

the suggestion in your email :

One thing you should do to make sure you have the right register settings is to dump all your registers to a serial port, LCD, whatever output you have and verify them one-by-one. If they are correct, verify that you are sending the right payload length and have the right TX address setup for your TX unit. Finally, you need to verify that the IRQ pin is functioning properly on the RX module. My suggestion is to put that module in TX mode and try to send a packet. Make sure you are reading the TX_DS interrupt to verify your hardware.

i try to verify my code according you suggestion.But i haven’t found the problems in my code.

in my code my setup should be right?

The problems are either in your code or in your hardware. Keep looking and you’ll figure it out eventually. Your code is rather difficult to read because of all the magic numbers instead of #define’s, so it would take a long time for me to go through it line by line. As I said, the use of my library would make debugging considerably easier, but it might take a while for you to get it going. It’s up to you how you want to do it.

Is this possible that transmitter can give the TX_DS interrupt but in fact the data is not send to the air?

I think you are not carful enough. pls keep trying and be carful enough. I also use C8051F320 to drive nRF24L01, and they can run now.

If you’re getting TX_DS, the 24L01 is sending something out. It is certianly possible that you may have a board that has a really bad RF layout and you’re not really transmitting anything out of the antenna, but if the units are really close together this shouldn’t matter.

Originally,i want to use your code directly,but i found my compiler can’t compile your code.So i analyse

your code you told me and according your flow i modify my own code.Unluckily the problem still exist.

I follow you flow config the PTX:

1.set no ACK(EN_AA = 0x00);

2.set RX_PW_P0 as 1 byte;

3.Set PWR_UP bit,also PTX(CONFIG = 0x0a);

trans:

0A 00 03 03 03 02 0F 0E 00 00 E7 E7 E7 E7 E7 C2 C2 C2 C2 C2 C3 C4 C5 C6 E7 E7 E7 E7 E7 01 00 00 00 00 00 11

4.delay 1.5ms,then CE=0;

5.when uart interrupt set an flag “en_send”;

6.if en_send=1,write 1 byte data;

7.CE=1,delay 10us,CE=0;

8.if IRQ=0 and TX_DS=1,clear all IRQ.

the PRX:

1.set no ACK(EN_AA = 0x00);

2.set RX_PW_P0 as 1 byte;

3.Set PWR_UP bit,also PRX(CONFIG = 0x0b);

receive:

0B 00 03 03 03 02 0F 0E 00 00 E7 E7 E7 E7 E7 C2 C2 C2 C2 C2 C3 C4 C5 C6 E7 E7 E7 E7 E7 01 00 00 00 00 00 11

4.delay 1.5ms,then CE=1;

5.wait until IRQ=0.