Too , I use the internal crystal and This is my code.
#include <mega16.h>
#include <delay.h>
/*This is a program that flashes the Led
on PORTA.0 every 0.5 seconds*/
main()
{
while(1) /*Loop forever*/
{
PORTA.0=1;
delay_ms(500);
PORTA.0=0;
delay_ms(500);
}
}
I’m not sure what you mean by “battery is 6 or 7 volts”. If you feed that high a voltage to the ATMega16 directly, you will burn it out. If you are using a 7805-family regulator, it’s too low; they need 2v headroom so I would use at least 7 volts.
According to the datasheet of the 7805 (here’s the link for [National’s version) the dropout voltage is 2V. The dropout voltage is the minimum voltage that the input has to be above the output for the regulator to work properly. So for a 5 volt regulator, you must supply at least 5 + 2 or 7 volts.
To reduce heat dissipation, you don’t want to go much above that voltage or may have to provide heatsinking or additional cooling.
I am not familiar with Codevision (I use WinAVR). In WinAVR, you don’t set the fuses in the compiler; you set them with the programmer. Codevision may do this in the IDE.