Author Topic: Atmel transceiver (RF212B) communication using microcontroller SAM D21  (Read 13177 times)

0 Members and 1 Guest are viewing this topic.

Offline CharvRastogiTopic starter

  • Newbie
  • Posts: 3
  • Country: in
Hello,

I am working on a project to implement communication between two Atmel transceiver (AT86RF212B) boards,  I am programming the boards using spi interface between them and SAM D21 (microcontroller). I am able to send and receive data using the LWmesh peer2peer sample project given by Atmel studio 7. But the issue is the data received and the data sent are not the same, the code somehow changes the data entirely. I am using a hyper terminal to send and look at the received data.
Could you please tell me why am I not receiving the correct data? Could it be the encryption scheme that is in-built in Atmel (AES)?

Thank you.

Link to the preface of the sample project - http://asf.atmel.com/docs/latest/thirdparty.wireless.avr2130_lwmesh.apps.peer2peer.sam4lc4c_reb233_xpro/html/index.html
(Note - this project is also available for the devices I have mentioned above)
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11236
  • Country: us
    • Personal site
But the issue is the data received and the data sent are not the same
It is highly likely that you have problems with UART baudrate mismatch. Have you verified your data inside the sending device (using debugger or otherwise)?

AES can be used but mismatch of security settings will be detected by the stack and invalid frames will be discarded.

PS: There is no need to cross post.
Alex
 

Offline CharvRastogiTopic starter

  • Newbie
  • Posts: 3
  • Country: in
Thank you! I was using the configured Baudrate between the microcontroller and the transceiver instead of the USART host baudrate.
The data is sent correctly now.

I had another doubt. I was trying to locate the exact point in the code that is used to send the data to the transceiver from SAM D21 using breakpoints and by hard coding the values, but I could not succeed. The code seems to involve many underlying protocols. Is it the sio2host subprogram? Hard coding the output didn't help here either. Would you have some light to shed on this?

PS: Sorry about the cross posting. 
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11236
  • Country: us
    • Personal site
I was trying to locate the exact point in the code that is used to send the data to the transceiver from SAM D21 using breakpoints and by hard coding the values, but I could not succeed.
My original code is much simpler and easier to understand. You can look at standalone version of LwMesh here http://www.atmel.com/tools/lightweight_mesh.aspx . The actual communication with the radio happens in the PHY layer, specifically phy.c file and PHY_DataReq() function. In the standalone version it calls HAL SPI access functions directly. In the ASF version it goes through more layers.

sio2host is a serial communication part, it is not related to the radio in any way.
Alex
 
The following users thanked this post: CharvRastogi

Offline CharvRastogiTopic starter

  • Newbie
  • Posts: 3
  • Country: in
Please correct me if I am wrong,
1. the function AppSendData() in the main program file (Peer2Peer.c) is used to send the data via the transceiver to the other transceiver at the receiving end.
2. the function appDataInd prints the data received from the radio on the host PC through UART.

How is the role of transmission divided between appSendData() and phy_datareq(). PHY_datareq seems to use the frame created in the nwk_tx.c program file, so I am assuming this is the frame that needs to be transmitted by the transceiver finally?

To hard code the output we implemented this method -
I, basically, hard coded the value of rx_data and fed it to both appsenddata() and sio2host_putchar(), and I expected this to print the data on the transmitting pc terminal (which it did) but it was not received by the receiving pc. Does this mean we would have to edit the frame_tx that I mentioned above in nkw_tx to alter the data being sent over the radio?

MY CODE -

int count;

