How to keep an ENC28J60 Module from Freezing

The ENC28J60 module is good for attaching an Arduino to a LAN or the Internet. The one real problem in doing so is how to keep an ENC28J60 module from freezing. No, not temperature wise ! 🙄  (‘Freezing’ in the sense of locking up, stop working, etc.)

How to keep an ENC28J60 Module from Freezing

ENC28J60 LAN Module

There are many Ethernet  arduino libraries for the ENC28J60 module, however,  I am using the UIPEthernet library from HERE. It is updated from the original Ethernet and follow on UIPEthernet libraries. Documentation on the Ethernet library can be found HERE along with sample code. Note: The UIPEthernet library I am using fully supports all the documented functions from the original library.

There are various ERRATA on the ENC28J60, however, the current versions of the UIPEthernet  library address those issues. This library also supports the STM32F103C8T6. Usually one would think that such ‘lockup’ or ‘freezing’ problems are related to power problems. That problem is not an issue here, it is taken care of by testing with different good power sources and lots of capacitance.

I have the most trouble when I attach an STM32F103C8T6  to the ENC28J60 module.

ARM Cortex M3 STM32F103C8T6

STM32F103C8T6

I seem to have the least problems when I attach an Arduino UNO to it.

Arduino UNO

Arduino UNO

I think that perhaps the extra speed of the STM32F103C8T6 enhances the problem. In the main loop() code, the library function checks on the ENC28J60 and perhaps due to the faster speed of the STM32F103C8T6 there is something going on that affects the ENC28J60.

Another, less know issue, is the need to occasionally call the library function maintain(). If one looks at the documentation, it seems maintain() is only used to renew a DHCP lease. Further research will show that this function call is needed, periodically, if connected to an ENC28J60.  I found that there are fewer ‘freezing’ problems when calling that function in the main loop() code, however, they still occasionally happen.

The best approach to fully solving the issue is to somehow check the status of the ENC28J60 and reset it if it is ‘frozen’. Fortunately, the code for that is available HERE.

This is my sample WEB server code which shows how to keep an ENC28J60 module from freezing by implementing that checking of the ENC28J60.  It also shows the use of the maintain() function and the use of the STM32F103C8T6 watch dog timer. I use the watch dog timer to make sure the mictocontroller running the code to control the ENC28J60 is not somehow locked up (‘frozen’).

Here is the code:

From the ASCII chart in the comments at the top of the code, one can see how the STM32F103C8T6 is wired to the ENC28J60.  One thing to note, is that the RESET of the ENC28J60 is accomplished via its RESET pin rather than by calling the Enc28J60.init() function.  This does a hardware reset and seems to work in all lockup cases.

1 comment

    • Sokkou on March 13, 2018 at 7:31 am
    • Reply

    Thank you for posting this. It is the exact situation I am working on at this moment!

Leave a Reply

Your email address will not be published.