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 CCS Technical Support

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



Joined: 09 Jan 2013
Posts: 7

View user's profile Send private message

PostPosted: Sun Feb 10, 2013 12:13 pm     Reply with quote

Eduardo's code works perfectly as it is, so it can only be a problem either with your hardware or the way you are setting up the PIC.

I only have working code for 18F26K20 and 18F4550 which you are welcome to but the only differences in my code compared to Eduardo's is the setting up of the PIC's fuses etc and the SPI modules.
dezso



Joined: 04 Mar 2010
Posts: 102

View user's profile Send private message

PostPosted: Sun Feb 10, 2013 11:59 pm     Reply with quote

Code:
#include <16F876A.H>

#device adc=10
#device ICD=TRUE
#device *=16
#device = PASS_STRINGS=IN_RAM
#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=10000000)
#USE SPI (MASTER, SPI1, BAUD=10000, MODE=0, BITS=8, STREAM=STREAM_SPI, MSB_FIRST) //this will set SPI in 4MHz(maximum for 16MHz Xtal. #Use SPI is a little buggy)
//#use rs232(baud=9600,parity=N,bits=8,stream=PORT1)
#define RF24_SPI_DISABLE_WARNING             //for disabling nRF24 SPI warning message.


Both have this exact same setting's, the only different between RX/TX is this
Code:
void main() {
   RF24_driver_use_example_RXdata();       //Example of using RF24 driver
}


Code:
void main() {
   RF24_driver_use_example_TXdata_simple();     //Example of using RF24 driver
}

both PIC running on 3.3V and connected to LA after reset this is the only com occur between PIC and NRF module
If I force the IRQ line low that is will start send other data but buffer stay empty.
I'm lost in the driver, don't really understand how it works so I guess have to look elsewhere.

Thanks anyway..


CCS1.140
_________________
I'm could be wrong many time's, at least I know what I'm doing Smile
Hexadec



Joined: 09 Jan 2013
Posts: 7

View user's profile Send private message

PostPosted: Mon Feb 11, 2013 3:29 am     Reply with quote

@dezso

Please post your full setup code including #defines, #includes and all fuse settings.

Also post the decoded version of your SPI transaction. Is it actually sending the data you expect to the SPI bus? Do you know what data it should be sending?
Eduardo__



Joined: 23 Nov 2011
Posts: 197
Location: Brazil

View user's profile Send private message

PostPosted: Mon Feb 11, 2013 5:49 am     Reply with quote

Dear Dezso,

Please, take a look at posts after Jan 28, it seems that zamzam23 have a had a problem with spi. In some cases it is necessary to rid off "rv = spi_read();" lines from driver. I put this line because I´ve had this bug with some uCs,... but it not happened with PIC16F628.

try that and good luck
_________________
Eduardo Guilherme Brandt
dezso



Joined: 04 Mar 2010
Posts: 102

View user's profile Send private message

PostPosted: Mon Feb 11, 2013 10:38 pm     Reply with quote

RX/TX same code
RF24_driver_use_example_TXdata
RF24_driver_use_example_RXdata
exception.

nRF24L01P.C/H is the exact copy of page 1 of this thread.

Eduardo I tried to remove the rv = spi_read(); lines but no effect.

Code:
#include <16F876A.H>
#device ICD=TRUE
#device *=16
#device = PASS_STRINGS=IN_RAM
#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=10000000)
//#USE SPI (MASTER, SPI1, BAUD=100000, MODE=0, BITS=8, STREAM=RF24_SPI, MSB_FIRST) //this will set SPI in 4MHz(maximum for 16MHz Xtal. #Use SPI is a little buggy)
#USE SPI (MASTER, CLK=PIN_C3, DI=PIN_C4, DO=PIN_C5, BAUD=50000, MODE=0, BITS=8, STREAM=STREAM_SPI, MSB_FIRST)
#define RF24_SPI_DISABLE_WARNING             //for disabling nRF24 SPI warning message.
//********** DEFINE PORT NAMES
#define  SPI_MISO       PIN_C4   //RC4; SPI(Usar por hardware sempre que possivel)
#define  SPI_MOSI       PIN_C5   //RC5; SPI(Usar por hardware sempre que possivel)
#define  SPI_CLK        PIN_C3   //RC3; SPI(Usar por hardware sempre que possivel)
//Driver nRF24L01P.C
#define  RF24_IRQ       PIN_A5   //RA5;  interrupcao nRF24L01+
#define  RF24_CS        PIN_C1   //RC1;  chipselect nRF24L01+
#define  RF24_CE        PIN_C2   //RC2;  chipEnable nRF24L01+
#define  RF24_PERFORMANCE_MODE   //performance mode ON
#define  RF24_SPI       STREAM_SPI//Redirects SPI2 port to RS24_SPI stream
//#define  RF24_USE_DMA            //nRF24 uses SPI DMA for multiple byte transfers
//INCLUDES_2   -  Drivers
#include <nRF24L01P.C>           //Driver nRF24L01+   Single Chip 2.4GHz Transceiver Driver
//INCLUDES_3
#include <STDLIB.H>
/*******************************************************************************/
void main()
{
    output_toggle(PIN_A0);
    delay_ms(500);
    output_toggle(PIN_A0);
    RF24_driver_use_example_TXdata_simple();     //Example of using RF24 driver
}

_________________
I'm could be wrong many time's, at least I know what I'm doing Smile
dezso



Joined: 04 Mar 2010
Posts: 102

View user's profile Send private message

PostPosted: Wed Feb 13, 2013 10:14 pm     Reply with quote

Ok
One thing I have noticed that while the LA show that NRF module returned 0x0E to the command 0x20 the rv=RF24_xfer(comm); returns 0x00

Tried software SPI or HW no change, whats wrong here Mad


_________________
I'm could be wrong many time's, at least I know what I'm doing Smile
Eduardo__



Joined: 23 Nov 2011
Posts: 197
Location: Brazil

View user's profile Send private message

PostPosted: Thu Feb 14, 2013 6:45 am     Reply with quote

sorry dezso, but now I can´t help you because I´m out of home(working). Maybe the next weak I´ll be back. I´ll answer you when I have available time.
Sorry for that.

While that, Try to check inside driver whether this is the correct behavior.
Good luck
_________________
Eduardo Guilherme Brandt
Eduardo__



Joined: 23 Nov 2011
Posts: 197
Location: Brazil

View user's profile Send private message

PostPosted: Thu Feb 14, 2013 6:47 am     Reply with quote

dezso, I suggest you get back(read) the configuration from your nRF(before or after try to send/receive data) and compare the data with the default configuration that you write when the program begins.
_________________
Eduardo Guilherme Brandt
dezso



Joined: 04 Mar 2010
Posts: 102

View user's profile Send private message

PostPosted: Thu Feb 14, 2013 3:35 pm     Reply with quote

Once I have time this weekend, I will try to make my own bit-bang SPI_xfer will see if that help.
I built this project and it works, at least I know the hardware works.
https://sites.google.com/site/proyectosroboticos/nrf24l01/16f876-nrf24l01
_________________
I'm could be wrong many time's, at least I know what I'm doing Smile
Eduardo__



Joined: 23 Nov 2011
Posts: 197
Location: Brazil

View user's profile Send private message

PostPosted: Thu Feb 14, 2013 4:25 pm     Reply with quote

I believe in CCS software SPI. Have you already tried that?
_________________
Eduardo Guilherme Brandt
dezso



Joined: 04 Mar 2010
Posts: 102

View user's profile Send private message

PostPosted: Tue Feb 19, 2013 5:56 pm     Reply with quote

I made my simple SPI xfer_read code and was able to read back all registers, is this supposed to be the default setting ?
Code:

Register 0x00 = 0x10
Register 0x01 = 0x7E
Register 0x02 = 0x06
Register 0x03 = 0x06
Register 0x04 = 0x06
Register 0x05 = 0x04
Register 0x06 = 0x1E
Register 0x07 = 0x1C
Register 0x08 = 0x00
Register 0x09 = 0x00
Register 0x0A = 0xCF
Register 0x0B = 0x85
Register 0x0C = 0x87
Register 0x0D = 0x89
Register 0x0E = 0x8B
Register 0x0F = 0x8D
Register 0x10 = 0xCF
Register 0x11 = 0x00
Register 0x12 = 0x00
Register 0x13 = 0x00
Register 0x14 = 0x00
Register 0x15 = 0x00
Register 0x16 = 0x00
Register 0x17 = 0x22

