nrf24L01+ help for Max retries and switch mode

Discussion about wireless devices

nrf24L01+ help for Max retries and switch mode

Postby gruber » Sun Aug 07, 2011 6:59 pm

Hi all,

I've posted those questions in another forum,so far no reply,so I do hope someone can help me here...

I've been "experimenting" with NRF24L01+ and 2xLPC1343 for some time, and I came across two things I cannot figure out on myself.

1) I cannot switch between RX and TX mode.
If I set RX and then sets TX and tries to send a packet,nothing happens. If I restart the module,set to TX and send, its OK. If its at RX, it receives

2) When the receiver is not ON, the module "hammers" the uC with interrupts instead of issuing 1 interrupt for max retries. I watched it with oscilloscope, the NRD24L01+ issues interrupt every ~1ms and when read it back, the MAX_RT flag is on. You can check the code below, but I think I clear the interrupts properly + flushing the TX + clearing CE bit, but still the module becomes un-usable after I try to send a packet with the receiver OFF. I have to restart the whole board in order to get it up&running again.

I am using 2 LPC1343 boards ( one olimex' and one self made ) with different pin assignment, but the same NRF code - i.e. the NRF part is the same on both boards.
If TX module is ON and the RX is ON ( both configured ) the transmission is OK. If I change the RX/TX side, its again all OK.

I assume its the software, because it does not matter which board tries 1) or 2), its always the same.

The code I use is
Code:
void nrf24_init(unsigned char freq, unsigned char power, unsigned char rate, unsigned char lna_gain) {
if(( freq > 125 ) && ( freq < 0 )) {
NRF_FREQ = 0;
}
else {
NRF_FREQ = freq;
}
NRF_RFSETUP = power | rate | lna_gain ;
nrf_wr_reg(NRF_WRITE_REG + NRF_EN_AA, 0x1);
nrf_wr_reg(NRF_WRITE_REG + NRF_EN_RXADDR, 0x01);
nrf_wr_reg(NRF_WRITE_REG + NRF_SETUP_RETR, 0x0);
nrf_wr_reg(NRF_WRITE_REG + NRF_RF_CH,NRF_FREQ);
nrf_wr_reg(NRF_WRITE_REG + NRF_RF_SETUP, NRF_RFSETUP);
nrf_wr_buf(NRF_WRITE_REG + NRF_RX_ADDR_P0, (unsigned char*)RX_ADDRESS, NRF_ADR_WIDTH);
nrf_wr_reg(NRF_WRITE_REG + NRF_RX_PW_P0, NRF_RX_PLOAD_WIDTH);
nrf_wr_buf(NRF_WRITE_REG + NRF_TX_ADDR, (unsigned char*)TX_ADDRESS, NRF_ADR_WIDTH);
nrf_wr_reg(NRF_WRITE_REG + NRF_STATUS, NRF_CLRST);
}


void nrf_rx_mode(void) {
nrf_ce(NRF_CE_DESEL);
nrf_wr_reg(NRF_WRITE_REG + NRF_CONFIG, 0x03);
delay(1000);
nrf_ce(NRF_CE_SEL);
}

void nrf_tx_mode(void) {
//nrf_ce(NRF_CE_DESEL);
nrf_wr_reg(NRF_WRITE_REG + NRF_CONFIG, 0x02);
delay(1000);
//nrf_ce(NRF_CE_SEL);
}

void nrf_flush_tx (void ){
nrf_wr_reg(NRF_FLUSH_TX,0x0);
}

void nrf_txpacket(unsigned char *tx_buf) {
nrf_wr_buf(NRF_WR_TX_PLOAD, (unsigned char*)tx_buf, NRF_TX_PLOAD_WIDTH);
}

void main (void)

...
case '<transmit>' :
txrx_mode = 0x1;
nrf_tx_mode();
send_msg("NRF:Set to TX mode");
break;
case '<receive>' :
txrx_mode = 0x0;
nrf_rx_mode();
send_msg("NRF:Set to RX mode");
break;
case '<send_pkt>' :
if (txrx_mode) {
nrf_txpacket((unsigned char*)nrftxbuf);
nrf_ce(NRF_CE_SEL);
delay(1000);
nrf_ce(NRF_CE_DESEL);
} else {
send_msg("NRF:Cannot execute while TX not configured");
}

then interrupt procedure
if (nrf_interrupted) {
if (txrx_mode) {
nrf_status = nrf_rd_reg(NRF_STATUS);
if (nrf_status & NRF_TXDS) {
send_msg("NRF send successful");
} else if (nrf_status & NRF_MAXRT) {
nrf_ce(NRF_CE_DESEL);
send_msg("NRF not sent - MAX Retries reached!");
} else {
nrf_flush_tx();
nrf_ce(NRF_CE_DESEL);
bytetohex(nrf_status);
send_msg("NRF not sent");
}
nrf_wr_reg(NRF_WRITE_REG + NRF_STATUS, nrf_status);
} else {
if (nrf_rxpacket((unsigned char *)nrfrxbuf)) {
delay(10000);
send_msg("NRF received successful");
} else {
send_msg("NRF received NOT successful");
}
}
nrf_interrupted = 0x0;


the wr_reg and rd_reg are "verified" separately and the tasks are working - I don't think the issue is there. I have tried different register write and read-back, the "checks" are OK.

If someone has an idea for help, please comment, as I am not able to figure out where the problem is...

Thanks in advance :)
gruber
 
Posts: 1
Joined: Sun Aug 07, 2011 6:41 pm

Re: nrf24L01+ help for Max retries and switch mode

Postby brennen » Mon Aug 08, 2011 7:55 pm

Given that my code is tested and works, you should probably start out by looking at my examples in the tutorials. You don't necessarily have to use my code, but by looking at least at the main.c files, you should get a pretty good understanding of how to configure the modules, as well as re-configuring RX and TX on the fly while powered up.
brennen
Site Admin
 
Posts: 395
Joined: Sun Aug 17, 2008 2:15 pm


Return to Wireless

Who is online

Users browsing this forum: No registered users and 2 guests

cron