|
|
View previous topic :: View next topic |
Author |
Message |
hassasian
Joined: 05 Jul 2015 Posts: 3
|
|
Posted: Sun Aug 09, 2015 6:08 am |
|
|
dezso wrote: | After checking this code now I see that I'm not using hardware SPI, its a simple bit-bang SPI communication.
If you use the F628A chip than it should work fine, if you using different chip than please check to be sure your ports are configured properly. |
I'm using 16f628a. And I'm using the code which I send the upper post. I have 2 16f628a, one of them sender, one of them receiver. But this doesn't work. What did you mean with saying be sure your ports are configured properly??
Here is my connections:
CE -> RA0
CSN -> RA1
SCK -> RA2
MOSI-> RA3
MISO-> RA4
IRQ -> B0
Same as my code as you see.
For explain on receiver (RX mode) irq pin from nrf always giving 3.3v. I have a problem but I cannot find it. I have just 4 more days for solve this problem. I'm waiting for your answer. Sincerely. |
|
|
tienchuan
Joined: 25 Aug 2009 Posts: 175
|
|
Posted: Wed Aug 12, 2015 11:59 pm |
|
|
Hi everyone:)
I have a problem when using this driver to test with NRF24L01+ module, using PIC16LF1455, CCS C ver5.044
I am using the examples in this driver, but maybe have an error in checking IRQ pin status.
If i put a comment line in below, the code can run in main loop, otherwise, it stops in here, because the IRQ does not change state when sending a msg out (it is still at a high level, don't go to low level)
Code: | while(RF24_IRQ_state()==false); |
Here is my test program. I using the driver copied from page 1 of this topic, and only edit with put comment at all rv = spi_read2();
Code: |
#include "16LF1455.h"
#DEVICE *=16 PASS_STRINGS=IN_RAM
#fuses HS,PUT,PROTECT,NOLVP,NOWDT,NOPROTECT, NOBROWNOUT, NOCLKOUT, NOIESO, NOFCMEN, NOWRT, NOCPUDIV, NOPLLEN, NOLPBOR, NODEBUG
#use delay(internal=16000000)
#define RF24_SPI STREAM_SPI
#USE SPI( FORCE_SW, MASTER, DI=PIN_C2, DO=PIN_C1, CLK=PIN_C0, BAUD=10000000, MODE=0, BITS=8, MSB_FIRST, STREAM=RF24_SPI)
#use fast_io(c)
#define SPI_MISO PIN_C2 //RC2,RP13; SPI(Usar por hardware)
#define SPI_MOSI PIN_C1 //RC7,RP18; SPI(Usar por hardware)
#define SPI_CLK PIN_C0 //RB0,RP3; SPI(Usar por hardware)
//Driver nRF24L01P.C
#define RF24_IRQ PIN_C3 //RC5,RP16; interrupt nRF24L01+
#define RF24_CS PIN_A1 //RB1,RP4; chipselect nRF24L01+
#define RF24_CE PIN_A0 //RB2,RP5; chipEnable nRF24L01+
#define RF24_PERFORMANCE_MODE //performance mode ON
#define RF24_SPI_DISABLE_WARNING
#include "nRF24L01P.c"
void main(void)
{
delay_ms(100);
setup_oscillator(OSC_16MHZ | OSC_INTRC);
delay_ms(100);
setup_comparator(NC_NC_NC_NC);
setup_vref(VREF_OFF);
setup_dac(DAC_OFF);
setup_pwm1(PWM_DISABLED);
setup_pwm2(PWM_DISABLED);
setup_adc(ADC_OFF);
//!
RF24_initPorts();
RF24_default_config();
RF24_TX_SET(); //Transmitter on
output_high(PIN_C4);
for(;;)
{
output_toggle(PIN_c4);
RF24_TX_putbuffer(false,1, "1");
while(RF24_IRQ_state()==false);
RF24_STATUS_clr_IRQs(IRQ_ALL);
//! RF24_driver_use_example_TXdata_simple(); // tried with example but not success
delay_ms(1000);
}
}
|
Pls show me way to fix this error.
Thanks you. _________________ Begin Begin Begin !!! |
|
|
dezso
Joined: 04 Mar 2010 Posts: 102
|
|
Posted: Sat Aug 15, 2015 2:26 pm |
|
|
hassasian wrote: | dezso wrote: | After checking this code now I see that I'm not using hardware SPI, its a simple bit-bang SPI communication.
If you use the F628A chip than it should work fine, if you using different chip than please check to be sure your ports are configured properly. |
I'm using 16f628a. And I'm using the code which I send the upper post. I have 2 16f628a, one of them sender, one of them receiver. But this doesn't work. What did you mean with saying be sure your ports are configured properly??
Here is my connections:
CE -> RA0
CSN -> RA1
SCK -> RA2
MOSI-> RA3
MISO-> RA4
IRQ -> B0
Same as my code as you see.
For explain on receiver (RX mode) irq pin from nrf always giving 3.3v. I have a problem but I cannot find it. I have just 4 more days for solve this problem. I'm waiting for your answer. Sincerely. |
PORTA is an 8-bit wide latch. RA4 is a Schmitt Trigger-input and an open drain output, might need pull up resistor ?
I haven't used this hardware for some time now, in fact haven't used PIC for over a year.
Do you have logic analyzer or a scope ? Check this pins make sure something going out/in _________________ I'm could be wrong many time's, at least I know what I'm doing |
|
|
pran
Joined: 10 Sep 2015 Posts: 4
|
|
Posted: Thu Sep 10, 2015 12:23 am |
|
|
Hi Eduardo and all. Currently i am using Dezso's code in my project and I have a doubt in it.
Code: |
void configure_RX()
{
int i;
RX_CSN_Low();
RX_CE_Low();;
bb_xfer(W_REGISTER); //PRX, CRC enabled
bb_xfer(0x39); //data 0b0011 1001
pulse_CSN();
delay_ms(2);
//-----------
bb_xfer(0x21); //dissable auto-ack for all channels
bb_xfer(0x00); ///
pulse_CSN();
//-----------
bb_xfer(0x23); //address width = 5 bytes
bb_xfer(0x03);
pulse_CSN();
//-----------
bb_xfer(0x26); //data rate = 1MB
bb_xfer(0x07);
pulse_CSN();
//-----------
bb_xfer(0x31); //4 byte payload
bb_xfer(0x04);
pulse_CSN();
//-----------
bb_xfer(0x25); //set channel 2
bb_xfer(0x02);
pulse_CSN();
//-----------
bb_xfer(0x30); //set address E7E7E7E7E7
for(i=0;i<=5;i++)
{
bb_xfer(0xe7); // send 5 bytes of data E7 E7 E7 E7 E7
}
pulse_CSN();
//----------------
bb_xfer(0x20); //PWR_UP = 1
bb_xfer(0x3b);
RX_CSN_High();;
RX_CE_High();
}
|
I am having doubt in this part. In this function the command W_REGISTER has been sent only once in the line, bb_xfer(W_REGISTER); bb_xfer(0x39);
Isn't it necessary to send the command W_REGISTER everytime before a databyte is sent?
In the datasheet the command format is given as,
<COMMANDWORD> <DATABYTE>
In the databyte section we have to provide the register name, right? Then where are we supposed to provide the data to be written to the register?
Please clarify the doubt. |
|
|
pran
Joined: 10 Sep 2015 Posts: 4
|
|
Posted: Thu Sep 17, 2015 4:37 am |
|
|
Hi all.I had posted in the forum with the hope of getting a reply.I would be grateful to you,if you could help me in this regard.
Thanking you in advance |
|
|
Eduardo__
Joined: 23 Nov 2011 Posts: 197 Location: Brazil
|
|
Posted: Thu Sep 17, 2015 7:54 am |
|
|
Sorry, but I'm working on my Master's degree dissertation, so I'm very busy and can not help the community till beginning next year.
Sorry for all
Eduardo _________________ Eduardo Guilherme Brandt |
|
|
Eduardo__
Joined: 23 Nov 2011 Posts: 197 Location: Brazil
|
|
Posted: Mon Oct 26, 2015 5:16 am |
|
|
From: aaronik19
To: Eduardo__
Posted: Sat Oct 24, 2015 7:22 pm
Subject: nrf24 question
Quote: | Dear Eduardo,
I saw your post about the nRF24 well done. Large code indeed!
Can I ask you something, this device is good for full mesh network? Is it possible to make individual address of nodes and broadcast messages? |
nRF24 accepts broadcast messages and up to 5 different receiving addresses. They are called pipes.
But I think that is a bit limited. It's better to implement in software a second address layer, so you will be able to accept more than 5 addresses and broadcast messages for them.
Good luck!
Eduardo _________________ Eduardo Guilherme Brandt |
|
|
lucasromeiro
Joined: 27 Mar 2010 Posts: 167
|
duvida! |
Posted: Mon Apr 11, 2016 10:32 pm |
|
|
Hello Eduardo, okay?
Brazuca friend!
Boy, I looked at your code and is very large.
I lost it.
I have a pic 16F628A and need to communicate with a nRF24L01.
The problem is that this PIC does not have a hardware SPI module or a lot of memory.
So I need to send some simple commands.
3 commands actually.
Enable 3 leds
Urgent college work.
Can you help me friend? |
|
|
Eduardo__
Joined: 23 Nov 2011 Posts: 197 Location: Brazil
|
|
Posted: Tue Apr 12, 2016 6:57 am |
|
|
Hallo Lucas!
Thats ok for PIC16F628A. I've already used this driver in this uC. Just include files as the example at the beginning of this topic (I think this example is located at page 2 of this topic).
About SPI, configure the SPI normally as software spi. It will work fine.
Sorry I've have no time to help, cause I'm very busy at this time.
Good luck friend!!! _________________ Eduardo Guilherme Brandt |
|
|
lucasromeiro
Joined: 27 Mar 2010 Posts: 167
|
ajuda |
Posted: Tue Apr 12, 2016 10:58 pm |
|
|
Eduardo__ wrote: | Hallo Lucas!
Thats ok for PIC16F628A. I've already used this driver in this uC. Just include files as the example at the beginning of this topic (I think this example is located at page 2 of this topic).
About SPI, configure the SPI normally as software spi. It will work fine.
Sorry I've have no time to help, cause I'm very busy at this time.
Good luck friend!!! |
Thank you friend!
I tried to do as asked, but could not a legal result.
Faked, but on the other side I get garbage.
Look at the code transmitter and receiver:
transmissor:
Code: |
//
#include "16F628A.H"
#DEVICE *=16 ICD=TRUE PASS_STRINGS=IN_RAM //Admite ponteiros para constantes
//#SERIALIZE(id=TR_serial_number, next="1" | file="TR_serial_number.txt" " | listfile="TR_serial_number.list", log="TR_serial_number.log")
#fuses MCLR,HS
#use delay(clock=20M)
//#use delay(clock=14.31818M) //Cristal a 20MHz (Prototipo com 14.31818MHz)
#USE SPI(FORCE_SW , DI=PIN_A4, DO=PIN_A3, CLK=PIN_A2, MASTER, BAUD=10000000, MODE=0, BITS=8, MSB_FIRST, STREAM=STREAM_SPI)
#use rs232(baud=9600,parity=N,xmit=PIN_B4,rcv=PIN_B5,bits=8)
//#use rs232(baud=115200, xmit=PIN_B4,FORCE_SW, INVERT, STREAM=DBG) //57600
#define RF24_SPI_DISABLE_WARNING //for disabling nRF24 SPI warning message.
//********** DEFINE PORT NAMES
#define SPI_MISO PIN_A4 //SPI(Usar por hardware quando possivel)
#define SPI_MOSI PIN_A3 //SPI(Usar por hardware quando possivel)
#define SPI_CLK PIN_A2 //SPI(Usar por hardware quando possivel)
//Driver nRF24L01P.C
#define RF24_IRQ PIN_B0 //interrupcao nRF24L01+
#define RF24_CS PIN_A1 //chipselect nRF24L01+
#define RF24_CE PIN_A0 //chipEnable nRF24L01+
#define RF24_PERFORMANCE_MODE //performance mode ON
#define RF24_SPI STREAM_SPI//Redirects SPI2 port to RS24_SPI stream
//INCLUDES_2 - Drivers
#include <nRF24L01P.C> //Driver nRF24L01+ Single Chip 2.4GHz Transceiver Driver
//#include <DS1307.C> //Driver RTC DS1307 I2C
//INCLUDES_3
#include <STDLIB.H>
/*******************************************************************************
*
* ====INICIO PROGRAMA====
*
*******************************************************************************/
void main() {
RF24_driver_use_example_TXdata_simple(); //Example of using RF24 driver
}
|
receptor:
Code: |
//
#include "16F628A.H"
#DEVICE *=16 ICD=TRUE PASS_STRINGS=IN_RAM //Admite ponteiros para constantes
//#SERIALIZE(id=TR_serial_number, next="1" | file="TR_serial_number.txt" " | listfile="TR_serial_number.list", log="TR_serial_number.log")
#fuses MCLR,HS
#use delay(clock=20M)
//#use delay(clock=14.31818M) //Cristal a 20MHz (Prototipo com 14.31818MHz)
#USE SPI(FORCE_SW , DI=PIN_A4, DO=PIN_A3, CLK=PIN_A2, SLAVE, BAUD=10000000, MODE=0, BITS=8, MSB_FIRST, STREAM=STREAM_SPI)
#use rs232(baud=9600,parity=N,xmit=PIN_B4,rcv=PIN_B5,bits=8)
//#use rs232(baud=115200, xmit=PIN_B4,FORCE_SW, INVERT, STREAM=DBG) //57600
#define RF24_SPI_DISABLE_WARNING //for disabling nRF24 SPI warning message.
//********** DEFINE PORT NAMES
#define SPI_MISO PIN_A4 //SPI(Usar por hardware quando possivel)
#define SPI_MOSI PIN_A3 //SPI(Usar por hardware quando possivel)
#define SPI_CLK PIN_A2 //SPI(Usar por hardware quando possivel)
//Driver nRF24L01P.C
#define RF24_IRQ PIN_B0 //interrupcao nRF24L01+
#define RF24_CS PIN_A1 //chipselect nRF24L01+
#define RF24_CE PIN_A0 //chipEnable nRF24L01+
#define RF24_PERFORMANCE_MODE //performance mode ON
#define RF24_SPI STREAM_SPI//Redirects SPI2 port to RS24_SPI stream
//INCLUDES_2 - Drivers
#include <nRF24L01P.C> //Driver nRF24L01+ Single Chip 2.4GHz Transceiver Driver
//#include <DS1307.C> //Driver RTC DS1307 I2C
//INCLUDES_3
#include <STDLIB.H>
/*******************************************************************************
*
* ====INICIO PROGRAMA====
*
*******************************************************************************/
void main() {
RF24_driver_use_example_RXdata(); //Example of using RF24 driver
}
|
Look this modification I made to the receiver fit in memory ram pic and spit me to receive the serial:
Code: |
void RF24_driver_use_example_RXdata() { //Example of using this driver
int RXbuffer1[32], RXbuffer2[32], RXbuffer3[32];
//int RXbuffer4[32], RXbuffer5[32];
int RXdatasize, RXpipe;
//int TXbuffer[40], TXdatasize; //not necessary
//int stat=0,fstat=0,retrys,lost,ret; //
//int i=false;
RF24_initPorts();
RF24_default_config();
//RF24_check_config(); //check configuration
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)
while ( RF24_RX_getbuffer(&RXpipe, &RXdatasize, RXbuffer2)!=true ); //Wait till receive data(1 to 32 bytes) into buffer(from default_config address of pipe0)
while ( RF24_RX_getbuffer(&RXpipe, &RXdatasize, RXbuffer3)!=true ); //Wait till receive data(1 to 32 bytes) into buffer(from default_config address of pipe0)
//while ( RF24_RX_getbuffer(&RXpipe, &RXdatasize, RXbuffer4)!=true ); //Wait till receive data(1 to 32 bytes) into buffer(from default_config address of pipe0)
//while ( RF24_RX_getbuffer(&RXpipe, &RXdatasize, RXbuffer5)!=true ); //Wait till receive data(1 to 32 bytes) into buffer(from default_config address of pipe0)
printf("\r\n%s",RXbuffer1);
/*while (!i) {
i=RF24_RX_getbuffer(&RXpipe, &RXdatasize, RXbuffer1); //Wait till receive data(1 to 32 bytes) into buffer(from default_config address of pipe0)
if (!i) buzzer_off();
else { buzzer_on(); delay_ms(10); buzzer_off(); }
}
i=false;*/
//RF24_STATUS_clr_IRQs(IRQ_ALL); //Allows clearing all IRQs at the same time
//fstat=RF24_FIFO_STATUS();
//stat=RF24_get_status();
//buzzer_on(); delay_ms(1); buzzer_off(); //Beepa Buzzer
delay_cycles(1);
}
|
Look what screen print happens:
Can you help me??
Thank you!!!! |
|
|
lucasromeiro
Joined: 27 Mar 2010 Posts: 167
|
|
Posted: Thu Apr 14, 2016 8:21 am |
|
|
Eduardo,
Can help me?
My whats: 71 98605-0664 |
|
|
Eduardo__
Joined: 23 Nov 2011 Posts: 197 Location: Brazil
|
|
Posted: Thu Apr 14, 2016 11:28 am |
|
|
Sorry Lucas. I´m very busy at these days. _________________ Eduardo Guilherme Brandt |
|
|
mutthunaveen
Joined: 08 Apr 2009 Posts: 100 Location: Chennai, India
|
|
Posted: Thu May 05, 2016 10:59 am |
|
|
lucasromeiro wrote: | Eduardo,
Can help me?
My whats: 71 98605-0664 |
Hi Lucas plz check if my new post fits in.. its simple to configure and works good. |
|
|
dmendesf
Joined: 31 Dec 2005 Posts: 32
|
New nrf clones |
Posted: Wed May 11, 2016 7:46 pm |
|
|
Has anyone managed to make these new nrf clones with blobs instead of chips work with this code? I still don't. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
|
|
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
|