at86rf212b peer2peer

Go To Last Post
21 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Dear Sir.

 

I have designed a board based on at86rf212b .

 

Using the peer2peer demo, I have one board programmed as master ,

 

The second board as slave . 

 

I have problems getting the transmission ack'ed from the slave.

 

What procedure can I made in order to tell if it is software or hardware issue ?.

 

Please Advise.

Ephraim Oved

Last Edited: Fri. Oct 16, 2015 - 12:21 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

But the software runs fine otherwise? Then check the status code returned in the confirmation callback.

 

And post your schematics and board layout and pictures if possible.

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi.

 

I have tested both boards as Master , Both produced the 780 Carrier as in the Spec' snapshot.

 

Now when one configured as slave I don't get the function appDataInd(NWK_DataInd_t *ind) activated ,

 

This function toggles leds , They do not toggle at all.

 

Here is the relevant code .

 

config.h

//#define dTransmit
#undef dTransmit
// Address must be set to 0 for the first device, and to 1 for the second one.
#ifdef dTransmit
#define APP_ADDR                  0//0 Transmit 1- receive
#else
#define APP_ADDR                  1//0 Transmit 1- receive
#endif

#define APP_PANID                 0x1234
#define APP_ENDPOINT              1

#define APP_CHANNEL               11
#define APP_BAND                  0x04
#define APP_MODULATION            0x1c

#define APP_SECURITY_KEY          "012345"

#define NWK_BUFFERS_AMOUNT                  10
#define NWK_DUPLICATE_REJECTION_TABLE_SIZE  50
#define NWK_DUPLICATE_REJECTION_TTL         2000 // ms
#define NWK_ROUTE_TABLE_SIZE                100
#define NWK_ROUTE_DEFAULT_SCORE             3
#define NWK_ACK_WAIT_TIME                   1000 // ms

#define NWK_ENABLE_ROUTING
//#define NWK_ENABLE_SECURITY
#endif // _CONFIG_H_

 

void PHY_Init(void)
{
  
  HAL_PhyReset();

  
  phyRxState = true;//false;
  phyBand = 4;
  phyModulation = phyReadRegister(TRX_CTRL_2_REG) & 0x3f;
  phyState = PHY_STATE_IDLE;

  phyWriteRegister(RF_CTRL_0_REG, 0x02);
  //phyWriteRegister(TRX_CTRL_0_REG, 0x00);

  phyWriteRegister(TRX_STATE_REG, TRX_CMD_TRX_OFF);
  phyWaitState(TRX_STATUS_TRX_OFF);

  phyWriteRegister(PHY_TX_PWR_REG, 0x41);
  //phyWriteRegister(PHY_TX_PWR_REG, 0x41);

  phyWriteRegister(TRX_CTRL_1_REG, (1<<TX_AUTO_CRC_ON) | (3<<SPI_CMD_MODE) |
      (1<<IRQ_MASK_MODE) /*| (1<<PA_EXT_EN) | (1<<RX_BL_CTRL)*/);

  phyWriteRegister(TRX_CTRL_2_REG, (1<<RX_SAFE_MODE));
  
}

 

void PHY_DataReq(uint8_t *data, uint8_t size)
{
  phyTrxSetState(TRX_CMD_TX_ARET_ON);

  phyReadRegister(IRQ_STATUS_REG);

  HAL_PhySpiSelect();
  HAL_PhySpiWriteByte(RF_CMD_FRAME_W);
  HAL_PhySpiWriteByte(size + PHY_CRC_SIZE);
  for (uint8_t i = 0; i < size; i++)
    HAL_PhySpiWriteByte(data[i]);
  HAL_PhySpiDeselect();

  phyState = PHY_STATE_TX_WAIT_END;
  HAL_PhySlpTrSet();
  for (uint8_t l_iDelay = 0; l_iDelay < 50; l_iDelay++);
  HAL_PhySlpTrClear();
}

 

static void phySetChannel(void)
{
  uint8_t reg;

  reg = phyReadRegister(TRX_CTRL_2_REG) & ~0x3f;
  phyWriteRegister(TRX_CTRL_2_REG, reg | phyModulation);

  phyWriteRegister(CC_CTRL_1_REG, phyBand);

  if (0 == phyBand)
  {
    reg = phyReadRegister(PHY_CC_CCA_REG) & ~0x1f;
    phyWriteRegister(PHY_CC_CCA_REG, reg | phyChannel);
  }
  else
  {
    phyWriteRegister(CC_CTRL_0_REG, phyChannel);
  }
}

 

 

