iam using the atmega16 mcu and i need to control motors but i dont know how to do pwm using atmega16 (registers,functions etc to be used) so i decided to go in a simple way as the admin wrote in some tutorial in which i need to check the delay of my mcu so i made a sample program and loaded in the mcu but instead of blinking it continuously lit on the source code of my program is as follows
# include<avr/io.h>
# include<util/delay.h>
int main(void)
{
unsigned long int i,j;
DDRD=0x40;
while(1)
{
PORTD=0x40;
for(i=0;i<1000;i++)
{
for(j=0;j<65000;j++){}
}
PORTD=0x00;
for(i=0;i<1000;i++)
{
for(j=0;j<65000;j++){}
}
}
return(1);
}
plzz tell me how to rectify this code inorder to know the no of cycles it takes for 1 ms pause so that i can use pwm or u can tell me how i can use pwm the traditional way like wat registers to initialize and wat functions to use(plzz write a small cource code as an example if u decide to say abt pwm)
plzz help me