AnsweredAssumed Answered

Powering down Ethernet PHY breaks debugging [LPC4088]

Question asked by Brendan McDonnell on Feb 19, 2018
Latest reply on May 29, 2018 by Brendan McDonnell

I need to power down the Ethernet PHY on my Embedded Artists' LPC4088QSB (QuickStart Board), in order to reduce the current draw. I've got some code which seems to do it, and reduces the current draw by (very) roughly 40 mA. But executing this code breaks debugging in a very strange way.


I'm using Mbed OS 5.7.5 in MCUXpresso. I describe further below how to check out and setup the project. But first I detail the issue.


Here is my test code where I demonstrate the issue:

GitHub - bmcdonnell-ionx/eth-dbg-issue 


Is this the right way to power down the PHY? Why is it breaking debugging, and how can I fix it? Details follow.


Problem Description


The problem goes like this:

  • Once phy_write(PHY_REG_BMCR, PHY_BMCR_PWR_DOWN); is called in main.cpp, and then after a reset or power-cycle, and after the code gets past the first for loop in ethernet_init(), you will no longer be able to debug. (i.e. The debugger can't halt the micro anymore, so you can't single step, "run to", or the like.)
    • This issue persists even after reset or power cycle. (Meaning you lose the ability to halt the micro once you pass that place inside ethernet_init().)
  • The only way I've found to fix the issue is as follows:
    • Power cycle the board so that you'll be able to halt the micro again (initially).
    • Erase the micro flash.
    • Power cycle the board again.
    • Now you'll be able to debug normally - until you pass that phy_write() call again.


I tried debugging with the on-board debugger, and with a separate LPC-Link2; results were the same.


The issue presents itself in all three of the commits in the repository now. (If you use the most recent, you may need to change the place to "Stop on startup" in Run -> Debug Configurations... -> Debugger tab.)


Project Setup




At the command prompt:


   mbed import  

   cd eth-dbg-issue

   mbed export -m LPC4088 -i mcuxpresso




   git clone  

   cd eth-dbg-issue

   mbed deploy

   mbed export -m LPC4088 -i mcuxpresso


Then in MCUXpresso, import the project from the filesystem.