MACRAW Application Note?

Hello Wiznet people,

I’m intending to implement IP/IPv6 on top of MACRAW for educational purposes.
Although there are good Application Notes for TCP/UDP there aren’t any for MACRAW.

Any chance you will publish such on the wiki or data sheet?
It so much better to have an official documentation then figuring it out by trial&error :slight_smile:


Hi Zick :slight_smile:

We publish the PPPoE application on the wiki site in April 2014.
In this application note, we described the structure of PPPoE protocol implemented by MACRAW mode firmware.

You can download the application note & source code from [url][/url]

EK :slight_smile:

Dear Zick,

As you know, MACRAW can handle the Ethernet frame.

  • The received MACRAW data format
    |-- data length (2byte) --|-- DATA packet (with data length) --|

*Pseudo code for MACRAW mode
(ref. code: … / socket.c)

  1. macraw_open
void macraw_open(void)
  uint8 sock_num;
  uint16 dummyPort = 0;
  uint8 mFlag = 0;
  sock_num = 0; [u]// socket number '0' can only support[/u]

  close(sock_num); // Close the 0-th socket
  socket(sock_num, Sn_MR_MACRAW, dummyPort,mFlag);  // OPen the 0-th socket with MACRAW mode
  1. macraw_send
uint16 macraw_send( const uint8 * buf, uint16 len )
   uint16 ret=0;
   uint8 sock_num;
   sock_num =0;

   if (len > getIINCHIP_TxMAX(sock_num)) ret = getIINCHIP_TxMAX(sock_num); // check size not to exceed MAX size.
   else ret = len;

   send_data_processing(sock_num, (uint8 *)buf, len);

   while( IINCHIP_READ(Sn_CR(sock_num)) );
   while ( (IINCHIP_READ(Sn_IR(sock_num)) & Sn_IR_SEND_OK) != Sn_IR_SEND_OK );
   IINCHIP_WRITE(Sn_IR(sock_num), Sn_IR_SEND_OK);

   return ret;
  1. macraw_recv
uint16 macraw_recv( uint8 * buf, uint16 len )
   uint8 sock_num;
   uint16 data_len=0;
   uint16 dummyPort = 0;
   uint16 ptr = 0;
   uint8 mFlag = 0;
   sock_num = 0;

   if ( len > 0 )

      data_len = 0;

      ptr = IINCHIP_READ(Sn_RX_RD0(sock_num));
      ptr = (uint16)((ptr & 0x00ff) << 8) + IINCHIP_READ( Sn_RX_RD1(sock_num) );
      //-- read_data(s, (uint8 *)ptr, data, len); // read data
      data_len = IINCHIP_READ_RXBUF(0, ptr);
      data_len = ((data_len<<8) + IINCHIP_READ_RXBUF(0, ptr)) - 2;

      if(data_len > 1514)
         printf("data_len over 1514\r\n");
         printf("\r\nptr: %X, data_len: %X", ptr, data_len);
         /** recommand : close and open **/
         close(sock_num); // Close the 0-th socket
         socket(sock_num, Sn_MR_MACRAW, dummyPort,mFlag);  // OPen the 0-th socket with MACRAW mode
         return 0;

      IINCHIP_READ_RXBUF_BURST(sock_num, ptr, data_len, (uint8*)(buf));
      ptr += data_len;

      IINCHIP_WRITE(Sn_RX_RD0(sock_num),(uint8)((ptr & 0xff00) >> 8));
      IINCHIP_WRITE(Sn_RX_RD1(sock_num),(uint8)(ptr & 0x00ff));
      IINCHIP_WRITE(Sn_CR(sock_num), Sn_CR_RECV);
      while( IINCHIP_READ(Sn_CR(sock_num)) ) ;

   return data_len;


1 Like

Dear ekkim and suhwan,

thanks a lot!
It’s nice to get good answers so early in the morning :slight_smile:
(UTC+2 here…)

I’m dealing with MACRAW mode and have some difficulties with filtration of incomig packets. I set up MFEN in Sn_MR according to datasheet

[quote]If user wants to implement Hybrid TCP/IP stack, it is
recommended that this bit is set as „1‟ for reducing host overhead to
process the all received packets.[/quote]
but where to I must write info about MAC addresses to be passed? haven’t found in dosc… neither datashit, not app note :frowning:

check out the SHAR register in datasheet page 33.

Hello Zick,
All I see about SHAR register is it configures the source hardware address. Could you explain a little bit more, what I should write there when I want to enter multicast group and when I want to receive all multicast packets. By now I don’t get any meaning of this reg in MACRAW mode :cry:


I didn’t try that myself so everything below is how I interpret the datasheet.

  1. Write the MAC address into the SHAR. On the WIZ550io board there’s a sticker with a MAC address. If you don’t have the W550io board come with a valid address you like (e.g. 00:11:22:33:44:55).
  2. Set MFEN

Then you’ll only get packets sent to 00:11:22:33:44:55 and FF:FF:FF:FF:FF:FF (broadcast).

Some strange stuff continues to happen.
Initializing socket in MACRAW mode like that:

MAC-address in SHAR non-zero. But, suddenly I receive all packets in networks, even with destination addresses that non-multicast and not mine (checked with wireshark).
How can I receive only broadcast packets (FF:FF:FF:FF:FF:FF) and packets with my MAC in SHAR?

upd: Fighting this problem for a week, still receiving all packets in network by the MACRAW socket without any filtration. Tried all flags in Sn_MR. so is that normal that there is no filtering of incoming packets??

upd2: was wrong, all works fine, was confused by ipv6 multicast addresses.