2

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?

Trygve Laugstøl
  • 1,410
  • 2
  • 19
  • 28
mina_g
  • 1,355
  • 4
  • 18
  • 21
  • 2
    Why don't you read the data sheets and ask if anything isn't clear? – Leon Heller Apr 03 '12 at 17:36
  • 4
    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. – Olin Lathrop Apr 03 '12 at 17:43
  • 1
    @LeonHeller I guess he's asking for the general difference between mega8 & mega 88 families – xsari3x Apr 03 '12 at 17:44
  • It's in the data sheets! The question should be closed. – Leon Heller Apr 03 '12 at 18:06
  • 3
    @mina_g It took me only 30 seconds to find the information below on Google, so try harder before you post a question here – m.Alin Apr 03 '12 at 18:25
  • 1
    @m.Alin: He doesn't have to, now that you've shown laziness pays off. The point was to send this guy home without a cookie. Unfortunately it only takes one member who doesn't get it to come by before the question is closed. Sigh. – Olin Lathrop Apr 03 '12 at 18:58
  • @OlinLathrop Sorry about that, but I wanted to show the OP that the information really exists out there. – m.Alin Apr 03 '12 at 19:08
  • 1
    @m.Alin thanks .. i did found this, but i was wondering about why this ATMega88 and ATMega168 are used in the ethernet projects using enc28j60 .. while the available ones for me in my country are the atmega8 and atmega16 and atmega32 .. that's why i wanted to know the difference, as by search i didn't find more helpful information .. thanks for your concern – mina_g Apr 03 '12 at 19:22
  • 2
    @mina_g You should edit your question, so it would become more clear what you really want to find out – m.Alin Apr 03 '12 at 19:45
  • 1
    @m.Alin thanks, i have now edited my question, i hope it is more specific now .. sorry for the confusion in the last question – mina_g Apr 03 '12 at 20:07

2 Answers2

12

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.
Toby Jaffey
  • 28,796
  • 19
  • 96
  • 150
  • 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. – mina_g Apr 07 '12 at 14:25
  • No, I've never used those tools – Toby Jaffey Apr 07 '12 at 17:36
6

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

Radu
  • 61
  • 1
  • 1