This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

RFConfig-nrf24e1

Hi could anyone explain what the below means involving the configuration of the nrf24e1 radio:

transmitter:

const RFConfig txconf =
{
    15,
    0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x12, 0x34, 0x56, 0x78, 0x83, 0x6c, 0x04
};


Receiver:

};

const RFConfig rxconf =
{
    15,
    0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x87, 0x65, 0x43, 0x21, 0x83, 0x6c, 0x05
};

I am of the belief it is for the configuring of shockburst and payload (from manual) but am unsure what the numbers are for (in decimal-seems to not be obvious as what they are for)

your knowledgable help is greatly appreciated.

Jon

Parents
  • this is the full transmitter code:

    #include <reg24e1.h>
    
    struct RFConfig
    {
        unsigned char n;
        unsigned char buf[15];
    };
    
    typedef struct RFConfig RFConfig;
    
    #define ADDR_INDEX  8   // Index to address bytes in RFConfig.buf
    #define ADDR_COUNT  4   // Number of address bytes
    
    const RFConfig txconf =
    {
        15,
        0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x12, 0x34, 0x56, 0x78, 0x83, 0x6c, 0x04
    };
    
    const RFConfig rxconf =
    {
        15,
        0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x87, 0x65, 0x43, 0x21, 0x83, 0x6c, 0x05
    };
    
    
    
    // LED is to be connected to this pin
    sbit LED_pin = P1^0;
    
    
    // Function prototypes
    void DELAY_LOOP_Wait(const unsigned int);
    void DELAY_100us(volatile unsigned char n);
    unsigned char SPI_ReadWrite(unsigned char b);
    void TRANSMIT_Packet(unsigned char b);
    void TRANSMITTER(void);
    void LED_Flash();
    void INIT(void);
    
    
    
    /*..................................................................*/
    
    
    void main(void)
    {
                    INIT();
    
              while(1)
              {
    
                TRANSMITTER();
    
    
          }
    
    
    
    }
    
    /*------------------------------------------------------------------*-
    
      DELAY_LOOP_Wait()
    
    -*------------------------------------------------------------------*/
    
    void DELAY_LOOP_Wait(const unsigned int DELAY)
       {
       unsigned int x, y;
    
       for (x = 0; x <= DELAY; x++)
          {
          for (y = 0; y <= 800; y++);
          }
       }
    
    
    /*------------------------------------------------------------------*-
    
      LED_FLASH()
    
    -*------------------------------------------------------------------*/
    
    void LED_Flash()
    {
                    LED_pin = 0;
                    DELAY_LOOP_Wait(1000);
                    LED_pin = 1;
                    DELAY_LOOP_Wait(1000);
    }
    
    /*------------------------------------------------------------------*-
    
      DELAY_100us()
    
    -*------------------------------------------------------------------*/
    
    void DELAY_100us(volatile unsigned char n)
    {
        unsigned char i;
        while(n--)
            for(i=0;i<35;i++)
                ;
    }
    
    /*------------------------------------------------------------------*-
    
      SPI_ReadWrite()
    
    -*------------------------------------------------------------------*/
    
    unsigned char SPI_ReadWrite(unsigned char b)
    {
        EXIF &= ~0x20;                  // Clear SPI interrupt
        SPI_DATA = b;                   // Move byte to send to SPI data register
        while((EXIF & 0x20) == 0x00)    // Wait until SPI hs finished transmitting
            ;
        return SPI_DATA;
    }
    
    
    
    /*------------------------------------------------------------------*-
    
      TRANSMIT_Packet()
    
    -*------------------------------------------------------------------*/
    
    void TRANSMIT_Packet(unsigned char b)
    {
        unsigned char i;
        CE = 1;
        DELAY_100us(0);
        // Start with the address of the receiver:
        for(i=0;i<ADDR_COUNT;i++)
            SPI_ReadWrite(rxconf.buf[ADDR_INDEX+i]);
        SPI_ReadWrite(b);
        CE = 0;
        DELAY_100us(3);                  // Wait ~300us
    }
    
    
     /*------------------------------------------------------------------*-
    
      TRANSMITTER()
    
    -*------------------------------------------------------------------*/
    
    void TRANSMITTER(void)
    {
        unsigned char b, bo, err;
        CS = 1;
        DELAY_100us(0);
        for(b=0;b<txconf.n;b++)
        {
            SPI_ReadWrite(txconf.buf[b]);
        }
        CS = 0;
        for(;;)
        {
            //b = ReadADC();              // Read ADC
           TRANSMIT_Packet(b);          // Transmit data
            }
    }
    
    void INIT(void)
    {
        PWR_UP = 1;                     // Turn on Radio
        DELAY_100us(30);                // Wait > 3ms
        SPICLK = 0;                     // Max SPI clock (XTAL/8)
        SPI_CTRL = 0x02;                // Connect internal SPI controller to Radio
    
    }
    

