Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

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, 07:39 AM ]

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.

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, 05:53 AM ]

You might also like