PIC18F4525 and ENC28J60 corruption and resets

General discussion on mikroPascal.
Post Reply
Author
Message
Tod
Posts: 2
Joined: 05 Mar 2009 18:54

PIC18F4525 and ENC28J60 corruption and resets

#1 Post by Tod » 05 Mar 2009 19:09

I have been using the EasyPic5 with a 18F4525 and the ENC28J60 board. Basically I am just running a simple web server on it and just checking for stability before I actually build a prototype. The web server is just a very simple server that is used to set the outputs on PortD to remote reboot PCs.

I've setup the watchdog timer to operate at clk/4096 which seems to work well in case something horrible goes wrong. I also check the return result from the Spi_Ethernet_doPacket function. If I see a 1, I reinitialize SPI and the Ethernet.

I have my browser setup to refresh the page ever second. Now I know in practice this wont be the case, I am just testing stability.

I have MISO on the ENC28J60 board set to 3.3v and all the others set to 5v. The 18F4525 is using an 8MHZ crystal and configured to use HSPLL mode clock for a 32MHZ clock. PortC is setup to use pulldown resistors.

Now the problem:

It will run great for hours at a time. never missing a beat. Then suddenly I will start getting a 1 from the Spi_Ethernet_doPacket function. The code is designed to reset the ENC28J60 (I assumed calling the SPI_Init and related Ethernet calls would do this). It may take 20-30 resets before it will start processing packets reliably again.

All indicators say that the problem lies with the ENC28J60 (or board). Is there a better way to reset the ENC28J60? Is there anything I can do to improve the reliability?

Tod
Posts: 2
Joined: 05 Mar 2009 18:54

#2 Post by Tod » 07 Mar 2009 18:09

After a lot of head scratching and searching the forums, I found something that definetly helped. ZgRob wrote a nice little routine to check the revid of the ENC chip. So with a little modification I found that my RevID was 4. Reading the docs on the Microchip website, I saw my ENC needed a 2.7K bias resistor. Looking on my board, I saw it had 2 x 1K resistors soldered in series.

I replaced those resistors with a 2.7K and reloaded my program. I must say this made a huge difference. Ran multiple tests, pinging from 2 PCs with 800 byte packets, and also hitting the webserver every 2 seconds, I had 2 packets in 20,000 lost. I am farily confident that those lost packets could be attributed to EMI. (the distance between my Pic and the board is easily 15cm or more. )

Also, another tip. If you have a cell phone, make sure it's no where near your project :-)

Thanks ZbBob for that small routine to pull the revID.

Post Reply

Return to “mikroPascal General”