static bool appDataInd(NWK_DataInd_t *ind)
{
    AppMessage_t *msg = (AppMessage_t *)ind->data;
    
    static BYTE l_Toggle= 0;
    
    LedControlService(&m_oEgmEmbedded.m_oLedControl_3, l_Toggle);
    LedControlService(&m_oEgmEmbedded.m_oLedControl_4, l_Toggle^1);
    l_Toggle^=1;
    return true;
}

 

static void appDataConf(NWK_DataReq_t *req)
{
    appState = APP_STATE_IDLE;
    (void)req;

    if (NWK_SUCCESS_STATUS == req->status)
    {
      // frame was sent successfully
      uint16_t l_iAddr =  req->dstAddr;
    }
    else
    {
      // some error happened
    }
  
}
#ifdef dTransmit
BYTE m_iTestData[] = {"0123456789ajhdhdfijshfgdfghdofjghkdf"};
#else
BYTE m_iTestData[] = {"9876543210ajhdhdfijshfgdfghdofjghkdf"};
#endif
/*************************************************************************//**
*****************************************************************************/
static void appSendMessage(uint8_t state)
{
    appMessage.buttonState[31] = state;

    LedControlService(&m_oEgmEmbedded.m_oLedControl_1, state&1);
    LedControlService(&m_oEgmEmbedded.m_oLedControl_2, (state&1)^1);

    memcpy((uint8_t *)&appMessage, m_iTestData, 30);
    
    appNwkDataReq.dstAddr = 1 - APP_ADDR;
    appNwkDataReq.dstEndpoint = APP_ENDPOINT;
    appNwkDataReq.srcEndpoint = APP_ENDPOINT;
    appNwkDataReq.options = NWK_OPT_ACK_REQUEST| NWK_OPT_ENABLE_SECURITY;
    appNwkDataReq.data = (uint8_t *)&appMessage;
    appNwkDataReq.size = 32;//sizeof(appMessage);
    appNwkDataReq.confirm = appDataConf;

    NWK_DataReq(&appNwkDataReq);

    appState = APP_STATE_WAIT_CONF;
}

 

void InitializeMesh(void)
{
    // Network initialization
    NWK_SetAddr(APP_ADDR);
    NWK_SetPanId(APP_PANID);
    
    PHY_SetChannel(APP_CHANNEL);
    // Add 
    PHY_SetBand(APP_BAND);
    PHY_SetModulation(APP_MODULATION);
    
    
    ////
    PHY_SetRxState(true);

    NWK_OpenEndpoint(APP_ENDPOINT, appDataInd);
}

 

static void APP_TaskHandler(void)
{
  static BYTE l_iCounter=0;
  
  switch (appState)
  {
    case APP_STATE_INITIAL:
    {
       

      appState = APP_STATE_IDLE;

    } 
    break;

    case APP_STATE_IDLE:
    {
 
        if (appButtonState == 1)// Master mode.
      {
        appSendMessage(l_iCounter++);

      }
    } 
    break;

    case APP_STATE_WAIT_CONF:
      break;
  }
}

 

 

Is there a way to tell if the slave get a the frame or not  ?

 

Please Advise.

Ephraim Oved

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Why did you do all those modifications to the PHY? They don't make any sense. There are APIs to control the radio.

 

Start with unmodified application.

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi.

 

Can u be more specific.

 

I needed to set the frequency to 780Mhz , So the band is 0x04  and channel is 11 .

 

If u take a close look at the balun it is set for the Chinese WPan 780 Mhz.

 

According to table 9-34 , base freq 769 + 11 * 1 gives 780 mHz.

 

Please Advise.

 

Ephraim Oved

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

There are APIs:

 

void PHY_SetChannel(uint8_t channel);
void PHY_SetBand(uint8_t band);
void PHY_SetModulation(uint8_t modulation);

 

Use them. Never modify anything in the stack, if you are not sure what you are doing. For example, why have you changed phyRxState to true? This creates inconsistent internal state of the PHY, since it actually is in TRX_OFF state.

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Also, where would I have a closer look at your balun?

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 Hi.

 

But I use them correctly ( to my opinion ) , Look at the void InitializeMesh(void)  above .

 

 phyRxState to true?   , It is set so in the peer2peer demo !!!.

 

Look at the schematics the balun is set for the chinese WPAN .

 

Please Advise.

 

Attachment(s): 

Ephraim Oved

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Ephraim Oved wrote:
But I use them correctly ( to my opinion ) , Look at the void InitializeMesh(void)  above .
You posted heavily modified PHY_Init() function. This is wrong, very wrong.

 

Ephraim Oved wrote:
 phyRxState to true?   , It is set so in the peer2peer demo !!!.
Not through PHY modification.

 

Ephraim Oved wrote:
Look at the schematics the balun is set for the chinese WPAN .
You need to have DC blocking capacitors before the balun. I have no idea what happens if you don't put them.

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi .

 

I am back . I installed the 2 dc blocking capacitor .

 

My system two boards:

MCU: ATSAM3S4BA-AU

MCU speed: 64 MHZ

Lightweight Mesh : PHY_AT86RF212 enable

 

APP_ADDR : 0 –transmit 1 – receive

APP_PANID: 0x4567

 

Every one second first board (transmit) send message with 32 bytes size and NWK_OPT_ACK_REQUEST, but the second board (receive) not receiving message (not TRX_END flag from IRQ_STATUS_REG in  void PHY_TaskHandler(void))

 

Notification:

If I set bit AACK_PROM_MODE (Support promiscuous mode ) in register 0x17

So the second board (receive) receive every packet from first board (transmit), but the first board not receiving the ack every packet (one from four or seven)

 

Please Advise.

 

Ephraim Oved.

Ephraim Oved

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi .

 

I am back . I installed the 2 dc blocking capacitor .

 

My system two boards:

MCU: ATSAM3S4BA-AU

MCU speed: 64 MHZ

Lightweight Mesh : PHY_AT86RF212 enable

 

APP_ADDR : 0 –transmit 1 – receive

APP_PANID: 0x4567

 

Every one second first board (transmit) send message with 32 bytes size and NWK_OPT_ACK_REQUEST, but the second board (receive) not receiving message (not TRX_END flag from IRQ_STATUS_REG in  void PHY_TaskHandler(void))

 

Notification:

If I set bit AACK_PROM_MODE (Support promiscuous mode ) in register 0x17

So the second board (receive) receive every packet from first board (transmit), but the first board not receiving the ack every packet (one from four or seven)

 

Please Advise.

 

Ephraim Oved.

Ephraim Oved

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

First of all check your SPI speed to the radio. Ideally it must be 7.5 MHz. But 8 MHz usually works fine, but not more than this.

 

Is your sending side getting a notification?

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi.

 

Spi now is 8MHz .

 

Problem is the same .

 

What do u mean by Is your sending side getting a notification? 

 

Do I get an Interrupt ?.

 

Please Advise.

 

Ephraim Oved.

Ephraim Oved

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

No, just an application callback. In case of P2P it is called appDataConf().

 

At this high frequency of the micro, you may also need to introduce short delay between HAL_PhySlpTrSet() and  HAL_PhySlpTrClear() in the PHY_DataReq() in LwMesh\phy\at86rf212\src\phy.c.

 

 

 

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

 

Setting the delay to 1 ,10,20 uSec , The same problem.

 

Some test , If the packet length 1s 16 bytes then in Prom mode I get every packet .

 

If the packet length is 32 and above , I get the packet chopped .

 

Please Advise.

 

Ephraim Oved.

Ephraim Oved

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Again, check for the status code on the sending side.

 

And use unmodified code. Having prom mode on one side will change behavior on the sending side.

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi.

 

I am using the unmodified code .

 

I get the packet only when I issue the command

 

phyWriteRegister(XAH_CTRL_1_REG, 0x02); 

 

on the slave side.

 

otherwise I get no packets.

 

What should be the speed of the micro in order not to use delays  ?.

 

Please Advise.

 

Ephraim Oved

Ephraim Oved

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi.

 

Is it possible that the Light mesh protocol is designed for AT86RF212 .

 

I am using AT86RF212B ? .

 

Please Advise.

 

Ephraim Oved.

Ephraim Oved

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

212 VS 212B makes no difference. The stack was mostly tested on MCUs running at 8 MHz. The delay requirement was discovered on Xmega running at 32 MHz. So it is needed somewhere ion that range.

 

What's your hardware looks like? Schematics? Pictures?

 

The fact that you can't receive frames in normal mode tells me that CRC is broken on the transmitted frames. And this can happen due to poor RF design, for example.

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi.

 

I have designed the board with the help of RF engineer .

 

I will test the software with a completely new board that I will get in two weeks .

 

Then I will be able to tell you it is hardware or software.

 

Do you know other project that work with Light mesh with cpu other than Xmega ?

 

Please Advise.

 

Ephraim Oved. 

Ephraim Oved

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

There are plenty of projects based on LwMesh working on many different MCUs.

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.