DC Motor with PWM

Hello!
Im building a robot and for the movement of the motors ive previously used big-banging pwm, but now i want to use directly the avr regiters but i have a hard time understanding them. Ive found in the playground a library named TimerOne but on my board im using pins 11,3 and 5,6 that are timer2 and timer0. Can someone make me a demo code which generates pwm on a pin and pose comments on every line of code? I don`t understand completely the TCCRA register and the OCRA one.

Can someone make me a demo code which generates pwm on a pin and pose comments on every line of code

Uncompiled, untested.

#define PWMPIN 9  //attach your driver circuit to pin 9 (or3, 5, 6, 10, or 11)
void setup()
{
}

void loop ()
{
  analogWrite (PWMPIN, 127); // roughly 50% (127/255) duty cycle @ 488Hz.
}

I need a demo code using directly the chip registers.

Go look in wiring_analog.c

using directly the chip registers.

Why is this your assignment? If so you are supposed to understand the timers yourself.

this is how i set up the registers
TCCR2A=11110001
TCCR2B=00000010
i`ve set pins 3,11 as output and given 128 to the OCR2A. Where am i doing wrong?

TCCR2A=11110001
TCCR2b=00000010

Where am i doing wrong?

You're writing (in the case of TCCR2A) a very large decimal value to an eight bit register.
In the case of TCCR2b, you're writing ten, when you should be writing two.

Post your code - I can't be bothered playing 20 questions.

void setup()
{
pinMode(11,OUTPUT);
pinMode(3,OUTPUT);
bitWrite(TCCR2A,0,1);
bitWrite(TCCR2A,1,0);
bitWrite(TCCR2A,4,1);
bitWrite(TCCR2A,5,1);
bitWrite(TCCR2A,6,1);
bitWrite(TCCR2A,7,1);
bitWrite(TCCR2B,0,0);
bitWrite(TCCR2B,1,1);
bitWrite(TCCR2B,2,0);
bitWrite(TCCR2B,3,0);
bitWrite(TCCR2B,6,0);
bitWrite(TCCR2B,7,0);
OCR2A=128;
digitalWrite(3,HIGH);
}
void loop()
{
}