I've been working with PWM in TIMER0 of my nano board.
So, it's working now and I know how to set OCR0A or OCR0B.
Then, I went to play with Clock Select Bits CS02 CS01 CS00 in TCCR0B.
0, 8 and 64 prescaler configurations worked as I also don't see the effect on the LED fade speed.
But the more problem I get is that 256 and 1024 prescaler don't work at all and the LED goes on all the time.
What is the problem?
The code:
void setup() {
DDRD |= (1<<DDD6);
TCCR0A |= 0xC1;
TCCR0B |= 0x00; // this works for 0x01, 0x02, 0x03 only
}
void loop() {
uint8_t i;
for (i=0;i<256;i++)
{
OCR0A = i;
_delay_ms(1);
}
}
regards,
_delay_*()
are implemented with assembly code loops (which means thatF_CPU
must be set correctly).