Skip to main content
Kostas Anemos
Associate II
December 26, 2017
Question

How do you detect an ethernet cable disconnection?

  • December 26, 2017
  • 9 replies
  • 2977 views
Posted on December 26, 2017 at 11:39

Hi,

Iam using an stm32F746 nucleo board and run the web server example with Netconn RTOS.

Working fine, IP is given and samples html files are loaded.

However the ethernet cable disconnection is not being detected (shouldnt the red led be ON?) and the worst thing is that when the cable is back the software is stuck and needs restart.

Any ideas how to overcome this deadlock?

    This topic has been closed for replies.

    9 replies

    Jan Waclawek
    Visitor II
    December 26, 2017
    Posted on December 26, 2017 at 12:19

    How do you detect an ethernet cable disconnection?

    By polling the PHY regularly.

    JW

    Kostas Anemos
    Associate II
    December 26, 2017
    Posted on December 26, 2017 at 16:40

    Thanks, no doubt that I should poll regurarly

    However seems that after initializations for RTOS, TCP/IP etc the main never executes....It is stated on the code also.

    Why is that?

    int main(void)

    {

    ....

    .....

     osThreadDef(Start, StartThread, osPriorityNormal, 0, configMINIMAL_STACK_SIZE * 5); 

     osThreadCreate (osThread(Start), NULL);

      /* Start scheduler */

      osKernelStart();

     

      /* We should never get here as control is now taken by the scheduler */    <------

      for( ;; ){

       User_notification(&gnetif);         <------this never executes......

      };

    }
    T J
    Senior III
    December 27, 2017
    Posted on December 27, 2017 at 03:46

    I am new to all this stuff too..

    I am having some aberrations on Ethernet as you are; locking up the Ethernet functions until hard reset.

    I started with the cube.

    my code is like yours;

    We never exit the RTOS task sharing program called osStartKernel();

        //Create user task

        task = osCreateTask('run HTTP Tasks', httpTask, NULL, 8*1024, OS_TASK_PRIORITY_NORMAL);

        //Failed to create the task?

        if (task == OS_INVALID_HANDLE)

        {

            // osCreateTask httpTask has failed with OS_INVALID_HANDLE

            // Error();

        }

        //Start the execution of tasks

        osStartKernel();

        // Error: 1st osStartKernel shouldn't ever exit, but it did. We should never get here

        // This function should never get here

        for (;;)

        ;
    T J
    Senior III
    January 1, 2018
    Posted on January 01, 2018 at 05:50

    I have found a problem in my code and fixed it, I am using the LAN8710A

    you should check this in your code;

    stm32f7xx_hal_conf.h

    #define PHY_SR            ((uint16_t)31)        /*!< PHY status register Offset                      */ //this is now corrected

    #define PHY_SR            ((uint16_t)0x31)    /*!< PHY status register Offset                      */ //this is wrong

    finally, I can confirm MII mode and 100MHz operation,

    but only one led stays on, I dont see any flickers.