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.

TMS570LC4 EMACTransmit() issue

Other Parts Discussed in Thread: HALCOGEN, DP83640, DP83630, TMS570LC4357

Hello,

I hope someone can help me. I have the following problem:

I am using a TMS570LC4 with a DP83848 Ethernet Physical Layer Transceiver. With the Halcogen drivers for the dp83640 I am able to check the link (true) and to read out the vendor ID (correct). Unfortunately, when I use the function EMACTransmit(...) the program hangs in:

1
2
3
while (EMAC_BUF_DESC_EOQ != (EMACSwizzleData(curr_bd->flags_pktlen) & EMAC_BUF_DESC_EOQ))
    {
    }

What am I doing wrong? Of course I call EMACHWInit() with return = 1 (NO_ERR) first.

Kindly regards,

Werner

  • Werner,

    I'm forwarding your query to our EMAC experts.
  • Werner,

    I'm not completely familiar with that line of code. But I'm guessing that you've submitted the buffer descriptor to the EMAC, however it hasn't processed it and you're stuck waiting for it. Is that right?

    If that is the case, then something like the pin muxing or clocking could be the issue -- please see this post to see if it sounds familiar:
    e2e.ti.com/.../426102

    Basically if the clocking / pinmux / mii v.s. rmii selection aren't right - then the MAC doesn't start transmitting ..

    -Anthony
  • Good morning,

    Thank you very much for your help. I checked the pinmux as well as the clock settings. Everything seems to be ok. I found out, that when

    I enable the check "Enable Loopback Communication" in Halcogen, the program does not hang in the while loop any longer. TX interrupt is also

    reached. (But not RX interrupt). That brings me to a question: Is the EMAC driver only functional in loopback mode? I just want to send/receive mac messages to/from

    my ethernet Transceiver. How do I have to config the EMAC to send and receive frames? I do the following steps:

    1.) Halcogen setup

    2.) I use the native MII pins (w4,v4,u6,u5,t4,u7,e4,u4,t3,u3,v3,u8,r1,t2,g4,t9,f4)

    3.) Clock settings like in the example (PLL1 = 300, PLL2 = 300, VCLKA4_DIV = 37.5)

    4.) Enable interrupts 77 and 79

    5.) Call functions EMACHWInit(macaddr) anf create_packet(macaddr) like in the example.

    I am looking forward to your answer(s).

    Kindly regards,

    Werner

  • Is there perhaps somebody who has a functional EMAC driver? Interrupts are only reached in Loopback mode. I do not know why. If Loopback mode is not activated, the IDLE bit is unset in MACSTATUS->IDLE = 0. I can neither send nor receive messages. Is it possible to send messages out despite Loopback mode is enabled? I also recognized, that my TX_EN Pin never goes high. I scoped the TXD_0/1/2/3 lines and saw some data.

    I don't know what I am doing wrong.

    Kindly regards.

  • Werner,

    Yes, there's this project processors.wiki.ti.com/.../HALCoGen_Ethernet_Driver_and_lwIP_Integration_Demonstration using the DP83640 phy that is on the HDK board (which you can purchase) and it's also been ported to the DP83630 based launchpad processors.wiki.ti.com/.../LAUNCHXL2-570LC43.

    Everything you say still sounds like the issue I ran into.

    - Is the MII box on the *PINMUX* tab checked? (different box than on the EMAC tab you showed above).
    - On the PINMUX tab - on the "Input Pin Muxing" did you *also* make sure the EMAC pins take input from the
    default terminals. It's possible you have them set on the Output tab but not the input tab.
    - Please check the value of PINMMR89, 90, 91 and 160.
    Especially:
    6.5.3 Control of Ethernet Controller Mode
    PINMMR160[24] is set by default. This bit is used to enable the RMII (Reduced Media Independent
    Interface of the Ethernet controller). If the application desires to use the MII (Media Independent Interface
    of the Ethernet controller), then the PINMMR160[24] must be cleared.


    Best Regards,
    Anthony
  • Anthony,

    I checked all the MUX functions again and it turned out that two pins were muxed wrong.

    I am able to get RX Interrupts as well as TX Interrupts now.

    MII under the tab "Pin Muxing" is also checked and the Input Pin Muxing is also on default.

    I also checked the PIMMRs and they are also correct.

    Unfortunately I still have some EMAC problems. When I plug in the ethernet cable there is

    a lot of traffic on the line. The RX Interrupt is called several times correctly but finally I

    always end up in the Phantom Interrupt.

    Same thing happens after sending few packets. I still cannot send data through the dp83848

    When I watch the Registers  TXGOODFRAMES and RXGOODFRAMES I see the counters increasing

    untill reaching Phantom Interrupt.

    I scoped the TX lines. TX_EN also goes high. I am still wondering about the data lines TXD_0 to

    TXD_3. Although I created a packet like in the example I cannot see the data. I only see single

    pulses on all four lines:

    TXD_0:

    TXD_1:

    TXD_2:

    TXD_3:

     In contrast to the TX lines, on RX I see full frames. Although I see the TXGOODFRAMES counter increase,

    good frames don't seem to be sent. Any idea?

    Kindly regards,

    Werner

  • Hello,

    is there perhaps somebody who has an idea?

    here my .dil file.

    6813.dilfile.zip

  • Would you please check where the TX/RX descriptors are located? In most the TI example, they are located in the system RAM although there is a dedicated CPPI memory for the Ethernet module. On TMS570LC4357, I saw the EMAC transmit/receive sometimes hangs up in the middle of the operation because the descriptors are not loaded correctly when they are located in the system RAM. Moving the descriptors to the CPPI RAM solves the issue. On TMS570LC4357, access to the system RAM is slower compared to other Hercules devices. Not sure if it is related to your problem.

    Thanks and regards,

    Zhaohong
  • Hello again Zhaohang,

    How can I check the location of the TX/RX descriptor buffer? Can you please have a look on my HL_sys_main.c (User_init_MII()) and my HL_emac.c ? I copied the function "create_packet()" to HL_emac.c Although my RXGOODFRAMES counter increases I am not able to see the received data. Where to look it up? I think we are getting closer to the problem :)

    Thanks and regards.

    Werner

    3343.TMS570LC4.zip

  • I just checked the the register again and found out, that I am not able to read out following registers :

    Start: MACADDRLO (0xFCF78500) to End: RX7CP (0xFCF7867C). I do not understand why I cannot read them.

    Could this be the reason for my problem?

  • I took a look at the code and found that the CPPI RAM is used to store the descriptors. The error in EMAC register reading is caused by a bug in the gel file. The memory address for those registers are not included in the CCS memory map. It can be resolved by the attached gel file.

    3463.tms570lc43xx.gel

    Thanks and regards,

    Zhaohong

  • Hello Zhaohong,
    thank you very much for your help. Unfortunately I am not at work. I cannnot wait testing it. I still wonder why I always end up in the phantom interrupt. Could the wrong gel file be the reason for it? I also cannot explain the pulses on the TX lines. Well, I am really looking forward to test the gel file tomorrow. I hope I can at least receive and read out a few messages before ending up in the phantom interrupt.
    Thank you very much. I will inform you tomorrow.

    Best regards,
    Werner

  • Default location of descriptors in codegenerator's code is CPPI. Rx buffers are located in RAM (static global array).

    I'm checked this demo code some time ago and looks like that it is not work out of box. It doesn't work until you enable loopback in PHY.

    And yes, after several receives you will be in Phanton handler. Looks like it depends on count of allocated descriptrors/buffers (by default 10).

    Maybe descriptor was not reloaded or something else...


    P.S. one small comment. Default generated code contains MPU setting for RAM cache enable.

    Because of it you probably will not be able to check received data in memory viewer (only updated descriptors will be visible, but not buffer).

    So it is better to change this settings to disable RAM cache ;)

  • (1) You do not need to disable data cache to view content in the on-chip RAM. There is an ACP module on this device. Any update of the RAM from other master will be automatically removed from data cache.
    (2) Phantom interrupt normally occurs when the the interrupt flag is not cleared at the module but CPU already exited ISR. It is more likely to happen when the peripheral clock is slow and the peripheral space is configured as "device". When a memory is configured as "device" by Cortex-R5 MPU, CPU will move to the next instruction after the data is written into CPU store buffer. It does nto wait the data to actually reach the peripheral. The solution is to do a dummy read of of the EMAC status register at the end of EMAC ISR to ensure that it is cleared before exiting the ISR.

    Thanks and regards,

    Zhaohong
  • Hello Zhaohong,

    1. It is strange cause I was not able to check input buffer until cache was disabled. Maybe ACP should be enabled or configured?
    2. Maybe, I will check it.
  • Good morning,

    I tested the gel file this morning and -wonder- I can see the missing registers. Thank you.

    I started a new project with only EMAC activated.

    I added following code to the end of TX and RX ISR:

    while( HWREG(hdkif->emac_base + EMAC_MACEOIVECTOR) != EMAC_INT_CORE0_TX)
               	 EMACCoreIntAck(hdkif->emac_base, (uint32)EMAC_INT_CORE0_TX);

    accordingly

    while( HWREG(hdkif->emac_base + EMAC_MACEOIVECTOR) != EMAC_INT_CORE0_RX)
           	 EMACCoreIntAck(hdkif->emac_base, (uint32)EMAC_INT_CORE0_RX);

    Now I do not end up in the phantom interrupt again.

    Still I don't know where to watch the received data. The RXGOODFRAMES counter increases

    but where to watch die source MAC Address of the received frame or the data?

    Sending data still does not work. Although I am sending two frames and also reach the

    TX ISR, data wont sent. I made some trys and suddenly with wireshark I could see two frames.

    One is 470, the other is 600 bytes.

    because in main I do following:

    /* USER CODE BEGIN (2) */
    
    extern hdkif_t hdkif_data[1];
    pbuf_t pack[5];
    static uint8 data[5][100];
    uint32 size1 = 470,size2=94;
    
    
    
    /* USER CODE END */
    
    uint8	emacAddress[6U] = 	{0xAAU, 0xBBU, 0xCCU, 0xDDU, 0xEEU, 0xFFU};
    uint32 	emacPhyAddress	=	1U;
    
    void create_packet()
    {
    	int i,j;
    
    	for(i=0;i<5;i++)
    	{
    	pack[i].tot_len = size1;
    	pack[i].len = size2;
    	for(j=0;j<6;j++)
    	{
    		data[i][j] = 0xffu;
    
    	}
    	for(j=0;j<6;j++)
    	{
    		data[i][j+6]= emacAddress[j];
    
    	}
    
    	data[i][12] = 0;
    	data[i][13] = 80;
    
    	for(j=0;j<80;j++)
    	{
    		data[i][j+14] = i+5;
    	}
    
    	pack[i].payload = &data[i][0];
    	if(i!=4)
    	pack[i].next = &pack[i+1];
    	}
    	pack[4].next= NULL;
    }
    
    void main(void)
    {
    /* USER CODE BEGIN (3) */
    	_enable_IRQ();
    	EMACHWInit(emacAddress);
    	HWREG(hdkif_data->emac_base + EMAC_RXMBPENABLE) |= ((uint32)EMAC_RXMBPENABLE_RXCAFEN);
    
    	create_packet();
    	EMACTransmit(&hdkif_data[0], &pack[0]);
    	size1=600;
    	size2=120;
    	create_packet();
    	EMACTransmit(&hdkif_data[0], &pack[0]);
    
    		while(1);
    /* USER CODE END */
    }

    I am quite sure, that these are my two frames. But I don't know why the data bytes are all 0x00. MAC

    Addresses are also missing. The only diference in sending this time was waiting to run my application

    untill only very little traffic was on the bus. Seems that receiving and transmitting at the same time

    does not work. I also tried in Loopback mode without success. Also disabled and enabled the cache.

    Thank you very much for your help.

    I am seeing the light at the end of tunnel ;)

    Best regards, Werner

  • If you use HCG code, received data will be availabe at (see HL_emac.c):

    static uint8_t pbuf_array[MAX_RX_PBUF_ALLOC][MAX_TRANSFER_UNIT];

    Did you try to check driver in loopback mode with PHY loopback enabling?
    To enable PHY loopback add the following:

    Dp83640EnableLoopback(hdkif->mdio_base, 1);

    somethere in EMACHWInit function after MDIOInit call.
  • Hello Dmitry,
    I tried in Loopback mode with phy loobpack enable. Without success.
    I am not even able to read the pbuf_array. I put a breakpoint into my
    RX ISR but the array never got updated. No data are send out :(
    I am really getting crazy....
  • I am finally able to receive data over Ethernet :) I disabled loopback (phy and EMAC) and cach. When I watch the pbuf_array I can see the same data as I see in wireshark. -Great success-
    Unfortunately sending still does not work. I think loopback does not work because of the sending. I could of course receive nothing without having sent something. I also realized that after the pbuf_array (10 elements) is full, nothing else is received and no more receive or transmit interrupt is called.
    I keep on researching.

    Best regards,
    Werner
  • Strange, after adding PHY loopback enable and cache, HCG demo start working fine (at leash for first 10 transmits).
    Maybe it is a HW problem...or packets are filtered? Does your packets are with normal size (60-1514 (64-1518))?
  • Yes, all packets do have normal size. Right now I think it is perhaps a config issue of the phy. I am not using the 83640 but the 83848. Receiving works fine but transmitting not...
  • OK, loopback does work. I send data and receive them in my buffer. But datas are not sent out of the phy :(
  • You may want to consider using a RJ45 loopback adapter to test the EMAC plus PHY combination. In the test, you configure the EMAC and PHY normally. Any message you send will be looped back outside the PHY. You can find more information from the following link.

    www.cableorganizer.com/network-test-equipment;gclid=CjwKEAjwlPOsBRCWq5_e973PzTgSJACMiEp2ZWcHCLHRVOCOw772ze8Sce6_hyjYtDU07S7qs5VnvBoCQT_w_wcB

    Thanks and regards,

    Zhaohong