Problem communicating with nrf 24L01

I am using CCS compiler integrated in MPLAB software and MPLAB ICD2 to debug the software and I am not atall able to communicate to nrf24L01…

This is the code I am trying… In this code I am writing to write in TX_ADDRESS and then read from it thro’ spi… But I am not getting the results… Please any help!!!

/*

** test.c

** SPI test program for PIC18F4520 and nRF24L01

*/

#include “18F452.h”

#fuses H4, NOBROWNOUT, NOWDT, NOLVP, NOPUT

#ignore_warnings 201, 204, 205

#ignore_warnings NONE

//function prototypes

unsigned char spi_Send_Read(unsigned char);

// Defines

#define SPI_SCK pin_C3 // Clock pin, PORTC pin 3

#define SPI_S0 pin_C5 // Serial output pin, PORTC pin 5

#define SPI_SI pin_C4 // Serial input pin, PORTC pin 4

#define SPI_CSN pin_B2 // CSN output pin, PORTC pin 2

#define SPI_CE pin_B3 // CE output pin, PORTC pin 1

#define SPI_IRQ pin_C6 // IRQ input pin, PORTB pin 0

#define SPI_SCALE 4 // postscaling of signal

// Macros

#define nop() _asm nop _endasm

void main(void)

{

unsigned char status = 0;

unsigned char data[5];

#asm

movlw 0x0f

movwf 0xfc1

movlw 0x10

movwf 0xf94

movlw 0xf3

movwf 0xf93

#endasm

setup_spi(SPI_MASTER | SPI_L_TO_H | SPI_CLK_DIV_16);

//write TX_ADDRESS register

output_bit(SPI_CSN,0); //CSN low

spi_write(0x30);

spi_write(0x11);

spi_write(0x22);

spi_write(0x33);

spi_write(0x44);

spi_write(0x55);

output_bit(SPI_CSN,1); //CSN high

//read TX_ADDRESS register

output_bit(SPI_CSN,0); //CSN low

status = spi_read(0x10);

data[0] = spi_read(0x00);

data[1] = spi_read(0x00);

data[2] = spi_read(0x00);

data[3] = spi_read(0x00);

data[4] = read(0x00);

output_bit(SPI_CSN,1); //CSN high

while (1)

{

}

}

Have you verified on a scope that your SPI is working? If not, you will have to get that going first. If you don’t have a scope, you can use a loopback test by first disconnecting the 24L01 (and anything else) from your SPI bus. Short the SDO and SDI lines with a wire. Send the values from 0 to 255 over SPI and verify that the byte that was received on every transaction was the same as the one sent. If so, you have SDI and SDO working. You can test that CSN is working by simply hooking that up to a multimeter and toggling it in software every 3 or 4 seconds. You generally need a scope to test SCK.

If you can get all of this working, hook the 24L01 back up and try reading some stuff, and see if you at least can read the proper default value of the status register. If not, you still don’t have everything working correctly.

scr8926, have you had any success talking to the 24L01? I am also trying to use your code to communicate with TX_ADDRESS register using a PIC24 and am not having any success.