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 ... 12, 13, 14 ... 18, 19, 20  Next
 
Post new topic   Reply to topic    CCS Forum Index -> Code Library
View previous topic :: View next topic  
Author Message
Eduardo__



Joined: 23 Nov 2011
Posts: 197
Location: Brazil

View user's profile Send private message

PostPosted: Sat Jan 18, 2014 6:12 pm     Reply with quote

Yuri, you´ve to take a look in how the commands work. See it inside main driver and header file.


In header file there´re "Command List:" and "addresses list" with instructions together.

Inside driver main file, there´re explanation of all functions... how it work. You´ve examples also,....
See RF24_default_config() function to see how to startup the nRF24 device.


Just a note: Is not positive(not easy) to check what of them are working. The best thing is check if the raspberry nRF24 driver configuration is exactly equal to you PIC driver configuration(The same channel, the same number of pipes, the same CRC, the same speed and transmit mode... etc... .

It can be hard to achieve without checking driver inside.


A key for you: It´s not a game. Try to check if both nRF transceivers has the same configuration.
nRF24 driver that I made has a function named "RF24_check_config()". You can ADD serial communicant ion for transmitting nRF24 registers internal configurations(after RF24 startup configuring of course).

Good luck friend.
_________________
Eduardo Guilherme Brandt
yuripace



Joined: 26 Nov 2013
Posts: 21

View user's profile Send private message

PostPosted: Sun Jan 19, 2014 6:07 am     Reply with quote

i need lot of luck :D but i made a small step forward, i found the default config of the raspberry.

SPI device = /dev/spidev0.0
SPI speed = 8000000
CE GPIO = 25
STATUS = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1 = 0xf0f0f0f0d2 0xf0f0f0f0e1
RX_ADDR_P2-5 = 0xc3 0xc4 0xc5 0xc6
TX_ADDR = 0xf0f0f0f0d2
RX_PW_P0-6 = 0x20 0x20 0x00 0x00 0x00 0x00
EN_AA = 0x00
EN_RXADDR = 0x03
RF_CH = 0x05
RF_SETUP = 0x03
CONFIG = 0x0f
DYNPD/FEATURE = 0x00 0x04
Data Rate = 1MBPS
Model = nRF24L01+
CRC Length = 16 bits
PA Power = PA_LOW

i suppose i have to set the corresponding parameters in your nRF24L01P.h, is right? Sorry for all the questions, its only to understand better how your driver works. At the end I'll post all my project sources.
Eduardo__



Joined: 23 Nov 2011
Posts: 197
Location: Brazil

View user's profile Send private message

PostPosted: Sun Jan 19, 2014 8:08 am     Reply with quote

yes. But the addresses you need to change to other values. The other transceiver have not use the same address.

Pipe 0 and pipe 1 you can use 3 to 5 bytes address lenght(you need to set how many bytes). Pipe 2 to 5 you can only change the last byte of address. The others bytes are equal to address of pipe 1.

Se settings you must to set:

RX_ADDR_P0-1 = 0xf0f0f0f000(address pipe0) 0xf0f0f0f001((address pipe1)
RX_ADDR_P2-5 = 0x02(address pipe2) 0x03(address pipe3) 0xc5(address pipe4) 0xc6(address pipe5)
TX_ADDR = 0xf0f0f0f0d2 (address TX) <<It means you´ll transmit to pipe 0 of the transceiver of address 0xf0f0f0f0d2
RX_PW_P0-6 = 0x20 0x20 0x00 0x00 0x00 0x00
EN_AA = 0x00
EN_RXADDR = 0x03
RF_CH = 0x05
RF_SETUP = 0x03
CONFIG = 0x0f
DYNPD/FEATURE = 0x00 0x04
Data Rate = 1MBPS

CRC Length = 16 bits
PA Power = PA_LOW <<<SET PowerAmplifier_HIGH(1mW)


Take a look in nRF24 driver header file to understand better the configurations.
_________________
Eduardo Guilherme Brandt
joseluis



Joined: 24 Jan 2014
Posts: 3

View user's profile Send private message

PostPosted: Fri Jan 24, 2014 9:32 am     Reply with quote

Hello Eduardo, I want to share my code I made using your library, used for communication with pic16f877a UART RF and it works well, my question is how can I add the DTR pin for the communication.

Code:

#include <16F877A.h>
#device adc=16
#device PASS_STRINGS=IN_RAM
//#device HIGH_INTS=TRUE
#FUSES NOWDT                    //No Watch Dog Timer
#FUSES HS                       //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD)
#FUSES NOBROWNOUT               //No brownout reset
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O

#use delay(clock=20000000)

#use rs232(baud=115200,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=PORT1)
#USE SPI (MASTER, SPI1, MODE=0, BITS=8, STREAM=RF24_SPI, MSB_FIRST)
#define   RF24_CS       PIN_C1
#define   RF24_CE       PIN_C2
#define   RF24_IRQ      PIN_B0
#define   SPI_CLK      PIN_C3
#define   SPI_MISO     PIN_C4  // SDI
#define   SPI_MOSI     PIN_C5  // SDO
//#define   RF24_USE_DMA
#define  RF24_PERFORMANCE_MODE   //performance mode ON
#define   RF24_SPI_DISABLE_WARNING
//#include <stdio.h>
//#include <STDLIB.H>
//#include <string.h>
#include <nrf24l01p.c>
char cadena[32];

#int_RDA
void  RDA_isr(void)
{
gets(cadena);
RF24_TX_SET();       //Transmitter on
//printf("%s\r\n",cadena);
      //now, you can write FIFO stack1
      RF24_TX_putbuffer(false,32, cadena); //Transmit 32bytes data(text string) to actual address(default_config address)

      //Do this to check each data transfer
      while(RF24_IRQ_state()==false);        //Waits for any interrupt.  Same as "while(!RF24_IRQ_state());"     
      RF24_STATUS_clr_IRQs(IRQ_ALL);      //Allows clearing all IRQs at the same time
RF24_RX_SET();       //Receiver on     
}

void main()
{
   //char buffer[4];
   int RXbuffer1[32], RXbuffer2[32], RXbuffer3[32];
   int RXbuffer4[32], RXbuffer5[32];
   int RXdatasize, RXpipe;
   
   enable_interrupts(INT_RDA);
   enable_interrupts(GLOBAL);
   printf("uart rf TRX\r\n");
   //buffer="RXTX";
   //printf("%s\r\n",buffer);
   RF24_initPorts();
   RF24_default_config();
   
   RF24_RX_SET();       //Receiver on
   while(true) {
     
      while ( RF24_RX_getbuffer(&RXpipe, &RXdatasize, RXbuffer1)!=true );    //Wait till receive data(1 to 32 bytes) into buffer(from default_config address of pipe0)
      printf("%s\r\n",RXbuffer1);

      }

      delay_cycles(1);   
}
Eduardo__



Joined: 23 Nov 2011
Posts: 197
Location: Brazil

View user's profile Send private message

PostPosted: Fri Jan 24, 2014 11:40 am     Reply with quote

Dear Joseluis,

About Data Terminal Ready (DTR). I think receiver side has not DTR pin(your code is only for receive).

You can use a pin of you uC to indicate DTR in TX side(or you can use the same uC for TX and RX). DTR depends of amount of you input TX buffer(size of teh buffer). nRF buffer is only 32 bytes, but you can use a larger buffer(depending of you uC amount of unusued RAM). When buffer is not full you can assert DTR. If buffer is full uC cannot receive data, so unassert DTR pin.

you´re free to decide how to work on.

Good luck friend
_________________
Eduardo Guilherme Brandt


Last edited by Eduardo__ on Fri Jan 24, 2014 9:24 pm; edited 1 time in total
joseluis



Joined: 24 Jan 2014
Posts: 3

View user's profile Send private message

PostPosted: Fri Jan 24, 2014 7:02 pm     Reply with quote

Thanks for answering Eduardo but if I wanted to add any pin control and send through another pipe, how I can change address from the Transmitter.
Eduardo__



Joined: 23 Nov 2011
Posts: 197
Location: Brazil

View user's profile Send private message

PostPosted: Fri Jan 24, 2014 9:22 pm     Reply with quote

Dear Joseluis,

receiver has several(6) pipes(6 different addresses), but transmitter has just a main pipe(one transmitt address). Each receiver pipe has a different address.

It means that the receiver can be enabled receiving in a single channel, but each receiver is able to receive data from 6 different addresses. At the transmitter side, you just change the ttransmitter address. You will be able to send data to receivers in the same channell of the transmitter, but the transmitting address you can change. Changing transmitting address you will be able to transmite data to different pipes in a same receiver, or to transmit to different receivers.

it can be useful, por example, if you want to trasmit a different data to pipe0 and pipe1, and you do not want to mix these data.

See default_config() function to learn how to set transmitt address.(or how to set pipe 0 to 5 addresses.
_________________
Eduardo Guilherme Brandt
joseluis



Joined: 24 Jan 2014
Posts: 3

View user's profile Send private message

PostPosted: Sat Jan 25, 2014 9:15 am     Reply with quote

Is it okay to change the direction of the transmitter with this code? and I need not do anything more
Code:


RF24_comm_out(W_REGISTER|TX_ADDR, "1rdda", 5 );   //(3 to 5 bytes)Transmit address. Used for a PTX device only.(LSByte first). Set RX_ADDR_P0 equal to this address to handle automatic acknowledge if Enhanced ShockBurst enabled
Eduardo__



Joined: 23 Nov 2011
Posts: 197
Location: Brazil

View user's profile Send private message

PostPosted: Sat Jan 25, 2014 1:00 pm     Reply with quote

yes, just this. "1rdda" is the address in ascii format. You can use any other 5byte pointer for address.

Just a note: Transmitter and receiver address lenght must be the same(3 to 5 bytes).



As you see, the driver is self-explainable!!! Take a look at header file to see more options.
_________________
Eduardo Guilherme Brandt
yuripace



Joined: 26 Nov 2013
Posts: 21

View user's profile Send private message

PostPosted: Sun Jan 26, 2014 4:52 am     Reply with quote

Eduardo__ wrote:
yes, just this. "1rdda" is the address in ascii format. You can use any other 5byte pointer for address.

just one question..should i change also che .c files?
this is the changed raspy config
Code:

STATUS           = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1     = 0x00000000c1 0x00000000c2
RX_ADDR_P2-5     = 0xc3 0xc4 0xc5 0xc6
TX_ADDR          = 0x00000000c1
RX_PW_P0-6       = 0x20 0x20 0x00 0x00 0x00 0x00
EN_AA            = 0x3f
EN_RXADDR        = 0x03
RF_CH            = 0x05
RF_SETUP         = 0x05
CONFIG           = 0x0f
DYNPD/FEATURE    = 0x00 0x00
Data Rate        = 1MBPS
Model            = nRF24L01+
CRC Length       = 16 bits
PA Power         = PA_HIGH


and this the header file part i changed according to the raspy config, is this ok?

Code:

enum RF24_addr {  //**Addresses list
   CONFIGURATION= 0x0f,         //see RF24_CONFIGURATION 0x00
   EN_AUTOACK=0x00,                  //bits 0 to 5 enables in pipe0 to pipe5(EN_AA)
   EN_RXPIPES,                  //bits 0 to 5 enables pipe0 to pipe5
   SETUP_ADDRESSWIDTH,         //set 1 to 3(3 to 5 bytes)
   SETUP_AUTORETRANSMISSION,   //7:4(250 to 4000us) autoretry delay, 3:0(0 to 15)Auto retry times
   RF_CHANNEL=0x05,            //0 to 126. F0= 2400 + RF_CHANNEL [MHz]. Use 1 channel of space for 250kbps to 1Mbps radios and 2 channels of space between 2Mbps radios.
   RF_SETUP=0x03,                  //see RF24_SETUP
   STATUS,                     //see RF24_STATUS
   OBSERVE_TX,                  //(R)7:4 lost packets, 3:0 retry TX packets
   RX_POWER_DETECTOR,         //(R)only bit0(1=true)
   RX_ADDR_P0=0xc1,            //Receive address data pipe 0. 5 Bytes maximumlength. (LSByte first)
   RX_ADDR_P1=0xc2,RX_ADDR_P2=0xc3,RX_ADDR_P3=0xc4,RX_ADDR_P4=0xc5,RX_ADDR_P5=0xc6,   //same for pipe 1. For pipes 2 to 5 is sent 1 Byte only. You can change only the Least Significant Byte.
   TX_ADDR=0x00000000c1,               //(3 to 5 bytes)Transmit address. Used for a PTX device only.(LSByte first). Set RX_ADDR_P0 equal to this address to handle automatic acknowledge if Enhanced ShockBurst enabled
   RX_PW_P0=0x20,             //(set 1 to 32)RX payload size pipe0
   RX_PW_P1=0x20 ,RX_PW_P2=0x00 ,RX_PW_P3=0x00 ,RX_PW_P4=0x00 ,RX_PW_P5=0x00 ,   //same for pipes 1 to 5
   FIFO_STATUS=0x17,            //(R)see RF24_FIFO_STATUS
   EN_DYNAMIC_PAYLOAD=0x1C,   //bits 0 to 5 enables in pipe0 to pipe5
   DYN_PAYLOAD_CONFIG=0x1D};   //see RF24_DYN_PAYLOAD_CONFIG


also the RF24_default_config functions need to be changed according to this parameter?

thanks!
Yuri
Eduardo__



Joined: 23 Nov 2011
Posts: 197
Location: Brazil

View user's profile Send private message

PostPosted: Sun Jan 26, 2014 7:02 am     Reply with quote

Wrong! Do not change header or driver file. It will stop working.

Header file determines the comands, addresses and constants alias.
Header file is just an alias file. Check enum and #define in CCS help file.


apply the commands inside your program.
_________________
Eduardo Guilherme Brandt
yuripace



Joined: 26 Nov 2013
Posts: 21

View user's profile Send private message

PostPosted: Sun Jan 26, 2014 7:12 am     Reply with quote

Eduardo__ wrote:
Check enum and #define in CCS help file.
apply the commands inside your program.

I dont uderstand Smile

So i have to change only the RF24_default_config function to make the driver working?
or you mean i have to write a similar function in my program?
Eduardo__



Joined: 23 Nov 2011
Posts: 197
Location: Brazil

View user's profile Send private message

PostPosted: Sun Jan 26, 2014 10:57 am     Reply with quote

yes, I suggest you copy RF24_default_config() to your program, and change function name and parameters as you want to.

Try to not change driver files(only change if you want to improve something or fix some bug, in this case a new release).
_________________
Eduardo Guilherme Brandt
kemalsati



Joined: 29 Jan 2014
Posts: 1

View user's profile Send private message

hi
PostPosted: Wed Jan 29, 2014 8:41 pm     Reply with quote

my friends i am so sorry for my bad english
i have some problem about your library
when i try to buld your cod i have same error about like this
--- Info 300 "C:\Program Files\PICC\Devices\16F877A.h" Line 488(11,25): More info: First Declaration of tx_buffer_full
*** Error 31 "C:\Program Files\PICC\Drivers\nRF24L01P.h" Line 93(4,18): Identifier is already used in this scope
*** Error 43 "C:\Program Files\PICC\Drivers\nRF24L01P.h" Line 93(23,33): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\nRF24L01P.h" Line 93(33,34): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\nRF24L01P.h" Line 93(34,35): Expecting a declaration
*** Error 27 "C:\Program Files\PICC\Drivers\nrf24l01p.c" Line 229(33,39): Expression must evaluate to a constant ::
5 Errors, 0 Warnings.
Build Failed.
Eduardo__



Joined: 23 Nov 2011
Posts: 197
Location: Brazil

View user's profile Send private message

PostPosted: Thu Jan 30, 2014 4:25 am     Reply with quote

Kemalsati, probably you did not used the expression

Code:
#device PASS_STRINGS=IN_RAM


See later posts,.. someone have had the same problems than you and it was solved.
_________________
Eduardo Guilherme Brandt
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 ... 12, 13, 14 ... 18, 19, 20  Next
Page 13 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