so, why is ATMega88 and his family are more suitable for this project
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.