_________________
I'm could be wrong many time's, at least I know what I'm doing Smile
Eduardo__



Joined: 23 Nov 2011
Posts: 197
Location: Brazil

View user's profile Send private message

PostPosted: Tue Feb 19, 2013 9:16 pm     Reply with quote

Dear Dezso,

I'm sorry I've no time to check it for you now, but, I've a good tip for you:

1-Use default configuration (driver command) for the 1st time;
2-Check if the received data are according default configuration values.
3-Use register names instead of just the addresses. It´s better to understand what are you reading. I put an almost complete register config information in .h file

Good luck
_________________
Eduardo Guilherme Brandt
amjad_alahdal



Joined: 19 Feb 2013
Posts: 50

View user's profile Send private message Yahoo Messenger MSN Messenger

PostPosted: Tue Mar 05, 2013 1:28 am     Reply with quote

Hello Eduardo,
You've done a great job writing the library of the Transceiver, but I have problems participating with the code. Here is what I have done.
I have the header file nRF24L01P as it is. And the c file nRF24L01P as it is.
I have tried to use the code under main function
Here is my code,
Code:

#include <18f2550.h>
#DEVICE PASS_STRINGS=IN_RAM
#USE DELAY(clock=8M)
#USE SPI(SPI2, MASTER, BAUD=1000000, MODE=0, BITS=8, MSB_FIRST, STREAM=STREAM_SPI2)
#define   RF24_SPI_DISABLE_WARNING
#include<nRF24L01P.c>
//********** DEFINE PORT NAMES
#define  SPI_MISO       PIN_C2   //RC2,RP13; SPI(Usar por hardware)
#define  SPI_MOSI       PIN_C7   //RC7,RP18; SPI(Usar por hardware)
#define  SPI_CLK        PIN_B0   //RB0,RP3;  SPI(Usar por hardware)
#define  INDICACAO_LED  PIN_A1   //RA1,RP1;  just a test LED output

//Driver nRF24L01P.C
#define  RF24_IRQ       PIN_C5   //RC5,RP16; interrupcao nRF24L01
#define  RF24_CS        PIN_B1   //RB1,RP4;  chipselect nRF24L01+
#define  RF24_CE        PIN_B2   //RB2,RP5;  chipEnable nRF24L01+
#define  RF24_PERFORMANCE_MODE   //performance mode ON
//#define  RF24_USE_DMA            //nRF24 uses SPI DMA for multiple byte transfers(I´m using Hardware DMA)
#define  RF24_SPI       STREAM_SPI2//Redirects SPI2 port to RS24_SPI stream


//INCLUDES   -  Drivers
//#include <spi_dma_PIC18F2550.c>
#include <nRF24L01P.C>

void main(void)
{
   while (TRUE)
   {
      //Your code here
   }
}

Well, I could figure how to write the main function from the replies, but still I have an error in those lines :
Code:


   #ERROR pino RF24_CS nao definido



To give you a clear vision of what I want. Here is what my code and transceivers should do

send " hello there " from pic 1
receive the sentence to pic 2 and print out in the LCD " hello there "
Eduardo__



Joined: 23 Nov 2011
Posts: 197
Location: Brazil

View user's profile Send private message

PostPosted: Tue Mar 05, 2013 7:42 am     Reply with quote

Dear Mr. Al-Adhal

I´m sorry, but I think forgot to translate a part of the driver from portuguese. You can use google translate in this case.

"pino RF24_CS nao definido" is a driver error message. It means that "pin RF24_CS was not defined". In another words, you must to define every pins of the uC that are connected to nRF24 chip board.

Good luck!
_________________
Eduardo Guilherme Brandt


Last edited by Eduardo__ on Wed Mar 06, 2013 9:24 am; edited 2 times in total
amjad_alahdal



Joined: 19 Feb 2013
Posts: 50

View user's profile Send private message Yahoo Messenger MSN Messenger

PostPosted: Tue Mar 05, 2013 8:29 am     Reply with quote

Ok, Thanks.

It's strange though, because I have already defined every pins in my main file.

Thank you Eduardo
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 ... 7, 8, 9 ... 18, 19, 20  Next
Page 8 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