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?

  • 2
    \$\begingroup\$ Why don't you read the data sheets and ask if anything isn't clear? \$\endgroup\$ – Leon Heller Apr 3 '12 at 17:36
  • 4
    \$\begingroup\$ This question is overly broad and can not be reasonably answered in its current form. RTFM, then come back with specific questions about what you didn't understand. We are not here as a substitute for getting information from obvious sources like datasheets. We are here to help you interpret those sources if you find things you don't understand. \$\endgroup\$ – Olin Lathrop Apr 3 '12 at 17:43
  • 1
    \$\begingroup\$ @LeonHeller I guess he's asking for the general difference between mega8 & mega 88 families \$\endgroup\$ – xsari3x Apr 3 '12 at 17:44
  • 3
    \$\begingroup\$ @mina_g It took me only 30 seconds to find the information below on Google, so try harder before you post a question here \$\endgroup\$ – m.Alin Apr 3 '12 at 18:25
  • 2
    \$\begingroup\$ @mina_g You should edit your question, so it would become more clear what you really want to find out \$\endgroup\$ – m.Alin Apr 3 '12 at 19:45

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.
  • \$\begingroup\$ many thanks for your effort. can you recommend me a simulator to deal with, iam using proteus (ISIS), but sometimes i face problems with debugging, despite compiling the code for debug mode. \$\endgroup\$ – mina_g Apr 7 '12 at 14:25
  • \$\begingroup\$ No, I've never used those tools \$\endgroup\$ – Toby Jaffey Apr 7 '12 at 17:36

I wrote a tutorial on how to use the Atmega8 with the enc28J60. Code and details available on my blog, here: http://www.pocketmagic.net/?p=2866


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.