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  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

Re: Problem with PIC16LF88
PostPosted: Wed May 03, 2017 7:10 pm     Reply with quote

About the error "Expression must evaluate to a constante", probably you did not used the expression at the beginning of the program

Code:
#device PASS_STRINGS=IN_RAM

See later posts,.. someone have had the same problems than you and it was solved.




sebcar wrote:
Dear Eduardo,
First, thank you for driver. However, it has been a long time since i have programed on PIC, and i did not manage to compile.

First I give my scheme:

[img]https://goo.gl/photos/4XMjeoEfiauCHvBMA[/img]

I use a PIC 16LF88, the internal oscillator at 4 MHz, ICSP and 3.3V PIC.
I program on CCS v 5.008.
Secondly I have this code:

.h File
Code:

#include <16F88.h>
#DEVICE *=16    ICD=TRUE  PASS_STRINGS=IN_RAM
#device ADC=10

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES PUT                      //Power Up Timer
#FUSES NOBROWNOUT               //No brownout reset
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O

#use delay(internal=4MHz)
#use STANDARD_IO( A )
#use FIXED_IO( A_outputs=PIN_A2,PIN_A1 )


The .c file:
Code:

#include <Domotique Pic.h>
//#USE SPI (MASTER, SPI1, ENABLE=PIN_B3, MODE=0, BITS=8, STREAM=RF24_SPI)
//#USE SPI(FORCE_SW , DI=PIN_B1, DO=PIN_B2, CLK=PIN_B4,ENABLE=PIN_B3, MASTER, MODE=0, BITS=8, MSB_FIRST, STREAM=STREAM_SPI)
#USE SPI(FORCE_SW, SPI2, MASTER, BAUD=1000000, MODE=0, BITS=8, MSB_FIRST, STREAM=STREAM_SPI2)

#define BatMes    PIN_A0
#define DhCt      PIN_A1
#define BatCt     PIN_A2
#define DHT-11    PIN_A4
#define SPI_MISO  PIN_B1
#define SPI_MOSI  PIN_B2
#define RF24_CS   PIN_B3
#define SPI_CLK   PIN_B4
#define RF24_CE   PIN_B5
#define RF24_IRQ  PIN_B0
#define  RF24_PERFORMANCE_MODE   //performance mode ON
#define PGC   PIN_B6
#define PGD   PIN_B7
#define RF24_SPI STREAM_SPI2

#include <nRF24L01P.c>

void main()
{
   setup_adc_ports(sAN0);
   setup_adc(ADC_CLOCK_INTERNAL);
   setup_timer_1(T1_INTERNAL|T1_DIV_BY_8);      //2,0 s overflow

   while(TRUE)
   {
      output_high(PIN_A7);
      delay_ms(100);
      output_low(PIN_A7);
      delay_ms(100);
      RF24_driver_use_example_TXdata_simple();
   }

}

My problem is that I have to make modification into driver to compile.
I changed the code on:
Code:

