I'm trying to change default PWM mode to have ~10kHz PWM and 10bit resolution. I write a code, but I don't see nothing change (between my code and default PWM execution). What do I wrong?
// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(22, 24, 26, 28, 30, 32);
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
}
void loop() {
//ustawia dzielnik timera1
TCCR1B = (TCCR1B & 0xF8) | 0x05 ;
/**********************************************************************************/
// Set pwm resolution to mode 7 (10 bit)
/**********************************************************************************/
TCCR1B &= ~(1 << WGM13); // Timer B clear bit 4
TCCR1B |= (1 << WGM12); // set bit 3
TCCR1A |= (1 << WGM11); // Timer A set bit 1
TCCR1A |= (1 << WGM10); // set bit 0
pinMode(13, OUTPUT);
for(;;)
{
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
delay(2500);
analogWrite(13,155);
lcd.setCursor(0,0);
lcd.print("1");
delay(2500);
analogWrite(13,255);
lcd.setCursor(0,0);
lcd.print("2");
delay(2500);
analogWrite(13,1023);
lcd.setCursor(0,0);
lcd.print("3");
lcd.setCursor(0, 1);
// print the number of seconds since reset:
lcd.print(millis()/1000);
}
}