need help coding NRF24L01. What am I missing?


Closed Thread
Results 1 to 7 of 7

Hybrid View

  1. #1

    Question need help coding NRF24L01. What am I missing?

    OK first off I know my code is horrible and I have no intention of becoming a professional coder so I'm not going to change that. But to the point, I'm trying to send the number 1, wait a second, the number 2, wait a second, the number 3 then repeat, and have an LED light up based on the # received. I haven't gotten a response from the receiving end no matter what I try. What am I missing here? FYI the most complex thing I've interfaced before these is a 1kbit i2c eeprom so this is a bit over my head. The LED for the number 2 does light up dimly whenever power is connected. Power supply is 3.3 volts. Do these need pull up/down resistors? Did I miss a register? How do I select the data pipe to use, or the addres to send to? I couldn't find any answers in the datasheet or the diyembedded tutorial, and the code examples I have found have all used hardware level SPI and been beyond my understanding.

    The address for pipe 1 is "aaaaa" and I've tried to disable every advanced feature on the chip to simplify things. By the way, when I copied and pasted the code, it cut off the first part of my commands. (101010 turns into 101010) WTF??


    TX code:
    Code:
    define osc 4
    
    
     a var byte
     csn var portc.1
    transmit var portc.3
    so var portc.5
    si var portc.2
    sck var portc.4
    high csn
    pause 100
    low transmit
    
    low csn
    shiftout si, sck, 0, [10000, 000000]
    high csn
    pause 5
    low csn
    shiftout si, sck, 0, [101010, "a", "a", "a", "a", "a"]
    high csn 
    pause 5
    low csn
    shiftout si, sck, 0, [110001, 000001]
    high csn 
    
    
    
      do
     low csn
    shiftout si, sck, 0, [100000,  "a", "a", "a", "a", "a", 000001]
    high csn
    high transmit
    pause 10
    low transmit
    pause 1000
    
     low csn
    shiftout si, sck, 0, [100000,  "a", "a", "a", "a", "a", 000010]
    high csn
    high transmit
    pause 10
    low transmit
    pause 1000
    
     low csn
    shiftout si, sck, 0, [100000, "a", "a", "a", "a", "a", 000011]
    high csn
    high transmit
    pause 10
    low transmit
    pause 1000
     
     
      
      
      
      loop

    RX code:
    Code:
     define osc 4
     #config
     __config H'3F46' 
    #endconfig
    
     a var byte
     csn var porta.2
    receive var portb.0
    so var portb.3
    si var portb.2
    sck var portb.1
    
    high csn
    pause 100
    
    low csn
    shiftout si, sck, 0, [10000, 000000]
    high csn
    pause 5
    low csn
    shiftout si, sck, 0, [101010, "a", "a", "a", "a", "a"]
    high csn 
    pause 5
    low csn
    shiftout si, sck, 0, [110001, 000001]
    high csn 
     
    
      do
     low receive 
      low csn
    shiftout si, sck, 0, [100000,  "a", "a", "a", "a", "a", 010101]
    shiftin so, sck, 0, [a]
    high csn
    high receive
    
    
    
    pause 10
      
      
      
      if a = 1 then
      high portb.4
      low portb.5
      low portb.6
      elseif a = 2 then
      high portb.5
      low portb.4
      low portb.5
      elseif a = 3 then
      high portb.6
      low portb.4
      low portb.5
      else
      high portb.4
      high portb.5
      high portb.6
      endif
      
      pause 20
     
     
      
      loop

  2. #2
    Join Date
    Oct 2004
    Posts
    440


    Did you find this post helpful? Yes | No

    Default Re: need help coding NRF24L01. What am I missing?

    rudyauction509

    See other basic nRF24L01 post #16 for code example.

    Norm

  3. #3


    Did you find this post helpful? Yes | No

    Default Re: need help coding NRF24L01. What am I missing?

    I can't. I need their compiler to open it. Can you post it here?

  4. #4
    Join Date
    Oct 2004
    Posts
    440


    Did you find this post helpful? Yes | No

    Default Re: need help coding NRF24L01. What am I missing?

    Quote Originally Posted by rudyauction509 View Post
    I can't. I need their compiler to open it. Can you post it here?
    rudyauction509

    You should only need to register.
    The code isn't mine to post.

    Norm

  5. #5


    Did you find this post helpful? Yes | No

    Default Re: need help coding NRF24L01. What am I missing?

    Never mind, my computer didn't recognise the .bas file so I opened it directly through microcode studio. However I'm still completely lost. I have no idea what's going on in the code, however it appears they are using hardware spi like all of the other examples. None of the commands used for data transfer are familiar. Looking through my posted code, can anyone see why I'm not getting results?

    By the way, the tx picmicro is a 16f886 and the rx picmicro is a 16f819.

  6. #6


    Did you find this post helpful? Yes | No

    Default Re: need help coding NRF24L01. What am I missing?

    I just spent another 3 long hours researching and found another half dozen code examples but all of them were once again for pic18f series with hardware spi and other external parts I don't have access to and I don't have enough experience to understand the commands. So can anyone help with specifically shiftin/shiftout and pic16f series code examples or point out anything I may have missed? And again, how do pipes and addressing work exactly? Do I send the Rx address before the data or the pipe number??? Is it a separate command? I have a feeling that that's where the problem is.

  7. #7
    Join Date
    Oct 2004
    Posts
    440


    Did you find this post helpful? Yes | No

    Default Re: need help coding NRF24L01. What am I missing?

    rudyauction509

    See other basic Re: nRF24L01 again this time post #17 for a 16F88 Shout and Shin (no SPI) version of code.
    To open with microcode studio first simply change the file extension from .bas to .pbp as the file is only text.

    Their is some porting to be done however taken command by command it can be done as the terms are quite similar.

    Norm

Similar Threads

  1. More NRF24L01+ questions on programming
    By longpole001 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 22nd June 2012, 07:12
  2. Software based SPI For use on Nordic NRF24L01
    By longpole001 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 29th April 2012, 01:49
  3. Nordic Key Fob and nRF24L01+
    By Del Tapparo in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 8th July 2010, 18:26
  4. Nordic nRF24L01
    By Ron Marcus in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 15th February 2009, 16:19
  5. need help in coding..
    By daphne8888 in forum mel PIC BASIC
    Replies: 1
    Last Post: - 19th March 2008, 07:31

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts