Timeline for Timer Prescaler problem
Current License: CC BY-SA 3.0
8 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Aug 18, 2017 at 19:35 | history | edited | Edgar Bonet | CC BY-SA 3.0 |
+ clarification.
|
Aug 18, 2017 at 19:32 | comment | added | Edgar Bonet |
@parasbhanot: "But in the datasheet default value of TCCR1B = 0x00". This only applies after a reset. You can rely on this default if you do not use a bootloader nor the Arduino core. The Uno's bootloader does its best to leave every register at its reset state, but it could be unwise to rely on this. And if you use the main() from Arduino core (the "normal" Arduino practice, where you write setup() and loop() but not your own main() ), then many registers will end up in the Arduino's default setting, which is not the same as the hardware-defined default.
|
|
Aug 18, 2017 at 16:57 | comment | added | dannyf | It is because of that, the code proposed to you is very dangerous: it is a bomb that will explode in your face when the conditions are "unexpectedly" right. | |
Aug 18, 2017 at 16:56 | comment | added | dannyf | "But in the datasheet default value of TCCR1B = 0x00. i was expecting the value of CS11 bit to be 0." you should never rely on the default values. and your code should only change the registers / bits to the extent that you need. For example, if you want to change prescalers, change only those registers / bits that are related to the registers / bits that need to be changed. Otherwise, your code may have unexpected impact on other parts of your code. | |
Aug 18, 2017 at 16:54 | comment | added | dannyf | " i have just checked the default value of TCCR1B . it is 0x33 ." that means the code is setting WGM13. With the proposed "beginner" approach, WGM13 is cleared. To the extent that your code uses anything that requires WGM13 being set, like PWM, it wouldn't work. | |
Aug 18, 2017 at 15:34 | vote | accept | paras bhanot | ||
Aug 18, 2017 at 15:33 | comment | added | paras bhanot | Thanks it solved my problem. i have just checked the default value of TCCR1B . it is 0x33 . But in the datasheet default value of TCCR1B = 0x00. i was expecting the value of CS11 bit to be 0. | |
Aug 18, 2017 at 10:57 | history | answered | Edgar Bonet | CC BY-SA 3.0 |