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.

TM4C1292NCPDT: Unable to get IP address from Custom PCB Board

Other Parts Discussed in Thread: TM4C1292NCPDT, UNIFLASH

Hi,

I am using TM4C1292NCPDT in our custom board to validate interface between external PHY(KSZ8765) and controller.  I used the code from thread (RTOS/TM4C1292NCPDT: Issue in External PHY configuration through MII interface - Arm-based microcontrollers forum - Arm-based microcontrollers - TI E2E support forums ) and modified as per my application. 

Modified code has been attached./cfs-file/__key/communityserver-discussions-components-files/908/tcpEcho_5F00_B.zip

I am able to configure the switch.

But not able to get output on Wireshark and Terminal window. See below

 

Please share your feedback or suggestions.

Thanks,

Kiran

  • Hi,

      We don't have examples for interfacing with external PHY. Looking at your code, you seem to mix lwIP with TI-RTOS NDK.  Are you trying to use both stacks at the same time? These are entirely two different TCP/IP stacks. In addition, TI-RTOS incorporates C:\ti\tirtos_tivac_2_16_00_08\products\TivaWare_C_Series-2.1.1.71b but your include path seems to use TivaWare_2.1.4.178 while your have other search paths for TivaWare_2.2.0.295. You will need to do the debug on your own. The post you reference should server you as a good starting point. I will suggest you either use lwIP stack or only TI-RTOS NDK stack, not both at the same time. Perhaps you can start with TI-RTOS example tcpEcho example. Again, make sure the stock example works first on LaunchPad. Capture the wireshark for it. Next modify the example to interface with the external PHY on your custom board. Capture the wireshark and compare between the two. Make sure you are able to configure the external PHY through MDIO interface and you are getting the clock to EMAC from the external PHY. These are the things I can come up with. 

      You can find the stock TI-RTOS tchpEcho example as follows. 

  • Hi Charles,

    Thanks for suggestions!!

    Please find the updated code file for your review. /cfs-file/__key/communityserver-discussions-components-files/908/tcpEcho_5F00_Kiran_5F00_extPhy.zip

    See below the output of Console:

    What can i understand from Network added? Please advise !!

    MAC address:

    Wireshark window :

    Please verify below setting for serial port setup and connection. Is it correct?

    Thanks,

    Kiran

  • Hi Charles,

    I am not getting MII signal on scope only Clock is coming (MII_RX_CLK and MII_TX_CLK)

    Can you please verify MII section in my modified code? why i am not getting MII signals on scope?

    Thanks a lot for your support!!

    Thanks,

    Kiran  

  • I'm confused.

    The question is if you are trying to program MAC with 00:00:00:00:00:00. Below is what I see in your screenshot. 

     

    How can you get a DHCP IP address of 192:168.1.100 if your MAC address is 00:00:00:00:00:00? 00:00:00:00:00:00 is an invalid MAC address. You need to program a valid MAC address with the OUI fields (the first 3 bytes of MAC) that pertains to your company. On LaunchPad, the MAC is pre-programmed with a valid MAC address that pertains to TI. 

    Why don't you try the stock tcpEcho TI-RTOS example with a valid MAC address. You should get a connection and be able to exchange messages with the server. Later if you reprogram the MAC to all 0's then the example will not work because MAC address equal 00:00:00:00:00:00 is not a valid address.

  • Hi Charles,

    Thanks for your comments!!

      You can find the stock TI-RTOS tchpEcho example as follows.

    Can you please share the link for stock TI-RTOS? Please share the path for this file.

    I am not getting the file as your suggested. See below 

    https://dev.ti.com/tirex/explore

    Thanks,

    Kiran

  • 1. Normally I open Resource Explorer from within CCS. See below. 

    2. After you open Resource Explore you click the three bar at the upper right of the page. See below. 

    3. Select 'Package Manager'.

    4. Scroll down until you see TI-RTOS for TivaC

    5. Scroll to the right, Select and Install. 

    6. After you do that you should see TI-RTOS for Tiva as follows. 

    If you still can't import from Resource Explorer then you can import directly by File->Import. See below. 

    Select CCS Projects to import. 

    When prompted to enter the CCS project directory path, you can provide the below path to discover the projects. 

    It will discover several Ethernet examples. You just select the one you want to import into CCS. 

  • Hi Charles,

    I will try with example as you suggested but I am not able change MAC address with CCS Uniflash or with CCS compiler in Debug and Run. 

    Programmed MAC address:

    When i tried to read MAC address. See below 

    Below is the change in code to change the MAC address:

    Please share your comments.

    Thanks,

    kiran

  • Hi,

      MAC address is stored in USER_REG0 and USER_REG1. These are non-volatile registers. In another word, these registers are one-time programmable only. After you program a MAC address to these registers you cannot program again. You must perform a mass-erase which is an unlock operation. See datasheet description.

    If you are using the LaunchPad, you can use LM flash programmer to unlock the device first. After the device is unlocked (restored to it factory setting) you can program a new MAC address again. See below. 

     

  • Hi Charles,

    If you are using the LaunchPad, you can use LM flash programmer to unlock the device first. After the device is unlocked (restored to it factory setting) you can program a new MAC address again.

    --> My custom board uses XDS200 Debug probe to program the device, so LM Flash Programmer doesn't support it.

     I use CCS Uniflash utility The screenshot results that I put in my previous post were from my custom board.

    MAC address is stored in USER_REG0 and USER_REG1. These are non-volatile registers. In another word, these registers are one-time programmable only. After you program a MAC address to these registers you cannot program again. You must perform a mass-erase which is an unlock operation.

    --> As suggested, I performed the unlock operation and tried programming the MAC address again. Althpugh it is changing the MAC address in the reference board but it isn't getting changed in the custom board. See below

    Is there anything I'm missing in the unlock procedure?

    Also,in the datasheet I found the following :

    Is the MAC Address 0x0010A1FFFFFF by default? 

    Best Regards,

    Kiran

  • Hi,

     Did you unlock successfully? After you unlock, can you first read the MAC address before programming a new one? If the unlock was successful then you will be reading FF-FF-FF-FF-FF-FF. If you read 00-00-00-00-00-00 then the unlock was not successful even though the console said otherwise. You can  refer to section 5.3.2 of this app note to use dbgjtag.exe to unlock the device using XDS200. 

    https://www.ti.com/lit/pdf/spma075

  • Hi Charles,

    I followed the same steps to unlock.

    But the 'Read MAC Address' returned as 0-0-0-0-0-0

    I pressed the Reset button on custom board and pressed 'Unlock' in CCS Uniflash utility.

    After this, the Reset button was released and 'Finish Unlock' was pressed. Then I power cycled the board.

    Let me know if i missed something.

    Thanks,

    Kiran 

  • Hi,

    I followed the same steps to unlock.

    What same steps did you try? It looks like you are still using CCS/Uniflash to unlock, is that correct?

      In my last reply, I suggest you try dbgjtag.exe command line to unlock the device for XDS200. Did you have a chance to try? Please refer to section 5.3.2 in this app note. https://www.ti.com/lit/pdf/spma075

  • Hi Charles,

    In my last reply, I suggest you try dbgjtag.exe command line to unlock the device for XDS200. Did you have a chance to try? Please refer to section 5.3.2 in this app note

    I did not get dbgjtag.exe. See below:

    I found one more thread where FMA used for MAC address.

    https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/424406/tiva-4c129-bootcfg-issues?pifragment-323257=2

    Please go through this post and suggest some steps. 

    Thanks,

    Kiran

  • Kiran,

      I don't know which CCS version you use. You can find dbgjtag.exe in the CCS installation for CCS12. See below. 

    The FMA/FMC is used if you want to program the MAC address to USER_REG0/USER_REG1 by the application instead of using Uniflash or LM flash programmer tool. But before you can use FMA/FMC method to program MAC address, you MUST first unlock the device. 

    In your screenshot, your MAC is showing all 0's. Just to make sure it is really true 0's, can you read USER_REG0/USER_REG1 in CCS register window. See below.

  • Hi Charles,

    I suggest you try dbgjtag.exe command line to unlock the device for XDS200

    Yes, I tried dbgjtag.exe in command prompt and I was able to unlock successfully. The MAC address was now reading as FF-FF-FF-FF-FF-FF.

    Thank for your suggestion.

    I programmed the new MAC address as well but I can't see the wireshark traffic. See below

    Also, see the Console output below. If I've to find a string globally in a project (i.e. in all the files of the project ),the  how do I do that? I tried Ctrl+H option but it didn't work. In this work,I want to find while file is printing 'Network Added' in the Console Window below.

    In general, while debugging how do I find out the flow of the code ,like if it moves from one file to another how to track that?

    Please guide.

    Thanks,

    Kiran

  • Hi Charles,

    One more thing that How can i get a IP address?

    Thanks,

    Kiran

  • I programmed the new MAC address as well but I can't see the wireshark traffic. See below

    Can you see wireshark traffic for the stock Ethernet example?

    Also, see the Console output below. If I've to find a string globally in a project (i.e. in all the files of the project ),the  how do I do that? I tried Ctrl+H option but it didn't work. In this work,I want to find while file is printing 'Network Added' in the Console Window below.

    I don't think you can do a global search for the string 'Network Added' on the CCS workspace I think 'Network Added' comes from somewhere in the NDK library that is in your NDK installation not in your CCS workspace. Sorry, I don't much knowledge in the inner workings of NDK to know which file it comes from. I think it is coming netctrl.c but not sure. 

    In general, while debugging how do I find out the flow of the code ,like if it moves from one file to another how to track that?

    You can put a breakpoint or single step for debugging and look at the callstack window. If you put a breakpoint on a line and after that line is reached, you can see the callstack to see how that the function is called from the callstack which shows the hierarchy of the calls. You can click on any one of the them (see highlighted in yellow for example) to take you to the file that invokes the function. 

    As explained in the very beginning of the original thread, I have no experience with external PHY. I strongly suggest you start with a simple stock TI-RTOS Ethernet example. Do NOT yet modify it. Get it to compile and work first. After that you will make modification to use the external PHY. Again, the only thing you should change are code related to supporting external PHY initialization. If you can get it to work then you can gradually add your own application specific code. This is the best recommendation I have give you. 

  • Hi Charles,

    Can you see wireshark traffic for the stock Ethernet example?

    See below:

    I am using below example

    Wireshark:

    Let me know if you have any suggestion or comments.

    Thanks,

    Kiran

  • Hi Charles,

    ,I want to find while file is printing 'Network Added' in the Console Window below.

    On launchpad, we have RJ45 port but we are using ethernet media converter for custom board due to  fiber port on controller board.

    Will it create any modification in IP address as per compare to without media converter?  

    Thanks,

    Kiran

  • Wireshark:

    Hi,

      In the future, please always run the stock example on the LaunchPad first. It will be your best reference. Looking at your wireshark capture above, I suppose you are running the stock example on your custom board. Is that correct? Although I'm not an expert in interpreting all the wireless traffic but If you look at the wireshark capture, there is a lot of [RST, ACK]. You can do google search on what caused [RST, ACK] packets to be sent. Here are some of them. Most of the time, you may see [RST, ACK] when the application on the server doesn't want to talk to the client IP (which the application only gets notified about after the handshake). It's not the TCP stack itself that sends the RST, it's doing it because the application closed the socket.

    https://osqa-ask.wireshark.org/questions/5533/rst-ack-immediately-after-sending-data/.

    https://osqa-ask.wireshark.org/questions/1652/what-would-cause-rstack/#:~:text=What%20would%20cause%20this%3F&text=This%20is%20very%20simply%20that,possibly%20it%20has%20been%20firewalled.

    https://osqa-ask.wireshark.org/questions/51332/tcp-server-sends-ack-rst-right-after-ack/

      This is what I will suggest you do to troubleshoot. 

    1.  Run the stock example on LaunchPad connected to a simple switch on your network. Make sure it works. It is supposed to work out of box. Capture the wireshark. You should always use this as your golden reference. 

    2.  Run the stock example on LaunchPad connected to your ethernet media converter. I'm not sure the details of your ethernet media converter and I don't know if this is possible for you to connect the LaunchPad to it. If you can run the stock example on LaunchPad connected to the ethernet media converter then you will know if the ethernet media converter is creating any problem vs. a switch. Capture the wireshark. Do a ping to the server. Can you reach the server successfully with a ping?

    3. Run the stock example on your custom board connected to your ethernet media converter. Capture the wireshark. Do a ping to the server. Can you reach the server successfully with a ping?

    4. Compare the wireshark capture between 1 and 3. Since the software is identical, the difference between 1 and 3 is the ethernet media converter and also the integrated PHY as in LaunchPad vs external PHY as in your custom board. You will need to isolate the problem to know if the problem is due to the ethernet media converter or because of the connection to the external PHY. 

      a. Check if you have configured the external PHY successfully. Can you read/write to the registers on the external PHY?

      b. Are you in MII or RMII mode?

      c. Are you getting EN0REF_CLK at 50Mhz  from the external PHY to EMAC controller on MCU if you are are running at RMII mode? Read the datasheet concerning the clock. 

     

     

    d. Are you in correct MII or RMII mode when you configure EMACPC register at 0xFC4?

  • One more thing on your wireshark capture, you have set the TCP port 23. The stock example uses TCP port 1000, not 23. See below. 

  • nHi Charles,

    1.  Run the stock example on LaunchPad connected to a simple switch on your network. Make sure it works. It is supposed to work out of box. Capture the wireshark. You should always use this as your golden reference. 

    Wireshark and socket output:

    Console Output:

    Now, in this output of stock example also, where is the console print "Network Added" coming from? I couldn't find it in the file you mentioned, i.e. netctrl.c. Any suggestions on where to find it?

    Now I will modify the same code for ext phy.as guided by you

    Best Regards,

    Kiran

  • Hi Charles,

    I've done modification in the tcp stock example.

    How do I add my own EMACSnow.c file (i.e. tcp_EMACSnow.c ) in this project with functions for external PHY because there's already an EMACSnow.c file in the ' tidrivers' library path and it shows errors in the functions redefined while building the project.

    Also,what's the difference between EMAC and EMACSnow?

    Below is my code attached:

    cfs-file/__key/communityserver-components-multipleuploadfilemanager/9cc8a509_2D00_2227_2D00_4364_2D00_8f19_2D00_deb0f50246a3-532865-complete/tcpEcho_5F00_Kiran_5F00_EK_5F00_TM4C1294XL_5F00_TI2_5F00_extPhy.zip

    Thanks,

    Kiran

  • Now, in this output of stock example also, where is the console print "Network Added" coming from? I couldn't find it in the file you mentioned, i.e. netctrl.c. Any suggestions on where to find it?

    ok. the stock example is working for you. So keep the wireshark capture as your golden reference for future comparison to your modified code. Having said that I really don't know the exact file the 'Network Added' is coming from. I think it is deeply embedded in the NDK library or the generated NDK code that I have not much knowledge with. Sorry.

     

    How do I add my own EMACSnow.c file (i.e. tcp_EMACSnow.c ) in this project with functions for external PHY because there's already an EMACSnow.c file in the ' tidrivers' library path and it shows errors in the functions redefined while building the project.

    I don't have any problem just copying EMACSnow.c to the local project directory. See below. You can make modification to it and build it along with the rest of your project. Always start with the stock example before you venture to your custom code. Copy EMACSnow.c to your stock example directory and rebuild the stock example and make sure it works first. Also you don't really need to modify EMACSnow.c if you just want to change the PHY configuration. You can define EMAC_PHY_CONFIG in your application. 

  • Hi Charles,

    ok. the stock example is working for you. So keep the wireshark capture as your golden reference for future comparison to your modified code. Having said that I really don't know the exact file the 'Network Added' is coming from. I think it is deeply embedded in the NDK library or the generated NDK code that I have not much knowledge with. Sorry.

    Thanks a lot for your support.

    Can you please below mentioned links for this problem?

    https://software-dl.ti.com/simplelink/esd/simplelink_msp432e4_sdk/2.20.00.20/docs/ndk/NDK_Users_Guide.html

    https://software-dl.ti.com/simplelink/esd/simplelink_msp432e4_sdk/2.20.00.20/docs/ndk/NDK_Users_Guide.html#network-control-functions

    Below mentioned function is responsible for "Network Added'

    So i checked same thing on stock example code but i found this:

    Is my finding correct ? if yes then i am not able find printf command. Please advise.

    Thanks,

    Kiran

  • Hi Charles,

    I don't have any problem just copying EMACSnow.c to the local project directory. See below. You can make modification to it and build it along with the rest of your project. Always start with the stock example before you venture to your custom code. Copy EMACSnow.c to your stock example directory and rebuild the stock example and make sure it works first. Also you don't really need to modify EMACSnow.c if you just want to change the PHY configuration. You can define EMAC_PHY_CONFIG in your application. 

    As suggested , below changes have been made in EMACSnow.c:

    Console Output:

    But i am not getting output on Wireshark.

    Please advice if i missed something.

    Thanks,

    Kiran

  • Below mentioned function is responsible for "Network Added'

    So i checked same thing on stock example code but i found this:

    Is my finding correct ? if yes then i am not able find printf command. Please advise.

    I think I figure out where the printf is. it is in the generated NDK code.

    1. Go to tcpEcho_pem4f.c file. See below. 

    2. In tcpEcho_pem4f.c, go to the line where NC_NetStart is called. NC_NetStart will call ti_ndk_config_Global_NetworkIPAddr. 

    3. If you trace ti_ndk_config_Global_NetworkIPAddr, it is here that is printing 'Network Added'. 

    But i am not getting output on Wireshark.

    As I mentioned before, I don't have experience with external PHY. You will need to do some debugging here. First, find out if the external PHY is up and running. I have provided you some debugging tips before. 

      a. What is your external PHY partnumber? How are you configuring the PHY? By MDIO interface or by SPI interface or others?

      b. Check if you have configured the external PHY successfully. Can you read/write to the registers on the external PHY?

      c. Are you in correct MII when you configure EMACPC register at 0xFC4?

      d. Do you have proper clocks from PHY to the MCU?

     

     

     e. Is the external PHY link up? See below. As a matter of fact, I will suggest you compare all the registers between LaunchPad and your custom board. I think it will help you narrow down any register differences between integrated PHY vs external PHY. 

  • Hi Charles,

    I think I figure out where the printf is. it is in the generated NDK code.

    Thanks a lot for support!!

    a. What is your external PHY partnumber? How are you configuring the PHY? By MDIO interface or by SPI interface or others?

    Part Number: KSZ8765

    We are using SPI interface 

    b. Check if you have configured the external PHY successfully. Can you read/write to the registers on the external PHY?

    Yes we can do this. See below

    c. Are you in correct MII when you configure EMACPC register at 0xFC4?

    Did you want to verify above mentioned image? 

    d. Do you have proper clocks from PHY to the MCU?

    MOSC Scope:

    ENORXCK and ENOTXCK: Please verify below image. Is this in correct form?

    How can i verify Gated system clock?

    Is the external PHY link up? See below. As a matter of fact, I will suggest you compare all the registers between LaunchPad and your custom board. I think it will help you narrow down any register differences between integrated PHY vs external PHY. 

    I am not able to find EPHYBMSR in datasheet. Can you please share page no where it is mentioned?

    Thanks,

    Kiran

  • b. Check if you have configured the external PHY successfully. Can you read/write to the registers on the external PHY?

    Yes we can do this. See below

    The screenshot above only shows the MAC address. I think MAC address is printed out by TI-RTOS, right? I was asking if you can read and write to the  KSZ8765 registers? You need to make sure the SPI is setup correctly and you can read/write to KSZ8765 successfully. 

    c. Are you in correct MII when you configure EMACPC register at 0xFC4?

    Looks like most of the bits in EMACPC are only for MCU with integrated PHY. Since you are using TM4C1292NCPDT, most of the bits should not apply - in another word, they will be blank. See below. However, very importantly, bit 31 is supposed to show an external PHY is used although it is not well documented in TM4C1292NCPDT datasheet. You need to make sure bit 31 is high. 

    d. Do you have proper clocks from PHY to the MCU?

    MOSC Scope:

    ENORXCK and ENOTXCK: Please verify below image. Is this in correct form?

    Your clocks look fine to me.

    I am not able to find EPHYBMSR in datasheet. Can you please share page no where it is mentioned?

    Sorry, EPHBMSR is for the internal PHY. Since you are using an external PHY, you will not have this register. But FYI, the register below is for MCU integrated PHY. 

    Please check all the following and report back. 

    1. Make sure you do NOT enable internal PHY. The stock example uses internal PHY. You must not use internal PHY. For TM4C1292NCPDT, the internal PHY is inaccessible anyway. You must use external PHY as follows. I think you are doing that already. But make sure the register is reflected in EMACCC register and EMACPC. The CLKEN bit should be 0 when MII is used. PTPCEN should be 1 in EMACCC register. Bit 31 in EMACPC register must be high to select external PHY. 

    #define EMAC_PHY_CONFIG EMAC_PHY_TYPE_EXTERNAL_MII

    2. Your application must include code to configure the GPIO pins for MII functions. Your application must configure MII pins using GPIOPinTypeEthernetMII(). I'm not sure if you are doing that. This is very important. If you do not configure the GPIO muxing circuit to use for Ethernet MII then they remain as GPIO pins only. So check it carefully that all relevant pins are properly configured. Without proper pin muxing there is no way for EMAC to talk to the external PHY. Look at the MII pins again in the datasheet if your board has these connections. 

    Check your pin muxing if you have used GPIOPinTypeEthernetMII to configure these pins matching your hardware connection. 

    3. I suppose you have already configured GPIO pins for SPI functions in order to read/write your external PHY registers. 

    4. Your external PHY must have a register that indicates link status if the PHY is up and running. You should check such register to make sure PHY is up.   

  • Hi Charles,

    The screenshot above only shows the MAC address. I think MAC address is printed out by TI-RTOS, right? I was asking if you can read and write to the  KSZ8765 registers? You need to make sure the SPI is setup correctly and you can read/write to KSZ8765 successfully. 

    Please see the code snippets for Ethernet Switch and Ethernet IC's port configuration below:

    3. I suppose you have already configured GPIO pins for SPI functions in order to read/write your external PHY registers. 

    Yes they're configured for SSI, see in the function iocEthernetSwitchConfig_ksz8765 below.

    void iocEthernetSwitchConfig_ksz8765(void)
    {
    //    UARTprintf("%s() : iocEthernetSwitchConfig : Configuring...\n",__FUNCTION__);
    
        // This "MII BYPASS" is actually txer5 from the ksz8765,
        // and therefore must be set to an input, since it's not used.
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
        GPIOPinTypeGPIOInput(GPIO_PORTG_BASE, GPIO_PIN_6);      // U45-55     MII_BYPASS     U46-28_MII_BP
    
        // PME is an output from the ksz8765, and must be set as input.
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOK);
        GPIOPinTypeGPIOInput(GPIO_PORTK_BASE, GPIO_PIN_1);
    
        // TODO why does OLD eth chip have this set as input here?  this is driving its rst input.
    //    GPIOPinTypeGPIOInput(GPIO_PORTK_BASE, GPIO_PIN_1);
        GPIOPinTypeGPIOOutput(GPIO_PORTK_BASE, GPIO_PIN_1);
    
        /* MDIO and MDC as Input pins */
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
        GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_2); // PF2 PIN 44 NC
        GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_3); // CAN'T FIND
        GPIOPinTypeGPIOInput(GPIO_PORTC_BASE, GPIO_PIN_6); // rst_n to ksz8765
        GPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_6, GPIO_PIN_6);
    
        /* SPI-2 DATA2 and DATA3 pins as input */
        // U45 TM4C1292NCPDTI3 to U21 LAN9252
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
        GPIOPinTypeGPIOInput(GPIO_PORTD_BASE, GPIO_PIN_6);       // CONT_ECAT_QSPI_DATA3
        GPIOPinTypeGPIOInput(GPIO_PORTD_BASE, GPIO_PIN_7);       // CONT_ECAT_QSPI_DATA2
    
        // U45 TM4C1292NCPDTI3 to U46 KSZ8463FMLI
        SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI2);
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
        GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE, GPIO_PIN_2);      // U45-3    CONT_QSPI_CS     CONT_ETHSW_CS_N     U46-42_SPI_CSn
        GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_2, GPIO_PIN_2);   // Set CS HI
        GPIOPinConfigure(GPIO_PD3_SSI2CLK);                      // U45-4    CLK_QSPI_CONT    CLK_CONT_ETHSW      U46-44_SPI_SCLK
        GPIOPinConfigure(GPIO_PD1_SSI2XDAT0);                    // U45-2    CONT_QSPI_DATA0  CONT_ETHSW_MOSI     U46-45_SPI_DI
        GPIOPinConfigure(GPIO_PD0_SSI2XDAT1);                    // U45-1    CONT_QSPI_DATA1  ETHSW_CONT_MISO     U46-41_SPI_DO
        GPIOPinTypeSSI(GPIO_PORTD_BASE, GPIO_PIN_3 | GPIO_PIN_1 | GPIO_PIN_0 );
    
    //    UARTprintf("%s() : iocEthernetSwitchConfig : Resetting...\n",__FUNCTION__);
    
        /* Ethernet Switch Reset */
        GPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_6, 0X00);
        SysCtlDelay(10000);
        GPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_6, GPIO_PIN_6);
    
    //    UARTprintf("%s() : iocEthernetSwitchConfig : Reset done\n",__FUNCTION__);
    
    
        /* Reset Ethernet Switch */
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
        GPIOPinTypeGPIOOutput(GPIO_PORTC_BASE, GPIO_PIN_6);
        GPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_6, GPIO_PIN_6);
    
        System_printf("\nMII and SPI configured for Ethernet Switch\n");
        System_flush();
    
    }

    void ioc_EthernetPortConfig_ksz8765(bool bMode,bool dbg)
    {
    
    //    if(bMode == TIVA)
    //        UARTprintf("%s() : Starting...\n",__FUNCTION__);
    //    else
    //        ioc_UartPrint("%s() : Starting...\n",__FUNCTION__);
    
        // Global registers
    
    
        // LED Mode
        // OLD (ks8463)
        //  IOCNAME  bits [9:8] in SGCR7      00          01          10          11
        //  LINKx    P1LED1/P2LED1            Speed       ACT         Duplex      Duplex
        //  100Mx    P1LED0/P2LED0            Link/ACT    Link        Link/ACT    Link
        // NEW (ksz8765)
        //  IOCNAME  bits[5:4]                00          01          10          11
        //  LINKx    LEDx_1                   Speed       ACT         Duplex      Duplex
        //  100Mx    LEDx_0                   Link/ACT    Link        Link/Act    Link
        ioc_PhyWriteOperation_ksz8765(0x0B,0x10,bMode,dbg);
    
        // Force 100-full, since autonegotiation is not supported in 100Base-FX (Fiber)
        // 0b11111111 = 0xFF
        ioc_PhyWriteOperation_ksz8765(0x1C,0xFF,bMode,dbg);
        //ioc_PhyWriteOperation_ksz8765(0x2C,0xFF,bMode,dbg);
    
    //    // Disable Auto MDX
    //    // 0b00000110 = 0x06
    //    ioc_PhyWriteOperation_ksz8765(0x1D,0x06,bMode,dbg);
    //    ioc_PhyWriteOperation_ksz8765(0x2D,0x06,bMode,dbg);
    
        // Port registers
        // Register 86 (0x56): Port 5 Interface Control 6
        ioc_PhyWriteOperation_ksz8765(0x56,0xA8,bMode,dbg);
        System_printf("Ethernet Switch is Configured\n");
               System_flush();
       // ioc_ksz8765_rdall(0,1);
    }

    At the end of the functions, they're printing "\n MII and SPI configured for Ethernet Switch\n" and "Ethernet Switch is Configured\n" respectively which is getting printed in the Console before the MAC address is printed. How do I check if it's actually getting configured successfully other than printing this? Even, if I check the SPI waveforms will that make sure the SPI data was transferred to the switch successfully?

    Looks like most of the bits in EMACPC are only for MCU with integrated PHY. Since you are using TM4C1292NCPDT, most of the bits should not apply - in another word, they will be blank. See below. However, very importantly, bit 31 is supposed to show an external PHY is used although it is not well documented in TM4C1292NCPDT datasheet. You need to make sure bit 31 is high. 

    In the EMACSnow.c file, the function 

    EMACPHYConfigSet(EMAC0_BASE, EMAC_PHY_CONFIG);

    is called inside the function int EMACSnow_NIMUInit(STKEVENT_Handle hEvent) 

    And we have defined #define EMAC_PHY_CONFIG          EMAC_PHY_TYPE_EXTERNAL_MII (you can check in the code shared)

    in EMACSnow.c file so this means the value in EMAC_PC should be 0x80000000 but it is not coming as expected, is there any other file/function/defintion where we need to make the changes? 

    Your application must include code to configure the GPIO pins for MII functions. Your application must configure MII pins using GPIOPinTypeEthernetMII(). I'm not sure if you are doing that. This is very important. If you do not configure the GPIO muxing circuit to use for Ethernet MII then they remain as GPIO pins only. So check it carefully that all relevant pins are properly configured. Without proper pin muxing there is no way for EMAC to talk to the external PHY. Look at the MII pins again in the datasheet if your board has these connections. 

    We're using the function PinoutSet() to configure the EthernetMII pins,which is configuring the MII pins using GPIOPinTypeEthernetMII function only. Please check the screenshot below

    Check your pin muxing if you have used GPIOPinTypeEthernetMII to configure these pins matching your hardware connection. 

    All these pins including EN0MDC and EN0MDIO are configured for MII signals. See below

    MAP_GPIOPinConfigure(GPIO_PP0_EN0INTRN);
    	GPIOPinTypeEthernetMII(GPIO_PORTP_BASE, GPIO_PIN_0);
    
        //
        // Configure the GPIO Pin Mux for PK4
    	// for EN0RXD3
        //
    	MAP_GPIOPinConfigure(GPIO_PK4_EN0RXD3);
    	GPIOPinTypeEthernetMII(GPIO_PORTK_BASE, GPIO_PIN_4);
    
        //
        // Configure the GPIO Pin Mux for PK6
    	// for EN0TXD2
        //
    	MAP_GPIOPinConfigure(GPIO_PK6_EN0TXD2);
    	GPIOPinTypeEthernetMII(GPIO_PORTK_BASE, GPIO_PIN_6);
    
        //
        // Configure the GPIO Pin Mux for PG5
    	// for EN0TXD1
        //
    	MAP_GPIOPinConfigure(GPIO_PG5_EN0TXD1);
    	GPIOPinTypeEthernetMII(GPIO_PORTG_BASE, GPIO_PIN_5);
    
        //
        // Configure the GPIO Pin Mux for PA6
    	// for EN0RXCK
        //
    	MAP_GPIOPinConfigure(GPIO_PA6_EN0RXCK);
    	GPIOPinTypeEthernetMII(GPIO_PORTA_BASE, GPIO_PIN_6);
    
        //
        // Configure the GPIO Pin Mux for PG7
    	// for EN0RXDV
        //
    	MAP_GPIOPinConfigure(GPIO_PG7_EN0RXDV);
    	GPIOPinTypeEthernetMII(GPIO_PORTG_BASE, GPIO_PIN_7);
    
        //
        // Configure the GPIO Pin Mux for PF2
    	// for EN0MDC
        //
    	MAP_GPIOPinConfigure(GPIO_PF2_EN0MDC);
    	GPIOPinTypeEthernetMII(GPIO_PORTF_BASE, GPIO_PIN_2);
    
        //
        // Configure the GPIO Pin Mux for PG3
    	// for EN0TXEN
        //
    	MAP_GPIOPinConfigure(GPIO_PG3_EN0TXEN);
    	GPIOPinTypeEthernetMII(GPIO_PORTG_BASE, GPIO_PIN_3);
    
        //
        // Configure the GPIO Pin Mux for PF3
    	// for EN0MDIO
        //
    	MAP_GPIOPinConfigure(GPIO_PF3_EN0MDIO);
    	GPIOPinTypeEthernetMII(GPIO_PORTF_BASE, GPIO_PIN_3);
    
        //
        // Configure the GPIO Pin Mux for PQ5
    	// for EN0RXD0
        //
    	MAP_GPIOPinConfigure(GPIO_PQ5_EN0RXD0);
    	GPIOPinTypeEthernetMII(GPIO_PORTQ_BASE, GPIO_PIN_5);
    
        //
        // Configure the GPIO Pin Mux for PM6
    	// for EN0CRS
        //
    	MAP_GPIOPinConfigure(GPIO_PM6_EN0CRS);
    	GPIOPinTypeEthernetMII(GPIO_PORTM_BASE, GPIO_PIN_6);
    
        //
        // Configure the GPIO Pin Mux for PK5
    	// for EN0RXD2
        //
    	MAP_GPIOPinConfigure(GPIO_PK5_EN0RXD2);
    	GPIOPinTypeEthernetMII(GPIO_PORTK_BASE, GPIO_PIN_5);
    
        //
        // Configure the GPIO Pin Mux for PG4
    	// for EN0TXD0
        //
    	MAP_GPIOPinConfigure(GPIO_PG4_EN0TXD0);
    	GPIOPinTypeEthernetMII(GPIO_PORTG_BASE, GPIO_PIN_4);
    
        //
        // Configure the GPIO Pin Mux for PG2
    	// for EN0TXCK
        //
    	MAP_GPIOPinConfigure(GPIO_PG2_EN0TXCK);
    	GPIOPinTypeEthernetMII(GPIO_PORTG_BASE, GPIO_PIN_2);
    
        //
        // Configure the GPIO Pin Mux for PQ6
    	// for EN0RXD1
        //
    	MAP_GPIOPinConfigure(GPIO_PQ6_EN0RXD1);
    	GPIOPinTypeEthernetMII(GPIO_PORTQ_BASE, GPIO_PIN_6);
    
        //
        // Configure the GPIO Pin Mux for PK7
    	// for EN0TXD3
        //
    	MAP_GPIOPinConfigure(GPIO_PK7_EN0TXD3);
    	GPIOPinTypeEthernetMII(GPIO_PORTK_BASE, GPIO_PIN_7);
    
        //
        // Configure the GPIO Pin Mux for PM7
    	// for EN0COL
        //
    	MAP_GPIOPinConfigure(GPIO_PM7_EN0COL);
    	GPIOPinTypeEthernetMII(GPIO_PORTM_BASE, GPIO_PIN_7);
    

    4. Your external PHY must have a register that indicates link status if the PHY is up and running. You should check such register to make sure PHY is up.

    Is the function 'EMACSnow_isLinkUp' or 'EMACSnow_emacPoll' in the file 'EMACSnow.c' being checked anywhere? 

    Instead of the line 

    newLinkStatus =
    (EMACPHYRead(EMAC0_BASE, 0, EPHY_BMSR) & EPHY_BMSR_LINKSTAT);

    I need to put 

    newLinkStatus = ioc_PhyReadOperation_ksz8765(0x1E,1,0);

    to check status of the link in my external PHY. Where should I replace this? (0x1E is the address of the status register for checking the link in my external PHY)

    Best Regards,

    Kiran

  • Yes they're configured for SSI, see in the function iocEthernetSwitchConfig_ksz8765 below.

    If you see proper SPI transactions on the scope then it should be fine. 

    At the end of the functions, they're printing "\n MII and SPI configured for Ethernet Switch\n" and "Ethernet Switch is Configured\n" respectively which is getting printed in the Console before the MAC address is printed.

    The print statement does not mean the SPI transactions are successful. This is why I asked to check if you can also read back what is written to make sure the write was successful. You can also look at the scope. 

    in EMACSnow.c file so this means the value in EMAC_PC should be 0x80000000 but it is not coming as expected, is there any other file/function/defintion where we need to make the changes? 

    Can you manually write to the register with value 0x80000000 using HWREG()?

    All these pins including EN0MDC and EN0MDIO are configured for MII signals. See below

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    MAP_GPIOPinConfigure(GPIO_PP0_EN0INTRN);
    GPIOPinTypeEthernetMII(GPIO_PORTP_BASE, GPIO_PIN_0);
    //
    // Configure the GPIO Pin Mux for PK4
    // for EN0RXD3
    //
    MAP_GPIOPinConfigure(GPIO_PK4_EN0RXD3);
    GPIOPinTypeEthernetMII(GPIO_PORTK_BASE, GPIO_PIN_4);
    //
    // Configure the GPIO Pin Mux for PK6
    // for EN0TXD2
    //
    MAP_GPIOPinConfigure(GPIO_PK6_EN0TXD2);
    GPIOPinTypeEthernetMII(GPIO_PORTK_BASE, GPIO_PIN_6);
    //
    // Configure the GPIO Pin Mux for PG5
    // for EN0TXD1
    //

    OK if you have configured the GPIO pins for MII function. 

    Is the function 'EMACSnow_isLinkUp' or 'EMACSnow_emacPoll' in the file 'EMACSnow.c' being checked anywhere? 

    Instead of the line 

    newLinkStatus =
    (EMACPHYRead(EMAC0_BASE, 0, EPHY_BMSR) & EPHY_BMSR_LINKSTAT);

    I need to put 

    newLinkStatus = ioc_PhyReadOperation_ksz8765(0x1E,1,0);

    Yes, you will need to get the link status from your KSZ PHY. The existing code is reading the link status from the integrated PHY that you don't have on the TM4C1292 device. 

  • HI Charles,

    Thanks for your response.

    I have one more query about scope of  ENORXCK and ENOTXCK.

    Comparison between scope of Custom board and Working board.  

    Scope of Custom board:

    Scope of Working board:

    Am i getting the correct waveform in Custom board as compare to working board? Will it affect the functionality of Microcontroller? 

    Please advise.

    Thanks,

    Kiran

  • Scope of Custom board:

    Scope of Working board:

    What do you mean you have a working board? Do you mean the working board is one that you can run the example on? 

    Looking at the clock for the custom board, I think it should be ok. It is 25Mhz. 

  • Hi Charles,

    What do you mean you have a working board?

    Working board means our reference board as mentioned earlies post also.

    Clock signal is distorted or noisy in Custom board that's why i asked.

    Thanks,

    Kiran 

  • Hi Charles,

    Is the function 'EMACSnow_isLinkUp' or 'EMACSnow_emacPoll' in the file 'EMACSnow.c' being checked anywhere? 

    Where i can check this ? Please advice.

    nstead of the line 

    newLinkStatus =
    (EMACPHYRead(EMAC0_BASE, 0, EPHY_BMSR) & EPHY_BMSR_LINKSTAT);

    I need to put 

    newLinkStatus = ioc_PhyReadOperation_ksz8765(0x1E,1,0);

    Where should i write this in existing code?

    Thanks,

    Kiran

  • Hi Charles,

    Can you manually write to the register with value 0x80000000 using HWREG()?

    I did the changes in EMACPHYConfigSet() function  in the file 'emac.c' as below ( to write the value directly to EMAC_PC)

    Yes, you will need to get the link status from your KSZ PHY. The existing code is reading the link status from the integrated PHY that you don't have on the TM4C1292 device.

    I also did the changes in both the functions EMACSnow_sLinkUp() and EMACSnow_emacPoll() in the file EMACSnow.c for checking the Link Status. See below:

    Also, checked the SPI clock signal (MDC) on the 3 boards(TI Launchpad, Reference Working Board and our custom board) Their respective scope captures are below:

    Launchpad

    Reference Board

    Custom Board

    The updated code is below:

     /cfs-file/__key/communityserver-discussions-components-files/908/tcpEcho_5F00_Kiran_5F00_EK_5F00_TM4C1294XL_5F00_TI2_5F00_extPhy-_2800_2_2900_.zip

    The wireshark traffic is not coming in Reference as well as custom board.

    Please guide what can be the cause behind it.

    Best Regards,

    Kiran

  • Also, checked the SPI clock signal (MDC) on the 3 boards(TI Launchpad, Reference Working Board and our custom board) Their respective scope captures are below:

    Launchpad

    Reference Board

    Custom Board

    Can you clarify something?

    - Which SSI do you use to talk to the external PHY? I suppose it is SSI2 based on your code.  Is that correct?

    - You are showing that LaunchPad is talking to the KSZ PHY successfully on SSI2. Is that correct?

    - Please confirm if you can read back what was written to KSZ using launchPad through SSI2 interface?

    - On your capture for reference board and custom board, you are showing the SPICLK, right?

    - Are you running the same code on all three boards? If you have an issue using SSI2 to talk to KSZ on your reference and custom boards then it is likely a hardware issue. Your code has no understanding at all what is the difference between LaunchPad, reference and custom boards. 

     - Why don't you focus on just the SSI2 code. Perhaps you can remove all other code except the SSI2 code. Get the SSI2 to talk to KSZ on all three boards before you add extra code that are Ethernet related. If you can't even set up KSZ on reference and custom boards using SPI interface then you can't continue with the Ethernet application. Your Ethernet code will rely on a working PHY. This is why I asked earlier many times if you can read and write to the external PHY successfully through the SPI interface. 

  • Hi Charles,

    Which SSI do you use to talk to the external PHY? I suppose it is SSI2 based on your code.  Is that correct?

    - You are showing that LaunchPad is talking to the KSZ PHY successfully on SSI2. Is that correct?

    Yes,We're using SSI2 to talk to KSZ

    Launchpad is not connected to KSZ, we don't have all those connections coming out of launchpad for successful interface with KSZ, so we're checking on launchpad alone without connections with KSZ

    Yes I'm showing SPICLK for reference and custom boards

    Yes running the same code on all the boards but the reference code has network running perfectly fine in the existing project so it could be issue in the code

    Thanks,

    Kiran

  • Yes running the same code on all the boards but the reference code has network running perfectly fine in the existing project so it could be issue in the code

    Hi,

      I'm confused. If LaunchPad produces a correct SPICLK waveform, then why wouldn't the same code produce the same for the reference board unless it is a hardware issue? Why do you think it is a code issue? Here we are talking about just the SPI functionality, not the Ethernet functionality yet. Just think about it, SSI2CLK is on PD3 pin. From the software point of view, SSI2 does not know it it running no a LaunchPad or on your reference board. Do you agree?  What is the PD3 connected on your reference board? Why don't you disconnect PD3 from MCU to any device for experiment? Do you see still wrong SSI2CLK? If you don't have anything connected to PD3 on your reference board and you still have a wrong SPI2CLK then we can look at the code again. But I still don't have a clue that the same exact code works on LaunchPad for SSI2CLK but not on your reference board unless it is a hardware issue. 

  • Hi Charles,

    I did SPI validation between TI Launchpad and EV board of KSZ8765 and validated the SCL_MDC and SDA_MDIO. 

    See below:

    Test Setup:

    Schematic of EV board KSZ8765:

    I am unable to understand why i am not getting same signal on reference board and custom. Even i am using the same code.

    Please share your feedback and suggest some steps.

    Thanks,

    Kiran

  • Which pins from the X11 connector on the LaunchPad are you connecting to your KSZ EVM? The picture is too small. Looks like you are using PL0 and PL1. What are these two pins used for? Are you also using PQ0 and PQ2 for SSI3CLK and SSI3TX?

    I am unable to understand why i am not getting same signal on reference board and custom. Even i am using the same code

    What signals are you getting on your reference board then? Are they totally flat or doing something but not correct? Show the waveform. I cannot visually what is 'not getting the same' meant.

    Why don't you create a simple code to first toggle PQ0 and PQ2 first? Will they toggle in your reference and custom boards? This test will check if these two pins are at least wiggling on your board. 

    What is your reference board schematic for the SPI signals? What else are they connecting to? 

  • Hi Charles,

    Thanks for your response!!

    Which pins from the X11 connector on the LaunchPad are you connecting to your KSZ EVM? The picture is too small. Looks like you are using PL0 and PL1. What are these two pins used for? Are you also using PQ0 and PQ2 for SSI3CLK and SSI3TX?

    As mentioned in the code, I am using PD0, PD1, PD2 and PD3. See below:

    What signals are you getting on your reference board then? Are they totally flat or doing something but not correct? Show the waveform. I cannot visually what is 'not getting the same' meant.

    Scope of reference board and custom board should be same as Scope of KSZ EVM.

    Why don't you create a simple code to first toggle PQ0 and PQ2 first? Will they toggle in your reference and custom boards? This test will check if these two pins are at least wiggling on your board. 

    I check the same code again on custom board. See below:

    Scope of KSZ EVM:

    Can you please compare both scope results? I am not able to understand where the things are going wrong. Please advice.

    What is your reference board schematic for the SPI signals? What else are they connecting to? 

    Both custom board and reference board has same schematic for SPI. 

    Please share your feedbacks.

    Thanks,

    Kiran 

  • Scope of reference board and custom board should be same as Scope of KSZ EVM.

    I check the same code again on custom board. See below:

    If this is what you see for the reference board and custom board then there must be something wrong with your boards. 

    How many reference boards and custom boards do you have? Do you see the same waveforms on all the boards you have?

    Why don't you do some experiments?

    - Disconnect PD0,1,3 from KSZ EVM meaning don't put any loads on these pins. Do you see the same waveform? Show scope.

    - Disconnect  PD0,1,3 from KSZ EVM and simply just toggle these three pins in GPIO mode multiple times. Eg. write 0 and then 1 and then 0 and then 1 repeatedly multiple times.  Show scope. 

    - Connect PD0,1,3 to KSZ EVM and toggle these three pins in GPIO mode multiple times. Show scope. 

  • Hi Charles,

    Thanks a lot for support. 

    Our RTOS code was stuck somewhere that's we unable to validated the communication between PHY and microcontroller.

    Thanks,

    Kiran

  • Hi Kiranjit,

      Really glad that you resolved the issue. Can you please elaborate how did you resolve the problem so the community will benefit from your solutions in the future. Can you answer a few questions please?

      - Can MCU communicate with your external PHY now? What was the problem and how did you resolve it? Was the problem hardware related or software related?

      - You were having problem with the SPI signals on your reference and custom boards but LaunchPad seems to be fine running the same code. What was the problem on your reference and custom boards and how did you resolve it? Was the problem hardware related or software related?

  • Hi Charles,

    The code was getting hanged due to introduction of additional I2C bus lines which were not taken into account earlier so probably due to I2C Bus Fault the connection wasn't being established

    Best Regards,

    Kiran