Discussion in "Project Help" started by    siddique    Aug 25, 2014.
Mon Aug 25 2014, 01:00 pm
#1
Hi,
I'm currently working on the nRF24L01+ transceiver.
I'm using spi protocol to interact with the module.
I'm trying to develop code for 2 modules. 1 transmitter and 1 receiver.

the problem which i am facing is that I am always getting MAX_RT interrupt at the transmitter side and no successful transmission or reception.

These are the steps in the transmitter module
MAKE CE LOW INITIALLY
1. load value 0x0E to CONFIG register
2. load value 0x01 to EN_AA register
3. load value 0x01 to EN_RXADDR register
4. load value 0x03 to SETUP_AW register
5. load value 0x2F to the SETUP_RETR register
6. load value 0x02 to the RF_CH register
7. load value 0X06 to the RF_SETUP register
8. load address 0XE7E7E7E7E7 to the TX_ADDR register
9. load address 0XE7E7E7E7E7 to the RX_ADDR_P0 register
10. FLUSH TX
11. LOAD PAYLOAD
12. MAKE CE HIGH FOR SOME TIME AND LOW AGAIN.

IN THE RECEIVER MODULE
MAKE CE LOW INITIALLY
START LOADING VALUES TO THE REGISTERS
1. load value 0x0F to CONFIG register
3. load value 0x01 to EN_RXADDR register
2. load value 0x01 to EN_AA register
4. load value 0x03 to SETUP_AW register
5. load value 0x00 to the SETUP_RETR register
6. load value 0x02 to the RF_CH register
7. load value 0X06 to the RF_SETUP register
8. load address 0XE7E7E7E7E7 to the RX_ADDR_P0 register
9. FLUSH RX
MAKE CE HIGH CONTINUOUSLY.

looking for help from whoever has worked on this module.
Need your guidance on this. My SPI is working fine.

Thanks in advance.


[ Edited Mon Aug 25 2014, 01:09 pm ]
Tue Aug 26 2014, 01:30 am
#2
This tutorial looks useful.
http://www.diyembedded.com/tutorials/nrf24l01_0/nrf24l01_tutorial_0.pdf
From reading that, I have a few suggestions.

In RF_SETUP ..set bit 0 to 1, the default.
In STATUS .. reset the interrupt flags as part of startup.
Set the data size for pipe 0, as the default , 0= 'off'

If that does not help,
turn off auto acknowledge just in case it is causing problems.
Let us know how you get on.
I'd like to see working project using a PIC or AT89S52.
Tue Aug 26 2014, 12:50 pm
#3
Hi,
Tried your suggestions.
when i put the device in auto acknowledge mode the transmitter re-transmits continuously and finally gives the MAX_RT interrupt.
but, when i disable auto acknowledgement, the transmitter transmits the data successfully (successful transmission is indicated in the transmitter status register TX_DS=1) but the receiver does not receive any data.

In both cases the receiver is not receiving any data.


[ Edited Tue Aug 26 2014, 12:52 pm ]
Wed Aug 27 2014, 03:33 am
#4
I assume you have made the changes I suggested to both TX and RX modules.

What hardware have you got ?
Wed Aug 27 2014, 11:18 am
#5
Pls check the Tx and Rx functions have made some changes. but the results are still same (no reception)
these are 2 separate programs loaded on two different AT89S52 controllers. I intend to program 1 device only as a transmitter and another only as a receiver.
These functions are supported by spi functions and other functions which complete the code.
I have checked the spi communication. I have successfully read the data which i had written to the registers. So, there is no problem in the spi functions.
void TX_Mode()//transmitter function
{
	unsigned char ch;
	unsigned int i=0;
	
	clear_interrupts();
	Write_spi(WRITE_REG+RX_PW_P0,0);  //setting payload width initially to 0

	Serial_print("\r\ninitial status ");
	status_read();  //reading status register
	
	delay_ms(100);
	ce=0;    //making CE low for writing the values to registers 
	delay_ms(1);
	
	Write_spi(WRITE_REG+CONFIG,0X02);		//setting power up bit
	Serial_print("\r\nvalue of CONFIG ");
	Read_spi(CONFIG,1);																		   //tx mode settings

	Write_spi_buffer(WRITE_REG+TX_ADDR, TX_ADDRESS, TX_ADR_LENGTH);	//loading Tx address 5 byte address 0xE7E7E7E7E7
		

	Write_spi(WRITE_REG+EN_AA,0X00);   //disabling auto ack for  all pipe
	Write_spi(WRITE_REG+EN_RXADDR,0X00); //disabling all receiving pipes cuz I'm only trying to send data not receive it

	Write_spi(WRITE_REG+SETUP_RETR,0X00);	  //setting no retransmission
	Write_spi(WRITE_REG+RF_CH,2);		//selecting channel for rf communication
	Write_spi(WRITE_REG+RF_SETUP,0X27);//250kbps (also tried for 1 mbps, got same result)
	Write_spi(WRITE_REG+SETUP_AW,0X03);//5 byte address width
	
/************************************************************/		
	set_reg_bit(CONFIG,3); //enable CRC (setting bit 3 of config register)
	set_reg_bit(CONFIG,2); //2 byte CRC (setting bit 2 of config register)
	clear_reg_bit(CONFIG,0); //TX MODE (clearing bit 0 of config register)
	

/************************************************************/	

	cs=0;
	write(FLUSH_TX);
	cs=1;

//	clear_interrupts();

	

/*	Serial_print("\r\n status after clearing ");
	status_read();		   */

	Write_spi_buffer(WR_TX_PLOAD, TX_PAYLOAD, TX_PLOAD_WIDTH);
	
/*	ch=Read_spi(FIFO_STATUS,1);
	Serial_print("\r\nvalue of fifo status reg ");
	conversion(ch);

	clear_interrupts();	  */

	//delay_ms(10);
	ce=1;		//making ce high for transmission
//	delay_Us(40);  //for 1mbps
	delay_Us(250); //for 250kbps
	ce=0;                //making ce low
	delay_ms(50);  //for 250kbps
//	delay_ms(40); // for 1mbps
//	clear_interrupts();
/*	ch=Read_spi(FIFO_STATUS,1);
	Serial_print("\r\nvalue of fifo status reg ");
	conversion(ch);

	Serial_print("\r\nstatus before clearing interrupts");
	status_read();
	clear_interrupts();
	Serial_print("\r\nInterrupt cleared");
	Serial_print("\r\nstatus after clearing interrupts");
	status_read();	*/
}


