Hi Goldsmith,
I am sorry i didnt make myself clear it was late night so i was in a hurry to post.
well here are the details
microcontroller used - atmega16 running at 8 mhz internal oscillator
PWM is generated by ATmega16 with the help of timer1 (16 bit timer) with the above said code initalization
motor driver circuit - IC L298N (Dual h bridge with pwm driver)
Power source is a Li poly battery 3 cell config. i also use Lead acid 12v battery also as backup.
motor driver is has 6 pins connected to the microcontroller 4 pins to drive 2 motors direction and 2 pwm pins to pwm driver.
4 pins for drive are connected to PORTA0-3 if 1010 is output then both motor rotate in clockwise. i think you must know the rest. the pwm pins are connected to the PORTD4-5 these pins the Timer1 output pins.
the atmega16 gets the pwm data from the UART which is conencted to the serialport of pc. the pc has a software which sends some packet data with 3 variables. the variables left speed, right speed, and driver direction.
left speed , right speed are values varying from 0-255 which is decoded from the joystick connected to the pc. and drive direction variable(forward, backward, left,right) is also decoded from joystick data .
the aim is drive a robot like a car driven in computer games. all the parts work fine including pwm works fine as per the config. But the problem is my pwm config is wrong as result my speed control practically varies from 0 to maximum speed and to some slower speed. i mean to i get only 3 speeds. instead of 255 speed that i am supposed to get. speed resolution is very poor. and the reason for this problem is only the timer 1 configuration ie the pwm produced is not suitable for my application i think. i also tried various combinations but none of it works properly.
please suggest me what pwm config i must use. i generated the above code with help of codevision avr evaluation. and i use that initialization code in aVR studio.
Thank you