This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Ethernet protocol converter using TM4C1294

Other Parts Discussed in Thread: TM4C129ENCPDT

Dear All,

I am  developing a product for RS232/RS485 to Ethernet protocol converter using TIVA TM4C129ENCPDT.

 Our board will acquire data from smart meter using RS485 and sending the data to another board which will be also having the same controller.

Second device will process the data and will send the data to IEC-101 master.

We have tested the board with serial communication between both the boards.

Now we want to setup Ethernet communication between both the TIVA controller, as both the devices will be residing at different places and will be using GPRS or broadband modem to communicate.

 I need to know if there is any sample code to use to setup a communication between both the devices.

I have refered the sample code enet_lwip , enet_IO, enet_Uip but all these codes are used as server.

If I can get sample code to refer then it will be very helpful.

Kindly help me with your valuable suggestions.

Thanks & Regards:-

utpal

 

  • Hello Utpal

    I know that there is a sample code being developed for basic Ethernet (just to work as communication interface between two devices). I am not sure on the release date for it.

    I will ask the team member to post an update.

    Regards

    Amit

  • Hi Amit,

    Is there an update to this?

    Thanks,

    Stephen

  • Stephen,

    Depending on the protocol requirements of your communication link, you might be able to DIY a simple stack. The programming example in the Ethernet section of the TivaWare manual is surprisingly good - based on that it took me a week to get to the point where I can send & receive arbitrary single-frame UDP packets. You do need to "know your protocols", though - the example only gets you to the point where you can send & receive raw Ethernet frames. My solution is unfortunately not ready to be published at this time, but if you're willing to try rolling your own, I can give you some pointers.

    -Veikko
  • Hi Veikko,

    Simple send/receive will be good enough for me. I'm only validating the hardware on my pcb.

    I'll check out the Tivaware manual first.

    Thanks,

    Stephen

  • OK, you should be able to do that with raw ethernet quite nicely. You don't even need two boards for testing RX - just connect the ethernet cable to any Windows PC and you'll get *plenty* of packets (among which ARP and DHCP discovery, for example).

    There is one gotcha in the example code. In the InitDescriptors function, you'll see:

    g_psTxDescriptor[ui32Loop].ui32Count = DES1_TX_CTRL_SADDR_INSERT;

    This commands the EMAC, when it reads the descriptor, to insert the ethernet address of the board to the outgoing frame in question. The setting is stored in the high bits of the .ui32Count field. However, in the PacketTransmit function, you have:

    g_psTxDescriptor[g_ui32TxDescIndex].ui32Count = (uint32_t)i32BufLen;

    Which effectively overwrites the previously applied setting. Now, you could do a |= assignment, but then you'd need to clear the previous buflen bits first. A better solution, IMHO, is to configure the EMAC to do the address insertion globally, ignoring the bits in the descriptor. In the example, in main() you have:

    //
    // Set MAC configuration options.
    //
    EMACConfigSet(EMAC0_BASE,
    (EMAC_CONFIG_FULL_DUPLEX |
    EMAC_CONFIG_CHECKSUM_OFFLOAD |
    EMAC_CONFIG_7BYTE_PREAMBLE |
    EMAC_CONFIG_IF_GAP_96BITS |
    EMAC_CONFIG_USE_MACADDR0 |
    EMAC_CONFIG_SA_FROM_DESCRIPTOR |
    EMAC_CONFIG_BO_LIMIT_1024),
    (EMAC_MODE_RX_STORE_FORWARD |
    EMAC_MODE_TX_STORE_FORWARD |
    EMAC_MODE_TX_THRESHOLD_64_BYTES |
    EMAC_MODE_RX_THRESHOLD_64_BYTES), 0);

    Change the highlighted setting to either EMAC_CONFIG_SA_INSERT or EMAC_CONFIG_SA_REPLACE. The difference between these is that with the former, the EMAC actually adds the source address bytes to the outgoing frame while the latter replaces the bytes in situ. I find the latter more intuitive, as then you will be sending and receiving frames with the actual structure.

    Also another thing to note - if the automatic IP+ICMP/TCP/UDP checksum calculation-by-hardware feature is to be used, you need to ensure that the checksum fields are all zero prior to handing over the frame to the DMA. But for raw ethernet you needn't worry about that.

  • Hi Viekko, I need to communicate between two TM4C1294 boards using ethernet specifically with the PTP 1588 protocol, and not one board and PC communication like you have suggested above. If you could provide a sample code to send and receive messages between two boards it would be very helpful.

  • Hi Vandan,

    Unfortunately I don't have sample code to do that. I have read about IEEE 1588 PTP, but haven't implemented it anywhere. But I can assure you it's not as simple as getting a working example code from someone...

    But before you even dream of attempting to make PTP work, you should have rock-solid understanding (and working code) of the communication between one TM4C board and a PC (a "known good" communication partner). I believe I'm not alone when I suggest to take very small, very well controlled steps towards your final target.

    Best regards,

    Veikko

  • Veikko Immonen said:
    I believe I'm not alone when I suggest to take very small, very well controlled steps towards your final target.

    Not alone - really?     Let's see a, "show of hands?"    (2 oars fall overboard (from this KISS canoe) when hands raise)

    Immediate gratification rules - small, controlled/methodical/thoughtful steps may have (passed) their (brief) time in the sun...   (although a "tuned" piano is always melodic...especially when "island-bound"...[this way too "inside" for all but 2])

    We of course applaud your "KISS" direction...

  • Hi Viekko, I realize its not an easy process from your previous answer. Well , I have started from what you have suggested. I'm not able to find the gotcha's that you have mentioned in the three example codes enet_lwip , enet_uip or enet_io. Please spread some light as to which 'example code' you are referring to in your reply to Stephen King. Do help me out.

    Regards ,
    Vandan
  • Vandan,

    A little more reading comprehension would serve you well.

    First, my name is Veikko, not Viekko - I wouldn't blame you if you couldn't pronounce it but I do expect everyone to be able to ctrl-c, ctrl-v it correctly.

    Second, the answer to your question can already be found in the thread. See my message on Apr 7th.

    Best regards,

    Veikko

  • cb1, appreciate the piano tuning reference - thanks for the spontaneous laughs!
  • Hi Veikko, my apologies for getting your name wrong.  Could you please elaborate on making a DIY stack.  Any links or reference document will be really helpful. Thanks

    Regards, Vandan

  • No harm done.

    If you're not yet familiar with the OSI model, that's where you need to start. Then read up on Ethernet framing, the IPv4 protocol (suggest skipping v6 for now), ARP, ICMP, UDP, etc etc... Wikipedia has decent articles on all of those. Once you've familiarized yourself with how networking works, and the TM4C Ethernet module documentation, the rest should be obvious. I didn't follow any "how to make an IP stack" guide... Don't expect to master all of those in a week or two - I gathered my knowledge bit by bit over the course of several years.

    Best regards,
    Veikko
  • A couple more tips that I remembered overnight; to simplify things, I didn't implement support for TCP nor IP fragmenting. This limits the use cases of the stack somewhat (quite severely in fact), but I considered the tradeoffs OK for my projected uses of the stack. Consider this if you wish to proceed creating your own stack.

    Best regards,

    Veikko