static void APP_TaskHandler(void)
{
   switch (appState) {
      case APP_STATE_INITIAL:
      {
         appInit();
         appState = APP_STATE_IDLE;
      }
      break;

      case APP_STATE_IDLE:
      break;

      default:
      break;
   }
   
   count++;
   if(count%20001==1){
      count=1;   
   }
   
   if(count%20000==19999){
   sio_rx_length = 5;
   for (uint16_t i = 0; i < sio_rx_length; i++) {
      rx_data=('A'+i); //put A,B,C
   }
   rx_data[sio_rx_length]=0x00;
   //sio_rx_length = sio2host_rx(rx_data, APP_RX_BUF_SIZE); //until buffer is filled, 0 is returned. Buffer size is 20 bytes, defined in config.h   
   if (sio_rx_length) {
      for (uint16_t i = 0; i < sio_rx_length; i++) {
         sio2host_putchar(rx_data);  //Echo back on the tx pc
         if (appUartBufferPtr == sizeof(appUartBuffer))  //Send the packet when the buffer is full
         {
            appSendData();
         }

         if (appUartBufferPtr < sizeof(appUartBuffer))  //Append to the packet to be sent, the size of which is sizeof(appUartBuffer)
         {
            appUartBuffer[appUartBufferPtr++] = rx_data;
         }
      }

      SYS_TimerStop(&appTimer);
      SYS_TimerStart(&appTimer);
   }
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11236
  • Country: us
    • Personal site
1. the function AppSendData() in the main program file (Peer2Peer.c) is used to send the data via the transceiver to the other transceiver at the receiving end.
That's the high-level idea.

2. the function appDataInd prints the data received from the radio on the host PC through UART.
appDataInd() is the callback that is called when data is received.

How is the role of transmission divided between appSendData() and phy_datareq(). PHY_datareq seems to use the frame created in the nwk_tx.c program file, so I am assuming this is the frame that needs to be transmitted by the transceiver finally?
appSendData() is an application level function. It was convenient to implement it this way for this application, but you are expected to change things depending on your application needs. NWK_DataReq() is the ultimate stack API.

The rest of the functions add necessary headers and figure out how to route the frame before it is physically sent using PHY_DataReq().

I, basically, hard coded the value of rx_data and fed it to both appsenddata() and sio2host_putchar(), and I expected this to print the data on the transmitting pc terminal (which it did) but it was not received by the receiving pc. Does this mean we would have to edit the frame_tx that I mentioned above in nkw_tx to alter the data being sent over the radio?

You really need to properly design your application, don't just adopt to Peer2Peer. Look at SimpleRemote, for example. It has a very simple and clean implementation of just the wireless part.
Alex
 

Offline kavita

  • Contributor
  • Posts: 27
  • Country: in
lwmesh
« Reply #6 on: April 07, 2016, 12:40:17 pm »
HI

I am using atmel AT86RF233 1 C. For the testing purpose can i only transmit only one array with using only using physical layer i mean one end to another end without using stack.
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11236
  • Country: us
    • Personal site
I am using atmel AT86RF233 1 C. For the testing purpose can i only transmit only one array with using only using physical layer i mean one end to another end without using stack.
Sure. Just use the code from phy.c from LwMesh. That's the lowest level PHY driver. You will need do to at least PHY_Init() and use PHY_DataReq() to send the data.
Alex
 

Offline kavita

  • Contributor
  • Posts: 27
  • Country: in
HI

This is my source code .I am able to read write registers and frame buffer, DIG3 LED is turned on .In this if any data is transmitted from UART data is written in frsme buffer. By transmitting interrupt register shows TX_END.and DIG4 blinks slidely but DIG3 is not turned off.i dont know what is happening because at receiving end i am not able to receive data.
« Last Edit: April 08, 2016, 09:02:39 am by kavita »
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11236
  • Country: us
    • Personal site
There is a number of issues I see with this code.
1. You never actually wait for completion of the frame transfer.
2. You are using advanced TX mode, but you never configure the address/PAN_ID and your payload does not match standard format, which radio expects in the advanced mode. You are receiving in the basic mode, so the frame will be received, but TX will fail, and you need to check the status code.
3. You never set a channel.
Alex
 

Offline kavita

  • Contributor
  • Posts: 27
  • Country: in
Re: Atmel transceiver (RF212B) communication using microcontroller SAM D21
« Reply #10 on: April 09, 2016, 05:25:34 am »
thank you..
 
   can you please tell me what kind of changes i have to do in this....
   I have to set channel ,PAN ID?
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11236
  • Country: us
    • Personal site
Re: Atmel transceiver (RF212B) communication using microcontroller SAM D21
« Reply #11 on: April 09, 2016, 05:32:33 am »
For basic mode you only need to set channel.

And then transmit without ARET.
Alex
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11236
  • Country: us
    • Personal site
Re: Atmel transceiver (RF212B) communication using microcontroller SAM D21
« Reply #12 on: April 09, 2016, 06:15:43 am »
what is crc value..how to calculate this..here i have already set
There is no CRC value, but you need to set frame size including CRC size (2 bytes). With the auto CRC the radio will put it there automatically.
Alex
 

Offline kavita

  • Contributor
  • Posts: 27
  • Country: in
Re: Atmel transceiver (RF212B) communication using microcontroller SAM D21
« Reply #13 on: April 09, 2016, 10:39:45 am »
this is my new code i have set channel and PAN ID.IS this ok?
by doing his DIG3 blinks slidely..
 

Offline kavita

  • Contributor
  • Posts: 27
  • Country: in
Re: Atmel transceiver (RF212B) communication using microcontroller SAM D21
« Reply #14 on: April 09, 2016, 01:03:16 pm »
HEY
I have successfully done it.thank you so much.
can you please tell me if I want to use extended operating mode which additional setting  I have to do for this.
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11236
  • Country: us
    • Personal site
Re: Atmel transceiver (RF212B) communication using microcontroller SAM D21
« Reply #15 on: April 09, 2016, 08:37:02 pm »
can you please tell me if I want to use extended operating mode which additional setting  I have to do for this.
Use states that correspond to the advanced mode. Just like LwMesh does.

In addition to this you will need to make sure that the header of your payload is formatted in accordance with IEEE802.15.4.
Alex
 

Offline kavita

  • Contributor
  • Posts: 27
  • Country: in
Re: Atmel transceiver (RF212B) communication using microcontroller SAM D21
« Reply #16 on: April 11, 2016, 05:57:32 am »
hi

 As mentioned in data sheet that when device in tx mode,DIG4 blinks and DIG3 will turn off but in my case it is not happening.can you please tell me what is the problem.I have checked all connections and hardware is ok.
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11236
  • Country: us
    • Personal site
Re: Atmel transceiver (RF212B) communication using microcontroller SAM D21
« Reply #17 on: April 11, 2016, 05:58:54 am »
As mentioned in data sheet that when device in tx mode,DIG4 blinks and DIG3 will turn off but in my case it is not happening.can you please tell me what is the problem.I have checked all connections and hardware is ok.
Have you actually enabled them? Read the datasheet entirely, especially register description. DIG pins do nothing by default, you need to enable them.
Alex
 

Offline kavita

  • Contributor
  • Posts: 27
  • Country: in
Re: Atmel transceiver (RF212B) communication using microcontroller SAM D21
« Reply #18 on: April 11, 2016, 06:32:32 am »
phyWriteRegister(TRX_CTRL_1_REG,(1<<TX_AUTO_CRC_ON) | (3<<SPI_CMD_MODE) | (1<<IRQ_MASK_MODE)
|(1<< PA_EXT_EN) );

I have done this setting,connected led to both this pins and initialy led is connected to 3.3V when this pin goes low LED will turn On.Now DIG3 is on when this device is ideal I mean no tx and rx.
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11236
  • Country: us
    • Personal site
Re: Atmel transceiver (RF212B) communication using microcontroller SAM D21
« Reply #19 on: April 11, 2016, 06:36:21 am »
I mean no tx and rx.
DIG 3 and DIG4 are complimentary, so if enabled, there are only two states - RX (even if radio is not actually receiving anything or not even in receive mode) and TX (when frame is transmitted). There is no in-between state.
Alex
 

Offline kavita

  • Contributor
  • Posts: 27
  • Country: in
Re: Atmel transceiver (RF212B) communication using microcontroller SAM D21
« Reply #20 on: April 11, 2016, 07:07:35 am »
OK,
so if I want that while doing  tx LED should on.any extra setting I have to do?   
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11236
  • Country: us
    • Personal site
Re: Atmel transceiver (RF212B) communication using microcontroller SAM D21
« Reply #21 on: April 11, 2016, 07:10:08 am »
No, PA_EXT_EN is enough. Keep in mind that TX time of a maximum payload is ~5 ms. You won't see that on an LED with your eyes.
Alex
 

Offline kavita

  • Contributor
  • Posts: 27
  • Country: in
Re: Atmel transceiver (RF212B) communication using microcontroller SAM D21
« Reply #22 on: April 11, 2016, 07:18:54 am »
okk thank you alex..
 

Offline kavita

  • Contributor
  • Posts: 27
  • Country: in
Re: Atmel transceiver (RF212B) communication using microcontroller SAM D21
« Reply #23 on: April 11, 2016, 08:46:42 am »
how can i set maximum gain?
Is it already set to maximum beacuse initially PHY_TX_PWR=0x0.
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11236
  • Country: us
    • Personal site
Re: Atmel transceiver (RF212B) communication using microcontroller SAM D21
« Reply #24 on: April 11, 2016, 04:36:11 pm »
how can i set maximum gain?
It is a bit complicated, since total TX power in 212B is a combination of PA_BOOST, GC_PA and TX_PWR settings.

Table 9-15 shows recommended settings based on your location and used modulation scheme.
Alex
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf