Skip to main content
Topic: The webbserver stops, Problems with ENC28J60?? (Read 22919 times) previous topic - next topic

Re: The webbserver stops, Problems with ENC28J60??

Reply #45
How about adding some NOPs? Perhaps it needs to settle down before it can accept a new setting?

Just thinking along (don't have experience with the used pic)..

Re: The webbserver stops, Problems with ENC28J60??

Reply #46
It's not about finding a fix.  Either commenting out the CKE = 1 line or adding the SMP = 1 line fixes the instability.  It's about understanding *why* this fixes the instability.  The original settings in the ENC28J60 file should be correct, according to the timing diagrams in the data sheets.

Re: The webbserver stops, Problems with ENC28J60??

Reply #47
I started a thread at the Microchip forum:

    http://www.microchip.com/forums/tm.aspx?m=486674

no conclusive answer was given.  Out of desperation I also opened a ticket at support.microchip.com.  It has the number 1-174397.  That was the answer I got:

"""
The CKE and SMP bits control the PICs interpretation of SPI clock phase and the SPI input sample timing. The idea CKE and SMP settings assuming no external delays. Once you have delay, other settings may work better. This usually happens at higher data rates, since the high and low time of the SPI signals are very quick. If you have skew between the data and clock signals due to TTL drivers or passive components the other settings may work better. Cases where the 'wrong settings' work better than the typical correct settings are uncommon.

I would recommend scoping the signals. The timing needs to meet the mode the PIC is in as well as the timing for the ENC28J60. This is the best way to verify timing.

If you have a lot of over or undershoot that may be causing general reception issues. If that is the case you may need to make circuit modifications for reliable operation.
"""

Well...

Ian, I think we will not ge any further without having someone looking at the timing with an oscilloscope.

Re: The webbserver stops, Problems with ENC28J60??

Reply #48
Thanks for the investigation and update. 

I'm still working on borrowing some scope time from a friend or university. I should really have one myself. I'll keep you updated.
Got a question? Please ask in the forum for the fastest answers.

Re: The webbserver stops, Problems with ENC28J60??

Reply #49
I too had instability problem with my web platform.

I noticed that on page 82 of ENC28J60 Rev C datasheet, the minimum CS hold time, Tcsh is 210 ns, which is rather long.

I added some delay (using 9 Nop()s) in the WriteReg() function (ENC28J60.c) to ensusure this hold time is met.

[font=courier:]static void WriteReg(BYTE Address, BYTE Data)
{
    ...
    Dummy = ENC_SSPBUF;   
    Nop();Nop();Nop();Nop();Nop();Nop();Nop();Nop();Nop();  //Ensure min CS hold time is satisfied
    ENC_CS_IO = 1;
}[/font:]
   
The mod seems to work. I didn't change the original SPI clock timing which I thought is already correct.

 

Re: The webbserver stops, Problems with ENC28J60??

Reply #50
Thanks for the update Stephen - there have been a number of ways people have gotten the ENC28J60 to stop hanging, this seems the simplest yet. Markus had it working even when overclocked by using a technically 'incorrect' SPI setting.
Got a question? Please ask in the forum for the fastest answers.