void RX_Mode(void)
{	
	ce=0;
	clear_interrupts();
	Write_spi(WRITE_REG+RX_PW_P0,0);

	Write_spi(WRITE_REG+CONFIG,0X02);//power up
	
	Write_spi(WRITE_REG+SETUP_AW,0X03);
	Write_spi(WRITE_REG+SETUP_RETR,0X00);
	 
	Write_spi_buffer(WRITE_REG + RX_ADDR_P0, TX_ADDRESS, TX_ADR_LENGTH); // Used the same address on the RX device as the TX device
	
	Write_spi(WRITE_REG+EN_AA,0X00);//no auto ack
	Write_spi(WRITE_REG+EN_RXADDR,0X01);//enable pipe 0 to receive data
	Write_spi(WRITE_REG+RF_CH,2);
	Write_spi(WRITE_REG+FEATURE,0X00);//disabling dynamic payload
	Write_spi(WRITE_REG+DYNPD,0X00);
	Write_spi(WRITE_REG + RX_PW_P0, TX_PLOAD_WIDTH); // Select same RX payload width as TX Payload width
	Write_spi(WRITE_REG+RF_SETUP,0X27);
	

/************************************************************/		
	set_reg_bit(CONFIG,3);	//enable crc
	set_reg_bit(CONFIG,2);	//2 byte crc
	set_reg_bit(CONFIG,0);	//setting prim_rx bit high for rx mode
	

/************************************************************/

	delay_ms(1);  

	cs=0;
	write(FLUSH_TX);	//CLEARING FIFO'S (TX AND RX FIFO RESPECTIVELY)
	cs=1;

	delay_ms(10);

	cs=0;
	write(FLUSH_RX);
	cs=1;

	delay_ms(1000);
	ce = 1; // Set CE pin high to enable RX device
	delay_ms(100);
}



[ Edited Wed Aug 27 2014, 11:23 am ]
Thu Aug 28 2014, 02:15 am
#6
In your TX code I see where you set payload width initially to 0
but not where you set to actual data size.
Thu Aug 28 2014, 10:39 am
#7
hi,
In the Tx code, I have disabled auto acknowledge and also I'm not receiving any data. So, I don't think there is any need to load any data size (other than 0) in the RX_PW_P0 register.
Pls correct me if I have misunderstood anything.
Fri Aug 29 2014, 01:01 am
#8


So, I don't think there is any need to load any data size (other than 0) in the RX_PW_P0 register.

siddique


You may not need to set a value, but I would anyway,
just in case....

Have you tried using the TX setup to receive and vice versa ?
Sat Aug 30 2014, 01:04 pm
#9



Have you tried using the TX setup to receive and vice versa ?

ExperimenterUK


could you please elaborate on this. I'm unable to clearly understand.
Regards
Sat Aug 30 2014, 09:26 pm
#10
I found a very good working source but its for PIC you can easily port it to 8051. I trust this source. can you give it a try and let me know?

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

Bobbyerilar
Thu Mar 28 2024, 08:08 am
pb58
Thu Mar 28 2024, 05:54 am
Clarazkafup
Thu Mar 28 2024, 02:24 am
Walterkic
Thu Mar 28 2024, 01:19 am
Davidusawn
Wed Mar 27 2024, 08:30 pm
Richardsop
Tue Mar 26 2024, 10:33 pm
Stevencog
Tue Mar 26 2024, 04:26 pm
Bernardwarge
Tue Mar 26 2024, 11:15 am