Reply
  • this is the full transmitter code:

    #include <reg24e1.h>
    
    struct RFConfig
    {
        unsigned char n;
        unsigned char buf[15];
    };
    
    typedef struct RFConfig RFConfig;
    
    #define ADDR_INDEX  8   // Index to address bytes in RFConfig.buf
    #define ADDR_COUNT  4   // Number of address bytes
    
    const RFConfig txconf =
    {
        15,
        0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x12, 0x34, 0x56, 0x78, 0x83, 0x6c, 0x04
    };
    
    const RFConfig rxconf =
    {
        15,
        0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x87, 0x65, 0x43, 0x21, 0x83, 0x6c, 0x05
    };
    
    
    
    // LED is to be connected to this pin
    sbit LED_pin = P1^0;
    
    
    // Function prototypes
    void DELAY_LOOP_Wait(const unsigned int);
    void DELAY_100us(volatile unsigned char n);
    unsigned char SPI_ReadWrite(unsigned char b);
    void TRANSMIT_Packet(unsigned char b);
    void TRANSMITTER(void);
    void LED_Flash();
    void INIT(void);
    
    
    
    /*..................................................................*/
    
    
    void main(void)
    {
                    INIT();
    
              while(1)
              {
    
                TRANSMITTER();
    
    
          }
    
    
    
    }
    
    /*------------------------------------------------------------------*-
    
      DELAY_LOOP_Wait()
    
    -*------------------------------------------------------------------*/
    
    void DELAY_LOOP_Wait(const unsigned int DELAY)
       {
       unsigned int x, y;
    
       for (x = 0; x <= DELAY; x++)
          {
          for (y = 0; y <= 800; y++);
          }
       }
    
    
    /*------------------------------------------------------------------*-
    
      LED_FLASH()
    
    -*------------------------------------------------------------------*/
    
    void LED_Flash()
    {
                    LED_pin = 0;
                    DELAY_LOOP_Wait(1000);
                    LED_pin = 1;
                    DELAY_LOOP_Wait(1000);
    }
    
    /*------------------------------------------------------------------*-
    
      DELAY_100us()
    
    -*------------------------------------------------------------------*/
    
    void DELAY_100us(volatile unsigned char n)
    {
        unsigned char i;
        while(n--)
            for(i=0;i<35;i++)
                ;
    }
    
    /*------------------------------------------------------------------*-
    
      SPI_ReadWrite()
    
    -*------------------------------------------------------------------*/
    
    unsigned char SPI_ReadWrite(unsigned char b)
    {
        EXIF &= ~0x20;                  // Clear SPI interrupt
        SPI_DATA = b;                   // Move byte to send to SPI data register
        while((EXIF & 0x20) == 0x00)    // Wait until SPI hs finished transmitting
            ;
        return SPI_DATA;
    }
    
    
    
    /*------------------------------------------------------------------*-
    
      TRANSMIT_Packet()
    
    -*------------------------------------------------------------------*/
    
    void TRANSMIT_Packet(unsigned char b)
    {
        unsigned char i;
        CE = 1;
        DELAY_100us(0);
        // Start with the address of the receiver:
        for(i=0;i<ADDR_COUNT;i++)
            SPI_ReadWrite(rxconf.buf[ADDR_INDEX+i]);
        SPI_ReadWrite(b);
        CE = 0;
        DELAY_100us(3);                  // Wait ~300us
    }
    
    
     /*------------------------------------------------------------------*-
    
      TRANSMITTER()
    
    -*------------------------------------------------------------------*/
    
    void TRANSMITTER(void)
    {
        unsigned char b, bo, err;
        CS = 1;
        DELAY_100us(0);
        for(b=0;b<txconf.n;b++)
        {
            SPI_ReadWrite(txconf.buf[b]);
        }
        CS = 0;
        for(;;)
        {
            //b = ReadADC();              // Read ADC
           TRANSMIT_Packet(b);          // Transmit data
            }
    }
    
    void INIT(void)
    {
        PWR_UP = 1;                     // Turn on Radio
        DELAY_100us(30);                // Wait > 3ms
        SPICLK = 0;                     // Max SPI clock (XTAL/8)
        SPI_CTRL = 0x02;                // Connect internal SPI controller to Radio
    
    }
    

Children