Electronic – When connecting to Ethernet through ENC28J60, why use ATmega88 instead of ATmega8

atmegaavrenc28j60ethernet

I know the general differences between ATmegaX8 family (ATmega88, ATmega168, and ATmega328) and the ATmegaX family (ATmega8, ATmega16, and ATmega32).

But I'm confused, as when I intended to work on a project to connect the ATmega8 to Ethernet using the ENC28J60 chip, I found that most projects on Internet are using ATmega88 and ATmega168, specially the ones from tuxgraphics.org:

And when I tried to port those source codes to work with ATmega8 instead of ATmega88, I faced a problem with prescaling the frequency many times and some other problems. I failed to reach a .hex code that works on ATmega8.

So why are ATmega88 and its family more suitable to connect to Ethernet than the ATmega8?

Best Answer

so, why is ATMega88 and his family are more suitable for this project "AVR ethernet"?!

The ATMega88 family is well suited to this project because the author has provided an implementation already tested and debugged.

There is nothing inherently different about the ATMega8 which affects this project.

i faced a problem with prescaling the frequency many times, and some other problems .. i failed to reach a .hex code from this project that works on ATMega8

The problem you are facing is one of porting embedded software to a new device. Your problem is that you have underestimated the task and expect it to work without changes.

You need to track down exactly where your code is failing, solve that issue then move on to the next problem. A TCP/IP stack on a microcontroller is not a simple thing.

If I were undertaking this project, I'd break it down like this:

  • Write a program to blink an LED
  • Extend it to send and receive bytes on the UART (this will be invaluable for debugging)
  • Extend it to use the SPI interface, verifying the waveforms with a scope/logic analyser
  • Wire up the ENC28J60 to the SPI interface, not forgetting chip select (I'd leave the interrupt line unconnected for now)
  • Extend the software to read from the chip id/version register and verify the result
  • Extend the software to write to a register and read it back
  • Plug in an ethernet cable, verify that the ethernet link status is changing in the ENC28J60s registers
  • Wire up the ENC28J60 interrupt line to an input on my microcontroller and test (enabling interrupts on link state changes would seem a good test)

Now, I'm confident that my hardware works.

  • Bring the ethernet driver functions (accesses to 16 bit registers, fifo access, etc) into my project and verify them by accessing registers
  • Configure the ENC28J60 for promiscuous mode and dump incoming packets to the UART, verify by comparing with Wireshark/tcpdump
  • Look at how the original author managed time, in particular how regularly they poll the IP stack and the ethernet driver. Implement a main loop to service these routines
  • Pull the rest of the IP stack on top of my driver layer
  • Configure the IP stack for my network (starting with a static IP)
  • Ping it
  • Pull the rest of the application code (web server/etc.) into my project.