I am trying to initialize the ENC28J60 on the custom board I received today. But when I try enabling the networkcontroller with networkController.enable(); I get this error:
#### Exception System.InvalidOperationException - CLR_E_INVALID_OPERATION (1) ####
#### GHIElectronics.TinyCLR.Devices.Network.Provider.NetworkControllerApiWrapper::Enable [IP: 0000] ####
#### GHIElectronics.TinyCLR.Devices.Network.NetworkController::Enable [IP: 0007] ####
#### SpeedCAN.Network::InitializeNetwork [IP: 0005] ####
Exception thrown: 'System.InvalidOperationException' in GHIElectronics.TinyCLR.Devices.Network.dll
An unhandled exception of type 'System.InvalidOperationException' occurred in GHIElectronics.TinyCLR.Devices.Network.dll
The schematic of this ENC28J60 is the same as my other designs with this same SC20100S SoC. I have also used this code before. I also checked if my CS, INT and RST pins are properly configured in the code.
What could this be?
Start with a simple project that only had absolutely necessary code, try it on our board and then try on yours. Otherwise we all will be guessing.
This code works on your dev board. The only difference is different CS/INT/RST pins.
There is nothing else done before activating the network
Do you use any interrupt pins anywhere beside for ethernet?
Just started a new, empty project and all I added was the sample code from the docs which I adapted to my specific pins.
The InvalidOperationException still occurs, so I don’t think there is something wrong with the software. I think it’s a hardware problem, which I already thought from the beginning.
Do you at GHI now of something that can trigger this? e.g. did you have this while developing a prototype board?
My schematic is the same as my other boards, so that shouldnt be a problem. I’ll continue probing around the board with the oscilloscope and see if I can figure it out.
Just for sanity check, open an interrupt pin on the same pin you use for INT. Does it raise an exception?
Does not raise an exception
As suspected, it was a hardware problem.
I found this useful topic outlining how to diagnose some issues on the ENC28J60 chip.
After a lot of probing and trying, I discovered one of the traces going to oscillator was broken so the ENC28J60 didnt have a oscillator connected! After fixing this trace, the ENC28J60 worked flawlessly and the exception didnt occur.
Thanks for your help, @Gus_Issa.
I hope others will find this topic useful, it already ranks at the top of google for the error