CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

nRF24L01+ full driver by Eduardo Guilherme Brandt
Goto page Previous  1, 2, 3 ... 18, 19, 20
 
Post new topic   Reply to topic    CCS Forum Index -> Code Library
View previous topic :: View next topic  
Author Message
PannetierJ



Joined: 18 Jun 2017
Posts: 31

View user's profile Send private message

PostPosted: Fri Jul 14, 2017 6:17 am     Reply with quote

Hello guys ,

I received my pics. I replaced my receiver by 18LF2520 and transmitter by 18LF2550.
It's LF now.
I have the same result.
I receive nothing....
Is it a problem of SPI config ?
PannetierJ



Joined: 18 Jun 2017
Posts: 31

View user's profile Send private message

PostPosted: Fri Jul 14, 2017 7:09 am     Reply with quote

Hi PCM,

You're right.

I had have an extra call to RF24_RX_SET().
I deleted this .

I catch the return of my function RF24_RX_SET() :
And I have an error : number 2

code of main prog :

Code:

#include <18F2520.h>  //18LF2520 is using
#DEVICE *=16    /*ICD=TRUE*/ PASS_STRINGS=IN_RAM /*HIGH_INTS=TRUE*/   //Admite ponteiros para constantes

#fuses HS,NOWDT,NOLVP
#use delay(clock=16000000)
#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7,ERRORS)
//#use SPI(SPI2,MASTER,BAUD=1000000, MODE=0,BITS=8,MSB_FIRST,STREAM=STREAM_SPI2)
 

#define RF24_SPI_DISABLE_WARNING  //for disabling nRF24 SPI warning message.



//********** DEFINE PORT NAMES
#define  SPI_MISO       PIN_B0   //SPI(Usar por hardware quando possivel)
#define  SPI_MOSI       PIN_B3   //SPI(Usar por hardware quando possivel)
#define  SPI_CLK        PIN_B1   //SPI(Usar por hardware quando possivel)

//Driver nRF24L01P.C
#define  RF24_IRQ       PIN_B2   //interrupcao nRF24L01+
#define  RF24_CS        PIN_C1   //chipselect nRF24L01+
#define  RF24_CE        PIN_C2   //chipEnable nRF24L01+
#define  RF24_PERFORMANCE_MODE   //performance mode ON
#define  RF24_SPI       STREAM_SPI2//Redirects SPI2 port to RS24_SPI stream

//#use SPI(MASTER,DI=SPI_MISO,DO=SPI_MOSI,CLK=SPI_CLK,BAUD=1000000,MODE=0,BITS=8,MSB_FIRST,STREAM=RF24_SPI)
//#use SPI(MASTER,SPI1, BAUD=1000000,MODE=0,BITS=8,MSB_FIRST,STREAM=RF24_SPI)
#use SPI(MASTER,DI=SPI_MISO,DO=SPI_MOSI,CLK=SPI_CLK,BAUD=1000000,MODE=0,BITS=8,MSB_FIRST,STREAM=STREAM_SPI2)

//INCLUDES_2   -  Drivers
#include <nRF24L01P.C>           //Driver nRF24L01+   Single Chip 2.4GHz Transceiver Driver


//INCLUDES_3
#include <STDLIB.H>


void main()
{
   int RXbuffer1[11];
   int RXdatasize, RXpipe;
   int i;
   int Result;
   printf("Initialisation of system in progress\r\n");
   RF24_initPorts();

   RF24_default_config();

   Result=RF24_RX_SET();       //Receiver on
   if(Result==1)
      printf("Config RX Ok\r\n");
   else
      {
      printf("Config RX KO\r\n");
      printf(" Result : %d\r\n",Result);
      }
   
   printf("Initialisation of system\r\n");
   
   while(true) {
     
      while( RF24_RX_getbuffer(&RXpipe, &RXdatasize, RXbuffer1)!=true );
     
        printf("Number of bytes received = %u \n\r",RXdatasize);
        for(i=0;i<RXdatasize;i++)
            printf("%c",RXbuffer1[i]);
        printf("\n\r");
     
   }
}




And into the function RF24_RX_SET() :

Code:

int RF24_RX_SET() {    //Enhanced ShockBurst receiving payload(return 1 if ok, return other number if error)
int i,data;

   i = RF24_comm_in(R_REGISTER|FIFO_STATUS);
   if ((i&RX_FULL)==RX_FULL) return 0;                 //Error: RX FIFO buffer full flag, must be read before receive new packets(REVISION 1.1)
   //   
   data = RF24_comm_in(R_REGISTER|CONFIGURATION);
   if ((data&PWR_UP)!=PWR_UP) return 0x02;   //Error: Turn PWR_UP on before transmit
   data|=PRIM_RX;                            //1. Select RX by setting the PRIM_RX bit in the CONFIG register to high.
   RF24_comm(W_REGISTER|CONFIGURATION, data);
   /*
   All data pipes that receive
   data must be enabled (EN_RXADDR register), enable auto acknowledgement for all pipes running
   Enhanced ShockBurst (EN_AA register), and set the correct payload widths (RX_PW_Px registers).
   Set up addresses as described in item 2 in the Enhanced ShockBurst transmitting payload
   example above.
   */
   RF24_enable();             //2. Start Active RX mode by setting CE high.
   //                         //3. After 130µs nRF24L01+ monitors the air for incoming communication.   
   /*4. When a valid packet is received (matching address and correct CRC), the payload is stored in the
   RX-FIFO, and the RX_DR bit in STATUS register is set high. The IRQ pin is active when RX_DR is
   high. RX_P_NO in STATUS register indicates what data pipe the payload has been received in.
   5. If auto acknowledgement is enabled, an ACK packet is transmitted back, unless the NO_ACK bit
   is set in the received packet. If there is a payload in the TX_PLD FIFO, this payload is added to
   the ACK packet.*/
   //RF24_disable();          //6. MCU sets the CE pin low to enter standby-I mode (low current mode).
   //                         //7. MCU can clock out the payload data at a suitable rate through the SPI.
   //                         //8. nRF24L01+ is now ready for entering TX or RX mode or power down mode.
   return true;               //Success
}//

Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> Code Library All times are GMT - 6 Hours
Goto page Previous  1, 2, 3 ... 18, 19, 20
Page 20 of 20

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group