J
Josef Moellers
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 << 0))
;
CS_low();
SPI_send(0xff);
CS_high();
_delay_ms(10);
ENC28J60_Bank(2);
b = ENC28J60_RCR(REG_MACON2);
USART_puthex(b); USART_Transmit('\r'); USART_Transmit('\n');
The output is "00", with and without the delay.
When I initialize the remaining registers (ERXST(HL), ...) I can read
them back and they come out as I write them, so my access code should be OK.
I have also hooked up a logic analyzer to CS and the SPI lines and I see
that CS goes low, the 8 clock pulses with SI staying high, then CS goes
back high, so the soft reset really leaves the ATMEGA32.
Any hints?
Thanks in advance,
Josef
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 << 0))
;
CS_low();
SPI_send(0xff);
CS_high();
_delay_ms(10);
ENC28J60_Bank(2);
b = ENC28J60_RCR(REG_MACON2);
USART_puthex(b); USART_Transmit('\r'); USART_Transmit('\n');
The output is "00", with and without the delay.
When I initialize the remaining registers (ERXST(HL), ...) I can read
them back and they come out as I write them, so my access code should be OK.
I have also hooked up a logic analyzer to CS and the SPI lines and I see
that CS goes low, the 8 clock pulses with SI staying high, then CS goes
back high, so the soft reset really leaves the ATMEGA32.
Any hints?
Thanks in advance,
Josef