I'm trying to get a module with an NFR24L01+ on board to send a simple data transmission from a pic micro but after a couple of days of trying various combinations without success i'm asking for help.
I can see data and commands being clocked in and out of the SPI. the pulse on CE is present on the chip. VDD_PA never rises. No power noted on a monitoring SA. Status 0x0E returned from chip.
My send byte code:
unsigned char SPI_RW(unsigned char DATA) {
while (! SSPIF);
SSPSTATbits.BF = 0;
SSPBUF = DATA;
while(SSPSTATbits.BF == 0);
return SSPBUF;
}
My send register code:
unsigned char SPI_RW_Register(unsigned char reg, unsigned char value){
int status;
CSN_PIN=0;
status=SPI_RW(reg);
SPI_RW(value);
CSN_PIN=1;
return status;
}
My write buffer code:
unsigned char SPI_Write_Buffer(unsigned char reg, unsigned char *pBuf, unsigned char bytes){
unsigned char status,i;
CSN_PIN=0; // Set CSN low, init SPI tranaction
status = SPI_RW(reg); // Select register to write to and read status unsigned char
for(i=0;i<bytes; i++) // then write all unsigned char in buffer(*pBuf)
{
SPI_RW(*pBuf++);
}
CSN_PIN=1;
return(status); // return nRF24L01 status unsigned char
}
My init code:
CE_PIN=0;
SPI_RW_Register(WRITE_REG + CONFIG,0x00110000);// PRX, no CRC , mask a couple of ints
__delay_ms(100);
SPI_RW_Register(WRITE_REG + SETUP_RETR,0x00);// autoretransmit off
SPI_RW_Register(WRITE_REG + SETUP_AW,0x00000011);// address width = 5
SPI_RW_Register(WRITE_REG + RF_SETUP, 0x00100110); //data rate 250KB 0dBm
SPI_RW_Register(WRITE_REG + RF_CH,0x02);// set channel
SPI_Write_Buffer(WRITE_REG + TX_ADDR,TX_ADDRESS,5);
SPI_Write_Buffer(WRITE_REG + RX_ADDR_P0,TX_ADDRESS,5);
SPI_RW_Register(WRITE_REG + EN_AA,0x00); //disable auto-ack
My TX code:
void NRFtx(){
CE_PIN=0;
SPI_RW_Register(WRITE_REG + STATUS,0x7e); // clear previous interrupts
SPI_RW_Register(WRITE_REG + CONFIG,0x00110010);// PTX, no CRC, mask a couple of ints
__delay_us(150);
SPI_RW_Command(FLUSH_TX);//clear tx fifo
SPI_Write_Buffer(WR_TX_PAYLOAD,tx_buf,TX_PAYLOAD_WIDTH);
CE_PIN=1;
__delay_ms(15);
CE_PIN=0;
}
Can anyone please tell me where i'm going wrong with this?
Thank you,
S