24L01 + pic18f25k22 full asyncronous transmission required

Discussion about wireless devices

24L01 + pic18f25k22 full asyncronous transmission required

Postby carloca » Mon Dec 07, 2015 1:46 pm

Hi everyone, and sorry for my poor English,

I'm a new user and this is my first post,
I used 24L01 board with Brennen (THANKS!) codes in the past, without problem,

now I'm facing a little trouble,
I'm developing a board with full async transmission, I have 1 mcu and 2 X 24L01 boards connected on the same SPI port, sharing all the pins except CE, CSN and IRQ,
I personalized Brennen files as follows:

in the nrf24l01.h I only added a bool variable named TXMODE and pin declaration for the 24L01 boards;
nrf24l01.h
---------------------------------
Code: Select all
bool TXMODE=1;

#define nrf24l01_CE_IOREGISTER     PORTC
#define nrf24l01_CE_PINMASK      0x04   //il CE di RX è su RC2 (00000100)
#define nrf24l01_CE_IOREGISTERTX     PORTB
#define nrf24l01_CE_PINMASKTX      0x02   //il CE del TX è su RB1 (00000010)

#define nrf24l01_CSN_IOREGISTER    PORTC
#define nrf24l01_CSN_PINMASK      0x02   //il CSN di RX è su RC1 (00000010)
#define nrf24l01_CSN_IOREGISTERTX    PORTB
#define nrf24l01_CSN_PINMASKTX      0x04   //il CSN di TX è su RB2 (00000100)

#define nrf24l01_IRQ_IOREGISTER    PORTB
#define nrf24l01_IRQ_PINMASK      0x01    //interrupt di RX è su RB0 (00000001)
#define nrf24l01_IRQ_IOREGISTERTX    PORTB
#define nrf24l01_IRQ_PINMASKTX      0x08    //interrupt di TX è su RB3 (00001000) (NON UTILIZZATO)

---------------------------------

in the nrf24l01.c I modified some functions as follows, in order to select the right board during transmission/reception
nrf24l01.c
------------------------------
Code: Select all
//clears the pin on the host microcontroller that is attached to the 24l01's CE pin
void nrf24l01_clear_ce()
{
    if (TXMODE)
        nrf24l01_CE_IOREGISTERTX &= ~nrf24l01_CE_PINMASKTX;
    else
        nrf24l01_CE_IOREGISTER &= ~nrf24l01_CE_PINMASK;
}

//sets the pin on the host microcontroller that is attached to the 24l01's CE pin
void nrf24l01_set_ce()
{
    if (TXMODE)
        nrf24l01_CE_IOREGISTERTX |= nrf24l01_CE_PINMASKTX;
    else
   nrf24l01_CE_IOREGISTER |= nrf24l01_CE_PINMASK;
}

//returns true if CE is high, false if not
bool nrf24l01_ce_pin_active()
{
    if (TXMODE)
    {
        if((nrf24l01_CE_IOREGISTERTX & nrf24l01_CE_PINMASKTX) != 0)
            return true;
   else
            return false;
    }
    else
    {
   if((nrf24l01_CE_IOREGISTER & nrf24l01_CE_PINMASK) != 0)
            return true;
   else
            return false;
    }
}

//sets the pin on the host microcontroller that is attached to the 24l01's CSN pin
void nrf24l01_clear_csn()
{
    if (TXMODE)
        nrf24l01_CSN_IOREGISTERTX &= ~nrf24l01_CSN_PINMASKTX;
    else
   nrf24l01_CSN_IOREGISTER &= ~nrf24l01_CSN_PINMASK;
}

//clears the pin on the host microcontroller that is attached to the 24l01's CSN pin
void nrf24l01_set_csn()
{
    if (TXMODE)
        nrf24l01_CSN_IOREGISTERTX |= nrf24l01_CSN_PINMASKTX;
    else
   nrf24l01_CSN_IOREGISTER |= nrf24l01_CSN_PINMASK;
}

//returns true if CSN is high, false if not
bool nrf24l01_csn_pin_active()
{
    if (TXMODE)
    {
   if((nrf24l01_CSN_IOREGISTERTX & nrf24l01_CSN_PINMASKTX) != 0)
      return true;
   else
      return false;
    }
    else
    {
   if((nrf24l01_CSN_IOREGISTER & nrf24l01_CSN_PINMASK) != 0)
      return true;
   else
      return false;
    }
}

//returns true if IRQ pin is low, false otherwise
bool nrf24l01_irq_pin_active()
{
    if (TXMODE)
    {
   if((nrf24l01_IRQ_IOREGISTERTX & nrf24l01_IRQ_PINMASKTX) != 0)
            return false;
   else
            return true;
    }
    else
    {
   if((nrf24l01_IRQ_IOREGISTER & nrf24l01_IRQ_PINMASK) != 0)
            return false;
   else
            return true;
    }
}
--------------------------------------

Now I'm initializing boards with
Code: Select all
 TXMODE=0;         //receiver
    nrf24l01_initialize_debug(true, 1, true); //receiver, 1 data byte, auto-ack enabled

    TXMODE=1;
    nrf24l01_initialize_debug(false, 1, true); //transmitter, 1 data byte, auto-ack enabled

the problem is:
receiver correctly works, but transmitter does not, after starting transmission it freezes on the next while statement

Code: Select all
TXMODE=1;
nrf24l01_write_tx_payload(&data, 1, true); //trasmette un byte

while(!(nrf24l01_irq_pin_active() && (nrf24l01_irq_tx_ds_active() || nrf24l01_irq_max_rt_active())))               //never exits this while statement!
            Nop();


I'm not able to figure out what's wrong,
any suggestion?

Thanks!

ciao from Italy

carlo
carloca
 
Posts: 1
Joined: Mon Dec 07, 2015 10:08 am

Return to Wireless

Who is online

Users browsing this forum: No registered users and 3 guests

cron