int RF24_comm(int comm, int32 comm1, int commDS) {
  //commDS=datasize(1 to 32 bits)
   int rv; //rv=return value(SPI nRF24 status read value)
   RF24_select();
   RF24_xfer(comm);    //RF24 Write address/command (see RF24_addr addresses list tabble in .h file)
   rv=spi_xfer(RF24_SPI, comm1); //Write config.value or command (1 to 32 bits of data)___I CANNOT USE RF24_xfer() ALIAS BECAUSE IT NOT ACCEPTS MORE THAN 1 PARAMETER rv=spi_xfer(RF24_SPI, comm1, commDS);
   rv=spi_read2();    //It's necessary due to spi_xfer read bug
   RF24_unselect();   
   return rv;

I have to suppress commDS from spi_xfer to not have the error:
"Expression must evaluate a constant".

Second error:

In nrf24l01p.h i modify:
Code:

//Automated functions contemplated register.   
enum RF24_STATUS {   // **Status Register (In parallel to the SPI command word applied on the MOSI pin, the STATUS register is shifted serially out on the MISO pin)
   IRQ_RX_dataready  =0b01000000,   // (0)Data Ready RX FIFO interrupt. Asserted when new data arrives RX FIFOc.Write 1 to clear bit.
   IRQ_TX_datasent   =0b00100000,   // (0)Data Sent TX FIFO interrupt. Asserted when packet transmitted on TX. If AUTO_ACK is activated,this bit is set high only when ACK isreceived.Write 1 to clear bit.
   IRQ_MAX_retransmit=0b00010000,   // (0)Maximum number of TX retransmits interrupt Write 1 to clear bit. If asserted it must be cleared to enable further communication.
   IRQ_ALL           =0b01110000,   // Allows clearing all IRQs at the same time
   RX_PIPE0          =0b00000000,   // (R)(bits 3:1)Data pipe number for the payload available for reading from RX_FIFO 000-101: Data Pipe Number
   RX_PIPE1          =0b00000010,   // (R)(bits 3:1)Data pipe number for the payload available for reading from RX_FIFO 000-101: Data Pipe Number
   RX_PIPE2          =0b00000100,   // (R)(bits 3:1)Data pipe number for the payload available for reading from RX_FIFO 000-101: Data Pipe Number
   RX_PIPE3          =0b00000110,   // (R)(bits 3:1)Data pipe number for the payload available for reading from RX_FIFO 000-101: Data Pipe Number
   RX_PIPE4          =0b00001000,   // (R)(bits 3:1)Data pipe number for the payload available for reading from RX_FIFO 000-101: Data Pipe Number
   RX_PIPE5          =0b00001010,   // (R)(bits 3:1)Data pipe number for the payload available for reading from RX_FIFO 000-101: Data Pipe Number
   RX_BUFFER_EMPTY   =0b00001110,   // (R)Data pipe number for the payload available for reading from RX_FIFO 000-101: Data Pipe Number
   TX_BUFFER_FULL2    =0b00000001    // (R)(0)TX FIFO full flag. 1: TX FIFO full. 0: Available locations in TX FIFO.
   };

I have to change TX_BUFFER_FULL to TX_BUFFER_FULL2 to not have the error:
"Identifier is already used in this scope".

Are there some more errors to correct to be able to communicate as soon as possible ? I want to communicate with a Raspberry.

Thank you a lot.

Sebastien, Pic Dummy.

_________________
Eduardo Guilherme Brandt
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed May 03, 2017 8:03 pm     Reply with quote

He has PASS_STRINGS=IN_RAM in his code. It's in the 2nd line of the .h file.
I really think the problem is as I described in my post.
sebcar



Joined: 03 May 2017
Posts: 8

View user's profile Send private message

PostPosted: Thu May 04, 2017 1:50 am     Reply with quote

Yes, i agree with PCM programmer.
sebcar



Joined: 03 May 2017
Posts: 8

View user's profile Send private message

PostPosted: Thu May 04, 2017 5:41 am     Reply with quote

Hello,
It compiles now perfectly.
Nevertheless, each time i try to launch the code with a function of the library, it bugs and do not execute even function prior to the library one.

An idea
sebcar



Joined: 03 May 2017
Posts: 8

View user's profile Send private message

PostPosted: Thu May 04, 2017 6:20 am     Reply with quote

I found that my module is a fake nrf24l01. I wait for a true one and post a reply.
sebcar



Joined: 03 May 2017
Posts: 8

View user's profile Send private message

PostPosted: Wed May 10, 2017 7:25 am     Reply with quote

It seems always blocked with not naked module.
I read that some person have problem with interrupt pin blocked to one and stopping the program.
Is it solved or not ?

I try to remove pull-up.
sebcar



Joined: 03 May 2017
Posts: 8

View user's profile Send private message

PostPosted: Wed May 10, 2017 8:13 am     Reply with quote

It seems that spi never try to communicate
sebcar



Joined: 03 May 2017
Posts: 8

View user's profile Send private message

PostPosted: Wed May 10, 2017 8:49 am     Reply with quote

I try with CCS 4.
It seems to communicate now but still blocked
sebcar



Joined: 03 May 2017
Posts: 8

View user's profile Send private message

PostPosted: Thu May 11, 2017 9:51 am     Reply with quote

Avec mon 16F, j'ai l'impression que l'INT ne repasse jamais à 0.
J'ai testé avec un 18F et là cela fonctionne.

Une idée?

--------------------------

Translation:
With my 16F, I feel that the INT never returns to 0.
I tested with an 18F and there it works.

An idea?
PannetierJ



Joined: 18 Jun 2017
Posts: 31

View user's profile Send private message

Error at the compilation
PostPosted: Sun Jun 18, 2017 11:19 am     Reply with quote

Hello ,

I tried to use your library.
In the first time, I'm using Pcw 4.068
I commented this
// #include <spi_dma_PIC18F24J11.c> //PIC18F24J11 DMA driver(I have another topic with this driver. It´s not essential)

Now I have few error on the warning
-> Invalid Pre-Processor directive

Best regard
PannetierJ



Joined: 18 Jun 2017
Posts: 31

View user's profile Send private message

PostPosted: Sun Jun 18, 2017 2:23 pm     Reply with quote

It's Ok .
I change my version of compiler.
Now it's Ok

Nevertheless, I have a second problem

Undefined STREAM_SPI2
Undefined --DMA_read
Undefined --DMA_start
Undefined -- DMA_is_busy
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jun 19, 2017 10:02 am     Reply with quote

PannetierJ wrote:
Nevertheless, I have a second problem

Undefined --DMA_read
Undefined --DMA_start
Undefined -- DMA_is_busy

I'm trying to put bugs into my test program to re-create what you're doing.
So, I added this line at the top of the nRF24L01P.c file:
Code:
#define RF24_USE_DMA

That caused me to get all these error messages:
Quote:
*** Error 12 "C:\Program Files\PICC\...\nRF24L01P.c" Line 161(15,16): Undefined identifier -- DMA_read
*** Error 12 "C:\Program Files\PICC\...\nRF24L01P.c" Line 162(16,17): Undefined identifier -- DMA_start
*** Error 12 "C:\Program Files\PICC\...\nRF24L01P.c" Line 163(24,25): Undefined identifier -- DMA_is_busy
*** Error 12 "C:\Program Files\PICC\...\nRF24L01P.c" Line 180(16,17): Undefined identifier -- DMA_write
*** Error 12 "C:\Program Files\PICC\...\nRF24L01P.c" Line 181(16,17): Undefined identifier -- DMA_start
*** Error 12 "C:\Program Files\PICC\...\nRF24L01P.c" Line 182(24,25): Undefined identifier -- DMA_is_busy
*** Error 12 "C:\Program Files\PICC\...\nRF24L01P.c" Line 334(25,26): Undefined identifier -- DMA_default_config

So remove this line. Get rid of it:
Code:
#define RF24_USE_DMA


PannetierJ wrote:
Nevertheless, I have a second problem

Undefined STREAM_SPI2

Look at the end of this post. I explain how to fix that error message:
http://www.ccsinfo.com/forum/viewtopic.php?t=47351&start=269


Last edited by PCM programmer on Tue Jun 20, 2017 1:04 am; edited 1 time in total
PannetierJ



Joined: 18 Jun 2017
Posts: 31

View user's profile Send private message

PostPosted: Tue Jun 20, 2017 12:27 am     Reply with quote

Hello,

Now it's ok.
I can compile my program, without error.
I remove #define RF24_USE_DMA

Thank you
PannetierJ



Joined: 18 Jun 2017
Posts: 31

View user's profile Send private message

PostPosted: Sat Jul 08, 2017 11:54 am     Reply with quote

Hello,

Ok, now i'm trying step by step.

I have a module transmitter and Receiver.
I don't receive my message.
I'm checking with my oscilloscope. I have data on MOSI bus.

Code of Transmitter:
Code:

#include <18F2550.h>
#DEVICE *=16    /*ICD=TRUE*/ 
#device = PASS_STRINGS=IN_RAM    //Admite ponteiros para constantes

#fuses HS,NOWDT,NOLVP,CPUDIV1
#use delay(clock=16000000)


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


#define Led_Send PIN_A3
#define Led_Init PIN_A4
//********** DEFINE PORT NAMES
#define  SPI_MISO       PIN_B0   //SPI(Usar por hardware quando possivel)
#define  SPI_MOSI       PIN_C7   //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=STREAM_SPI2)


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


//INCLUDES_3
#include <STDLIB.H>


void main()
{
   output_high(Led_Init);
   RF24_initPorts();
   RF24_default_config();
 
   RF24_TX_SET();       //Transmitter on
   output_low(Led_Init);
   while(true)
   {
      output_high(Led_Send);
      RF24_TX_putbuffer(false,11,"Hello World");
      output_low(Led_Send);
      delay_ms(500);
   }
}



Code of my Receiver
Code:

#include <18F2550.h>
#DEVICE *=16    /*ICD=TRUE*/ 
#device = PASS_STRINGS=IN_RAM    //Admite ponteiros para constantes

#fuses HS,NOWDT,NOLVP,CPUDIV1
#use delay(clock=16000000)
#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7,ERRORS)

 

#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=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;
   
   printf("Initialisation of system in progress\r\n");
   RF24_initPorts();
   RF24_default_config();
 
   RF24_RX_SET();       //Transmitter on
   printf("Initialisation of system\r\n");
   
   RF24_RX_SET();       //Receiver on
   while(true) {
     
      while ( RF24_RX_getbuffer(&RXpipe, &RXdatasize, RXbuffer1)!=true );   
     printf(RXBuffer1[0]);
     
   }
   }



I checked the data on my transmitter: MOSI bus:



The problem can be the config of my SPI ?
my Fuse ?

Thank you
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Jul 09, 2017 7:45 am     Reply with quote

If you want help, you would get better results if you post in the main CCS
forum. Most people assume the original thread author will answer
questions about his code in the Code Library forum. So most other
people won't help you here. If the original guy doesn't want to help,
you are out of luck.

I suggest that you re-post your latest post in the main forum and provide
a link to this Code Library thread at the start, so people know what you
are doing:
nRF24L01+ full driver by Eduardo Guilherme Brandt

And post a few comments on what you expect to see in the SPI data
and what is wrong with your actual data. For example, is your complaint
that you don't like the 0xFF and/or the 0xA0 ? If so, put that information
into your post.
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  Next
Page 19 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