nRF24L01 carrier wave

Discussion about wireless devices

nRF24L01 carrier wave

Postby Jonil » Sat Dec 20, 2008 8:40 pm

Hi,

I try to configure the nRF24L01 to output the carrier wave constantly. There is a description
on page 68 in datasheet how to do it. However, I can't get it to work, i.e. the nRF24L01 does not output a carrier.

When I transmit normal data as fast as I can I see clearly the output spectrum on my diy spectrum analyzer (channel 50).
But I want to try it with just a fairly clean carrier. Is there some testcode available for the carrier wave output?

Thanks
Jon


Spectrum analyzer from http://www.circuitcellar.com/library/print/0406/Armitage-189/index.htm
Image



My code:

Code: Select all
            nrf24l01_power_up(false);                              // Set PWR_UP = 1 in the CONFIG register and wait >1.5ms
            nrf24l01_set_as_tx();                                 // Clear the PRIM_RX in the CONFIG register
      
            nrf24l01_write_register(nrf24l01_EN_AA, (unsigned char*)0x00, 1);
            nrf24l01_write_register(nrf24l01_SETUP_RETR, (unsigned char*)0x00, 1);
            nrf24l01_write_register(nrf24l01_RF_SETUP, (unsigned char*)0x1F, 1);   // PLL Lock
            
            // Address 0xFF
            nrf24l01_write_register(nrf24l01_SETUP_AW,(unsigned char*)0x03, 1);    // Address 5 bytes            
            unsigned char address [5] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
            nrf24l01_set_tx_addr(address, 5);
            
            nrf24l01_write_register(nrf24l01_RX_PW_P0, (unsigned char*)32, 1);      // 32 bytes
            nrf24l01_write_tx_payload(payload, 32, false);                     // All 0xFF
            nrf24l01_write_register(nrf24l01_CONFIG, (unsigned char*)0x02, 1);      // CRC = 0, PWR_UP = 1
            nrf24l01_write_register(nrf24l01_RF_CH, (unsigned char*)50, 1);         // RF channel
            nrf24l01_transmit();
            _delay_ms(1);
         
            nrf24l01_set_ce();
            nrf24l01_reuse_tx_pl();

            while(1)
            {
               RED_LED_ON;
               wdt_reset();
            }
Jonil
 
Posts: 8
Joined: Tue Aug 26, 2008 7:12 pm

Re: nRF24L01 carrier wave

Postby brennen » Mon Dec 22, 2008 4:55 pm

Frankly, I can't see a single bug in your code. I also just looked at the nrf24l01_reuse_tx_pl() function, and it looks like it is correct, as well. I do know that the 24L01+ has a bit to do this exact thing, so it would be much easier on that chip. But if you plug away at it, you're likely to find something in your code (or my code) that is messed up.
brennen
Site Admin
 
Posts: 395
Joined: Sun Aug 17, 2008 2:15 pm

Re: nRF24L01 carrier wave

Postby Jonil » Sun Dec 28, 2008 3:57 pm

Thank you for taking the time to check the code. I will check deeper in the code once again next week
and will let you know if i success. And yes, the new chip has a easier configuration. :P
Jonil
 
Posts: 8
Joined: Tue Aug 26, 2008 7:12 pm

Re: nRF24L01 carrier wave

Postby Jonil » Sat Jan 03, 2009 10:19 pm

I hooked up a debugger to the system and when I read the registers in the nRF24L01 it wasn't correct at all.
I don't now what causing the problem but instead of writing the registers one by one I tried to write
all of them at the same time by using function nrf24l01_initialize().

It seems to work perfect, now it outputs the carrier wave constantly.

I have attached the working code.

Spectrum at channel 45:
Image

Code: Select all
            unsigned char channel = 45;
            unsigned char payload[32] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
            unsigned char address [5] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF};

            nrf24l01_initialize(0x02,
                              false, 
                              0x00,
                              0x01,
                              0x03,
                              0x00,
                              channel,
                              0x1F,
                              NULL,
                              NULL,
                              0xF1,
                              0xF2,
                              0xF3,
                              0xF4,
                              (unsigned char*)&address,
                              32,
                              0x12,
                              0x13,
                              0x14,
                              0x15,
                              0x16);

   
            //nrf24l01_get_all_registers((unsigned char*)&reg_data);
            nrf24l01_write_tx_payload(payload, 32, false);                     // All 0xFF            
            nrf24l01_transmit();
            
            while(!(nrf24l01_irq_pin_active()));

            nrf24l01_set_ce();
            nrf24l01_reuse_tx_pl();
            
            while(1)
            {                        
               YELLOW_LED_ON;
               wdt_reset();
            }

Jonil
 
Posts: 8
Joined: Tue Aug 26, 2008 7:12 pm

Re: nRF24L01 carrier wave

Postby brennen » Mon Jan 05, 2009 12:39 pm

Good to seee you got it working. Did you by chance see at what line(s) in the code your register set was being corrupted? There may be some bug lurking in my code somewhere.
brennen
Site Admin
 
Posts: 395
Joined: Sun Aug 17, 2008 2:15 pm

Re: nRF24L01 carrier wave

Postby Jonil » Sun Feb 08, 2009 7:13 pm

I looked at code again, and its little bit embarrassing.

I function call like this will be totally wrong, right?

nrf24l01_write_register(nrf24l01_RF_CH, (unsigned char*)50, 1);


It should be something like this:

unsigned char channel = 50;
nrf24l01_write_register(nrf24l01_RF_CH, &channel, 1);

After changing all the function calls it works very well with the description in the datasheet.
Jonil
 
Posts: 8
Joined: Tue Aug 26, 2008 7:12 pm

Re: nRF24L01 carrier wave

Postby brennen » Sun Feb 08, 2009 9:25 pm

Yeah, the first function call would have likely sent the data that was being held at address 50. The form of the second function call is definitely the way to go. It is kind of a pain to have to waste that extra byte, but in order to be the most flexible, I made that argument a pointer to allow for arrays.
brennen
Site Admin
 
Posts: 395
Joined: Sun Aug 17, 2008 2:15 pm


Return to Wireless

Who is online

Users browsing this forum: No registered users and 1 guest

cron