|
|
View previous topic :: View next topic |
Author |
Message |
kenvinh
Joined: 13 Jun 2012 Posts: 12
|
|
Posted: Thu Jun 14, 2012 10:35 am |
|
|
Yeah, thanks, I will try to use software spi and disable every line of spi_read() like you said.
By the way, I don't have my own debugger, so I use printf function there only to check the spi_xfer() get stuck or not, because I think after writing command to nRF24L01 successfully it will inform me on rs232. Is this the right way? |
|
|
Eduardo__
Joined: 23 Nov 2011 Posts: 197 Location: Brazil
|
|
Posted: Thu Jun 14, 2012 5:12 pm |
|
|
driver not sends anything automaticaly through RS232.
Yes, you can use printf and a serial output to "see" some data value.
I´ve already programed pic without debugger. I may say you that you will expend more than twice time to found an error without debugger. I strongly recomend you buy one. This is not expensive fo PIC. Just U$89,00 the U64 from CCS.
See http://www.ccsinfo.com/product_info.php?products_id=icd_u64
Good luck _________________ Eduardo Guilherme Brandt |
|
|
kenvinh
Joined: 13 Jun 2012 Posts: 12
|
|
Posted: Fri Jun 15, 2012 4:22 am |
|
|
Thanks for your suggestion, now I can get rid of the stucking position by using software spi and disable all the line with spi_read2() and it's really exciting to see it can get through:
Code: | #USE SPI(DI=PIN_C4, DO=PIN_C5, CLK=PIN_C3,ENABLE=PIN_C0, MASTER, BAUD=5000000, MODE=0, BITS=8, MSB_FIRST, STREAM=RF24_SPI) |
After that, I run the function RF24_check_config() (after the RF24_default_config())to make sure the value in the register is what i expected to see. And as usual, I insert some line in header file to see what's it real value by using rs232 to display the bbuf value.
Code: |
void RF24_check_config() { //Check actual configuration(only for debugging purposes, stop in each delay)
int bbuf[40];
RF24_comm_in(R_REGISTER|CONFIGURATION, bbuf, 1);//EN_CRC|CRC16|PWR_UP); //RF_packet CRC and nRF24L01+ configuration and initialization
printf("%u",bbuf); // It display 67
bbuf = 0;
delay_ms(5000);
RF24_comm_in(R_REGISTER|EN_AUTOACK, bbuf, 1); //0b00011111); //autoack in pipe 0,1,2,3,4 and 5
printf("%u",bbuf);
bbuf = 0;
delay_ms(5000);
RF24_comm_in(R_REGISTER|EN_RXPIPES, bbuf, 1); //0b00000011); //****enable only pipes 0 and 1(pipes 2 to 5 are not used)
printf("%u",bbuf);
bbuf = 0;
delay_ms(5000);
|
And all the value I receive is 67, I have no idea what this value come from? But it the same for every register value.
I don't know if there's still any problem with SPI communication. I'm trying to figure out |
|
|
Eduardo__
Joined: 23 Nov 2011 Posts: 197 Location: Brazil
|
|
Posted: Fri Jun 15, 2012 8:32 am |
|
|
You should printf the value bbuf[0] and not the value of the pointer bbuf, that could be 67 or any other memory address).
See RF24_default_config() values to see what is expected to see when you check configuration.
Another thing: Use directive FORCE_SW in SPI.
Software spi can not manage more than 1MHz(you programmed 5MHz)... it is very difficult to achieve. _________________ Eduardo Guilherme Brandt |
|
|
kenvinh
Joined: 13 Jun 2012 Posts: 12
|
|
Posted: Sat Jun 16, 2012 4:55 am |
|
|
Hi Eduardo,
I'm trying to check back my spi connection on forum.
I'll post back when I solve it. Thanks |
|
|
mrdongus
Joined: 18 Jun 2012 Posts: 2
|
version of CCS and nRF24L01 |
Posted: Mon Jun 18, 2012 2:27 pm |
|
|
Hi Eduardo.
Can I use your code with module nRF24L01 (not nRF24L01+). My CCS C is version 4.120 Can I use this to write code with your library ?
Thank you ! |
|
|
Eduardo__
Joined: 23 Nov 2011 Posts: 197 Location: Brazil
|
|
Posted: Mon Jun 18, 2012 2:58 pm |
|
|
Of course yes.
The unique difference between nRF24L01 and nRF24L01+ is that nRF24L01 will not be able to support 2Mbps RF data transfers(only 256kbps or 1Mbps).
So change datarate configuration to less than 2Mbps. You may change default_config() function directly, also.
Best Wishes _________________ Eduardo Guilherme Brandt |
|
|
kenvinh
Joined: 13 Jun 2012 Posts: 12
|
|
Posted: Tue Jun 19, 2012 6:40 pm |
|
|
My module is also nRF24L01, and as the specification I read, it can also reach the 2mbps rate, only the nRF2401 is limited at 1mbps.
As far as I know when reading the datasheet, the reason nRF24L01 not "recommended for new design" is its commands and registers arrangement.
For example, when I use Eduardo code, before I can use R_RX_PL_WID, W_ACK_PAYLOAD or W_TX_PAYLOAD_NOACK, I have to issue the command ACTIVATE followed by data 0x73 but in nRF24L01+, you can use those 3 commands directly
The different working mode is still frustrating me. Is the transmitter search for a "suitable" receiver before trasmitting? The FIFO is used for every mode? |
|
|
Eduardo__
Joined: 23 Nov 2011 Posts: 197 Location: Brazil
|
|
Posted: Wed Jun 20, 2012 7:51 am |
|
|
Thanks Kevinh!
I did not know about that. There is some more difference? Only that?
But, despite of that command, nRF24L01 is RF compatible untill 1Mbps with nRF24L01+, isn´t it?
thanks a lot! _________________ Eduardo Guilherme Brandt |
|
|
Eduardo__
Joined: 23 Nov 2011 Posts: 197 Location: Brazil
|
|
Posted: Wed Jun 20, 2012 7:53 am |
|
|
Kevinh.
I think you mean you module is also nRF24L01+(plus), not nRF24L01, isn´t it? _________________ Eduardo Guilherme Brandt |
|
|
kenvinh
Joined: 13 Jun 2012 Posts: 12
|
|
Posted: Wed Jun 20, 2012 10:05 am |
|
|
Yes, Eduardo, your code is mostly compatible with my nRF24L01.
The differences at the command is like I said.
About the register, there's also some differences:
1. At RF_SETUP (0x06): nRF24L01+ has CONT_WAVE and it can set 250kpbs, 1 or 2Mbps; but the older don't have CONT_WAVE and can set 1 or 2Mbps only. Can you explain me the CONT_WAVE usage, I see you disable it in your code.
2. At RPD (0x09): nRF24L01 has that register with the name CD (Carrier detect), its functionality isn't mentioned well as thats in nRF24L01+
That's all the differences I know between these two modules, I'm still trying to understand well the operation of this RF module. It's really interesting though
Here's the link to nRF24L01.
http://www.nordicsemi.com/eng/Products/2.4GHz-RF/nRF24L01 |
|
|
Eduardo__
Joined: 23 Nov 2011 Posts: 197 Location: Brazil
|
|
Posted: Wed Jun 20, 2012 10:30 am |
|
|
In continuous wave mode, the RF transmitter is transmitting continuously, without any data.
You can use it just to check signal strength(with a spectrum analyzer) or any other tests you want to check transmitter circuit operation.
for that, use the command:
Code: | RF24_waveout_testing(int channel) ; //TX is always on transmitting sinc signal
|
--------------------
RPD? Yes, you can check it. it will tell you whether there is RF signal(over -65dB) on-air in the current selected channel.
use the command:
Code: | RF24_RX_power_detector() //Returns 1 if power is over -65dbm (RPD bit)
|
_________________ Eduardo Guilherme Brandt |
|
|
kenvinh
Joined: 13 Jun 2012 Posts: 12
|
|
Posted: Wed Jun 20, 2012 10:35 am |
|
|
Ok, I got it, thanks |
|
|
kenvinh
Joined: 13 Jun 2012 Posts: 12
|
|
Posted: Fri Jun 22, 2012 9:09 am |
|
|
Hi, Eduaro.
After spending some time checking back my spi connections. I found out some mistakes and now I'm sure my spi connection is ok now (I made communication with 25LC256 eeprom)
I backed on my nRF24L01 modules, I checked all the configuration by some LEDs, and it's showing the correct default configurations.
So I made a simple test, one 18F4550 as receiver and one 18F4550 as a transmitter sending repeatedly 1 byte data.
Transmitter code: (I used leds to indicate the progress)
Code: |
int bbuf[40];
//Initialization
RF24_initPorts();
output_d(0xAA);
delay_ms(500);
output_d(0);
delay_ms(100);
//Write configuration
RF24_default_config();
output_d(0xAA);
delay_ms(500);
output_d(0);
delay_ms(100);
//Set TX mode
RF24_TX_SET();
output_d(0xAA);
delay_ms(500);
output_d(0);
delay_ms(100);
while(true)
{
output_d(0b11000011); // Indicating it's transmitting
delay_ms(500);
output_d(0);
delay_ms(100);
bbuf[0] = 0b00110011;
RF24_TX_putbuffer(true,1,bbuf[0]);
delay_ms(100);
}
}
|
Receiver code: (Again the leds were used to indicating waiting)
Code: |
int RXbuffer[40];
int RXdatasize, RXpipe;
//Initialization
RF24_initPorts();
output_d(0xAA);
delay_ms(500);
output_d(0);
delay_ms(100);
//Write configuration
RF24_default_config();
output_d(0xAA);
delay_ms(500);
output_d(0);
delay_ms(100);
//Set RX mode
RF24_RX_SET();
output_d(0xAA);
delay_ms(500);
output_d(0);
delay_ms(100);
while(true)
{
while(RF24_RX_getbuffer(&RXpipe,&RXdatasize,RXbuffer)!=true)
{
output_d(255);
delay_ms(100);
output_d(0);
delay_ms(100);
} //All leds blinking while waiting
output_d(RXbuffer[0]); //If data received, it will display 0b00110011
delay_ms(50);
}
}
| .
As both leds on transmitter and receiver were blinking, I did assume that transmitter was doing his job and receiver just keep waiting, I don't know why it can't receive any data.
Where did I make mistake? My SPI is running at 3MHz, and both is working at MODE=0 |
|
|
UenX
Joined: 16 Aug 2012 Posts: 6
|
|
Posted: Thu Aug 16, 2012 8:41 am |
|
|
Hi Eduardo.
(First, sorry for my bad English)
I'm working on a nRF24L01 project and I am so happy I found your CCS driver.
I'm testing transmitting on a PIC18F4550 ( using a 16x2 charracter LCD for debugging ) and receiving on a PIC18F2550 ( using a LED for debugging );
Transmitting seems OK, cause there was some changes on interrupt pin (IRQ) ( 0 --> 1) after sending data.
But receiver couldn't catch any thing in the air. It stucks in the "while(read buffer )"
I had done some check on transmitter 's config using your check_config() function
I tried to output bbuf[0] :
Code: | // convert int8 to binary and output to LCD
void outputAsBin(int8 val)
{
int8 mask=128;
while (mask)
{
if (mask & val) lcd_putc('1');
else lcd_putc('0');
mask /= 2;
}
}
void RF24_check_config() {
///.....
RF24_comm_in(R_REGISTER|CONFIGURATION, bbuf, 1); //EN_CRC|CRC16|PWR_UP) --> which is 0000 1110; //RF_packet CRC and nRF24L01+ configuration and initialization
// output result of reading config register and delay 5 seconds for viewing
lcd_putc("\fConf="); outputAsBin(bbuf [ 0 ]); delay_ms(5000); |
----> the LCD displays "Conf = 0000 0100" and the same for AUTO_ACK, ADDRESS_WITDTH......
Can you help me out of this? Thank you.
UPDATE:
The code runs fine after I made some changes in your nRF24L01P.c :
replace all "spi_read2" calls by "spi_read" |
|
|
|
|
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
|