Initializing an ENC28J60

Hi,

I'm currently trying to convert a "NET-IO" board of the German shop "Pollin" into a Serial-to-LAN-adapter and learn something on the way (so "use the ethersex code" is not an option ;-).

I have disassembled the original code (which allows access to 8 digital outputs, 4 digital inputs and 4 analog inputs), have the datasheet and have also d/l-ed the ethersex code but no matter how hard I try, I do not get a single packet received! EPKTCNT stays 0 even if I ping a non-existent IP address (UC, MC, and BC are obviously ENabled!)

I have traced this back and I find that MARST is clear after a SOFT RESET, while it should be set according to the datasheet! So I gather that the MAC unit is not working.

My code looks like this (I hope the function names are self-explanatory):

/* Wait for ESTAT.CLKRDY */ while (!ENC28J60_RCR(REG_ESTAT) & (1

Reply to
Josef Moellers
Loading thread data ...

Yes: "If the address specifies one of the MAC or MII registers, a dummy byte will first be shifted out the SO pin. After the dummy byte, the data will be shifted out MSb first on the SO pin."

So rather than "SPI_send(RCR | MACON2); macon2 = SPI_send(0);" I have to do "SPI_send(RCR | MACON2); SPI_send(0); macon2 = SPI_send(0);"

*then* the MARST bit comes out set!

Why I still do not see packets coming in is my next concern.

No worries, mate!

Josef

Reply to
Josef Moellers

I had inadvertedly set LOOPBK in MACON1, effectively short-circuiting the chip. That will teach me not to use symbolic names ;-)

I finally received some packets and already dumped one. It was great seeing MAC- and IP-address of a host in my network.

Josef

Reply to
Josef Moellers

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.