|
|
View previous topic :: View next topic |
Author |
Message |
Eduardo__
Joined: 23 Nov 2011 Posts: 197 Location: Brazil
|
|
Posted: Thu Jan 24, 2013 2:58 pm |
|
|
Hi deszo,
What means "PSup 3.6v" ?
You must supply it below 3.6V.
I´m using Mplab 8.7 yet. I´ve a program using this driver for several days(I´m using 2 NiMH batteries, suplying 2.4V). It transmits each 10s and then it sleeps. It is several days and it not reseted or stuck yet. _________________ Eduardo Guilherme Brandt |
|
|
dezso
Joined: 04 Mar 2010 Posts: 102
|
|
Posted: Fri Jan 25, 2013 1:19 am |
|
|
This is just so strange..
Firs and second pic show the SPI com with the driver from the link in my previous post.
Third pic show your PIC16F876A test, don't understand why SPI behave this way. Both setup use Hardware SPI, so the SDI/SDO/CLK cannot be messed up..CE&CS set up as described, PIN_C1/C2
Generally I don't use a lot of 3.3v device, my bench got 5v output so I just used a 317 v-reg with fixed res to 3.6v, now its changed to 3.3v, that did not fixed it tho.
_________________ I'm could be wrong many time's, at least I know what I'm doing |
|
|
Eduardo__
Joined: 23 Nov 2011 Posts: 197 Location: Brazil
|
|
Posted: Fri Jan 25, 2013 8:57 pm |
|
|
Try to configure SPI to use software instead of pic hardware.
I´ve have little problems with hardware SPI in some CCS C versions.
Then, check it again.
thanks
Eduardo _________________ Eduardo Guilherme Brandt |
|
|
dezso
Joined: 04 Mar 2010 Posts: 102
|
|
Posted: Fri Jan 25, 2013 10:57 pm |
|
|
Can't explain it !!
Change it to software spi and worked than change it back to HW and worked again !!
_________________ I'm could be wrong many time's, at least I know what I'm doing |
|
|
Eduardo__
Joined: 23 Nov 2011 Posts: 197 Location: Brazil
|
|
Posted: Fri Jan 25, 2013 11:31 pm |
|
|
dezso, it is a mystery.
But I´m happy it worked! _________________ Eduardo Guilherme Brandt |
|
|
zamzam23
Joined: 25 Aug 2010 Posts: 47
|
can you help me pls |
Posted: Sun Jan 27, 2013 1:26 pm |
|
|
Here is my code but I cannot work it. can you check it pls?
Receiver:
Code: | #ignore_warnings 203
#include <18f4520.h>
#DEVICE *=16 PASS_STRINGS=IN_RAM //Admite ponteiros para constantes
#device ADC=10
#include <stdlib.h>
#include <math.h>
#fuses HS,NOWDT,NOBROWNOUT,NOFCMEN,NOLVP,PUT,NOWRT,NODEBUG,NOCPD,NOSTVREN,NOMCLR,PROTECT
#use delay (clock=10M)
#USE SPI(FORCE_SW , DI=PIN_C4, DO=PIN_C5, CLK=PIN_C3, MASTER, BAUD=10000000, MODE=0, BITS=8, MSB_FIRST, STREAM=STREAM_SPI) //this will set SPI in 4MHz(maximum for 16MHz Xtal. #Use SPI is a little buggy)
#define RF24_SPI_DISABLE_WARNING //for disabling nRF24 SPI warning message.
//********** DEFINE PORT NAMES
#define SPI_MISO PIN_C5 //RC4; SPI(Usar por hardware sempre que possivel)
#define SPI_MOSI PIN_C4 //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_B0 //RA5; interrupcao nRF24L01+
#define RF24_CS PIN_C2 //RC1; chipselect nRF24L01+
#define RF24_CE PIN_C1 //RC2; chipEnable nRF24L01+
#define RF24_PERFORMANCE_MODE //performance mode ON
#define RF24_SPI STREAM_SPI//Redirects SPI2 port to RS24_SPI stream
#include <nRF24L01P.C> //Driver nRF24L01+ Single Chip 2.4GHz Transceiver Driver
/**************** Process Data Packet ******************************************/
#use delay (clock=10000000)
//*********************************** ANA PROGRAM FONKSİYONU********************
void main ()
{
int RXbuffer1[32];
int RXdatasize, RXpipe;
RF24_initPorts();
RF24_default_config();
RF24_RX_SET(); //Receiver on
while(true)
{
while(RF24_RX_getbuffer(&RXpipe,&RXdatasize,RXbuffer1)!=true)
{
output_bit(pin_a0,1);
}
while(1);//for just test
}
}
|
transmitter:
Code: | #ignore_warnings 203
#include <18f4520.h>
#device ADC=10
#DEVICE *=16 PASS_STRINGS=IN_RAM //Admite ponteiros para constantes
#fuses HS,NOWDT,NOBROWNOUT,NOFCMEN,NOLVP,PUT,NOWRT,NODEBUG,NOCPD,NOSTVREN,NOMCLR,PROTECT
#use delay(clock=10M)
#USE SPI(FORCE_SW , DI=PIN_C4, DO=PIN_C5, CLK=PIN_C3, MASTER, BAUD=10000000, MODE=0, BITS=8, MSB_FIRST, STREAM=STREAM_SPI)
#define RF24_SPI_DISABLE_WARNING //for disabling nRF24 SPI warning message.
#include <stdlib.h>
#include <math.h>
#define buton pin_e1
//********** DEFINE PORT NAMES
#define SPI_MISO PIN_C5 //SPI(Usar por hardware quando possivel)
#define SPI_MOSI PIN_C4 //SPI(Usar por hardware quando possivel)
#define SPI_CLK PIN_C3 //SPI(Usar por hardware quando possivel)
//Driver nRF24L01P.C
#define RF24_IRQ PIN_B0 //interrupcao nRF24L01+
#define RF24_CS PIN_C2 //chipselect nRF24L01+
#define RF24_CE PIN_C1 //chipEnable nRF24L01+
#define RF24_PERFORMANCE_MODE //performance mode ON
#define RF24_SPI STREAM_SPI//Redirects SPI2 port to RS24_SPI stream
#include <nRF24L01P.C> //Driver nRF24L01+ Single Chip 2.4GHz Transceiver Driver
//-------------------------{}----------------------------
#use delay(clock=10M)
void main()
{
int bbuf[40];
RF24_initPorts();
RF24_default_config();
RF24_TX_SET();
while(1)
{
if(input(buton))
{
while(input(buton));
output_bit(led, 1);delay_ms(1000);//test
bbuf[0] = 0b00110011;
RF24_TX_putbuffer(true,1,bbuf[0]);
output_bit(led, 0);
}
}
}
|
Last edited by zamzam23 on Sun Jan 27, 2013 4:25 pm; edited 1 time in total |
|
|
Eduardo__
Joined: 23 Nov 2011 Posts: 197 Location: Brazil
|
|
Posted: Sun Jan 27, 2013 4:22 pm |
|
|
It´s simple:
Code: |
if ( RF24_RX_getbuffer(&RXpipe, &RXdatasize, RXbuffer1)!=true ) {
//Congratulations, you receive data
//Read data from RXbuffer1 and use it as ou want
//So RXbuffer1 contains the data(pointer or array),
//RXdatasize contains datasize(1 to 23 bytes) and
//RXpipe contains the number of the pipe that you
//received the data, as each nRF24 pipe has one
//different address that you can change(nRF24
//has 6 pipes, pipe 0 to 5)
}
|
You must to check whether you received any data from RF and use it in your program.
I usualy check it several times a second.
As nFR has triple 32bytes buffer, you´re able to receive up to 3 packets without PIC CPU intervention. If you receive 3 packets, your nRF24 buffer is full and you´re not able to receive more data if you not read it using the example above.
Good luck. _________________ Eduardo Guilherme Brandt
Last edited by Eduardo__ on Sun Jan 27, 2013 4:28 pm; edited 3 times in total |
|
|
zamzam23
Joined: 25 Aug 2010 Posts: 47
|
|
Posted: Sun Jan 27, 2013 4:25 pm |
|
|
I have updated my previous message in the same time you write. pls check my message. |
|
|
Eduardo__
Joined: 23 Nov 2011 Posts: 197 Location: Brazil
|
|
Posted: Sun Jan 27, 2013 4:30 pm |
|
|
have you tried to use example programs? Try with example progams first as I´ve already tested them. _________________ Eduardo Guilherme Brandt |
|
|
zamzam23
Joined: 25 Aug 2010 Posts: 47
|
|
Posted: Sun Jan 27, 2013 4:37 pm |
|
|
I didnT try with 16f628 and 16F876 as your example but I though that I can work with 18F too.
the first point is that, when I use the "ICD=TRUE", my fuses closed by complier. so I deleted this code but still I cannot receive any data. actually, I donT know tranciver is work true or not.
I have used your same code in examples.just as differ, defined the pins as 18F.
How can I be sure, my tranciver is working or not? |
|
|
Eduardo__
Joined: 23 Nov 2011 Posts: 197 Location: Brazil
|
|
Posted: Sun Jan 27, 2013 4:47 pm |
|
|
See previous page in this topic. Look for RF24_check_config() function. _________________ Eduardo Guilherme Brandt |
|
|
Hexadec
Joined: 09 Jan 2013 Posts: 7
|
|
Posted: Sun Jan 27, 2013 6:16 pm |
|
|
Here's my setup code for an 18F device which works well with Eduardo's code unchanged.
Code: | /***** D E F I N E S *********************************************************/
#define RF24_IRQ PIN_B2 //pin35
#define RF24_CS PIN_B5 //pin38
#define RF24_CE PIN_B3 //pin36
#define SPI_CLK PIN_B1 //pin35
#define SPI_MISO PIN_B0 //pin33
#define SPI_MOSI PIN_C7 //pin26
#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_SPI//Redirects SPI2 port to RS24_SPI stream
#define RF24_SPI_DISABLE_WARNING
#define LED PIN_A0
/* --- macros to switch on/off LED --- */
#define Led_On() output_high(LED)
#define Led_Off() output_low(LED)
#define mFlashLED {Led_On(); delay_ms(150); Led_Off(); }
/***** I N C L U D E S *******************************************************/
#include <18F4550.h>
//#include <eeprom_I2C.h>
/***** C O N F I G U R A T I O N *********************************************/
#fuses HSPLL,NOWDT,NOPROTECT,NOLVP,USBDIV,PLL5,CPUDIV1,VREGEN
#DEVICE *=16,PASS_STRINGS=IN_RAM, HIGH_INTS=TRUE
#use delay(clock=48000000)
//Setup communications modules
#USE SPI(SPI1, MASTER, BAUD=1000000, MODE=0, BITS=8, MSB_FIRST, STREAM=RF24_SPI)
//#use i2c(Master, scl=I2C_SCL, sda=I2C_SDA) // Setup software I2C Pin C6 is 25 and D2 is 21
#include <nRF24L01P.C> //Driver nRF24L01+
#include <usb_cdc.h> // Includes all USB code and interrupts, as well as the CDC API
|
HTH |
|
|
Eduardo__
Joined: 23 Nov 2011 Posts: 197 Location: Brazil
|
|
Posted: Sun Jan 27, 2013 6:23 pm |
|
|
Thanks for share with us Hexadec _________________ Eduardo Guilherme Brandt |
|
|
zamzam23
Joined: 25 Aug 2010 Posts: 47
|
|
Posted: Sun Jan 27, 2013 7:05 pm |
|
|
thank you. I am still working on it.
1-)Hexadec,in your code,
#USE SPI(SPI1, MASTER, BAUD=1000000, MODE=0, BITS=8, MSB_FIRST, STREAM=RF24_SPI)
is give me an error and I changed it like this:
#USE SPI(SPI1, MASTER, BAUD=1000000, MODE=0, BITS=8, MSB_FIRST, STREAM=STREAM_SPI)
the error is fixed. I cannot understand that, this code works on your 18F4550 but not work my 18F4520. what is the reason?
2-)I am using this mini kit at the picture.
is the pin configurations right?
3-)I connected the pins directly to the microcontroller.is this right?
|
|
|
Hexadec
Joined: 09 Jan 2013 Posts: 7
|
|
Posted: Mon Jan 28, 2013 3:54 am |
|
|
Quote: | code works on your 18F4550 but not work my 18F4520. what is the reason? |
The STREAM= is only naming the stream for the protocol.
What error message do you get and have you defined RF24_SPI?
The pinout you show is the same as the modules I am using.
Have you noticed that the pin configuration is:-
2 4 6 8
1 3 5 7
The pins are connected directly to the MCU |
|
|
|
|
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
|