Author Topic: fnCheckEthLinkState and KSZ8081  (Read 6704 times)

Offline kingston

  • Newbie
  • *
  • Posts: 26
    • View Profile
fnCheckEthLinkState and KSZ8081
« on: June 09, 2015, 08:53:41 AM »
Hey Mark,

we had some problem with our network activity led and the KSZ8081 PHY. The LINK_UP was detected just fine but LINK_DOWN was never received.
In the function fnCheckEthLinkState(void) in kinetis.c you mask the register value with PHY_LINK_STATE_CHANGE which is defined as:
Code: [Select]
#define PHY_LINK_STATE_CHANGE  (PHY_LINK_UP_INT | PHY_LINK_DOWN_INT)when using the KSZ8081.
This breaks the following else case:
Code: [Select]
else if (PHY_LINK_DOWN_INT & usInterrupt) {        // {27} add else so that the LINK UP event is not overwritten to UNKNOWNIf the define is changed to
Code: [Select]
#define PHY_LINK_STATE_CHANGE PHY_LINK_UP_INTthe LINK_DOWN event is detected.
   
Regards

Paul

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: fnCheckEthLinkState and KSZ8081
« Reply #1 on: June 10, 2015, 01:15:28 AM »
Hi Paul

Which board are you using and are you using a PHY interrupt or polling?

The KSZ8081 is used with the FRDM-K64F in pollling mode (since there is no interrupt line connected) and I don't have problems detecting link up and link down.

The reason for this is the following code in the if (PHY_LINK_STATE_CHANGE & usInterrupt) { block:

    #if (defined _DP83849I || defined _KSZ8081RNA) && defined INTERRUPT_TASK_PHY // {52}{84}
        default:                                                         // link has gone down
            int_phy_message[MSG_INTERRUPT_EVENT] = LAN_LINK_DOWN;
            break;
    #endif


where the change {84} was added on
02.06.2014 Add _KSZ8081RNA status register settings                  {84}

Prior to this I agree that the link down case would never be caught when #define PHY_LINK_STATE_CHANGE  (PHY_LINK_UP_INT | PHY_LINK_DOWN_INT) is used.

In any case, I think that your modification is also correct - it is used by boards that have the KS8041, whereby probably both methods lead to the same result.

Best regards

Mark


Offline kingston

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: fnCheckEthLinkState and KSZ8081
« Reply #2 on: June 10, 2015, 10:04:09 AM »
Hi Mark,

we are using a custom board based on the K60 V2 and the KSZ8081 in interrupt mode.
The project is based on uTasker 1.4.7 so the fix is already included but it never worked for us prior to the change of the define.

Thanks for your response!

Kind regards

Paul

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: fnCheckEthLinkState and KSZ8081
« Reply #3 on: June 10, 2015, 11:52:23 PM »
Paul

OK. I have tested both methods on the FRDM-K64F in polling mode and they are both good.
Therefore, since you have confirmed that the link down is operational on the K60 in interrupt mode using #define PHY_LINK_STATE_CHANGE PHY_LINK_UP_INT, I have left this setting as general solution.

Regards

Mark