Hi friends. is it possible to set ATTINY13A clock to 64KHz ? the microcore bootloader have 128KHz but I need 64KHz.
thanks
You should be able to get 64kHz by setting the clock source to the 128kHz internal clock and then setting the prescaler to divide by 2.
Note that the 128kHz oscillator is not very stable or accurate. You might be better off “bending” the 4.8MHz clock down to 4.096MHz and using a 64 prescaler.
westfw:
You should be able to get 64kHz by setting the clock source to the 128kHz internal clock and then setting the prescaler to divide by 2.Note that the 128kHz oscillator is not very stable or accurate. You might be better off “bending” the 4.8MHz clock down to 4.096MHz and using a 64 prescaler.
thanks for reply. can you tell me how can I set the prescaler to divide to 2 ?
yes it's not stable but good for battery saving
i have only changed div when running 4.8mhz but should work with 128khz too
//first include this
#include <avr/pgmspace.h>
and then use this to set div 2
clock_prescale_set(clock_div_2);
Best of luck
swe-dude:
i have only changed div when running 4.8mhz but should work with 128khz too//first include this
#include <avr/pgmspace.h>
and then use this to set div 2
clock_prescale_set(clock_div_2);
Best of luck
thanks for reply. when compiling get error:
Arduino: 1.8.12 (Windows 10), Board: "ATtiny13, 128 KHz internal osc., BOD disabled, Micros enabled"
sketch_apr15f:5:19: error: expected constructor, destructor, or type conversion before '(' token
clock_prescale_set(clock_div_2);
^
exit status 1
expected constructor, destructor, or type conversion before '(' token
sorry i copied the wrong include...
try this:
#include <avr/power.h>
int main(void) {
init();
{
//setup
clock_prescale_set(clock_div_2);
}
while (1)
{
//loop
}
}
swe-dude:
sorry i copied the wrong include...
try this:#include <avr/power.h>
int main(void) {
init();
{
//setup
clock_prescale_set(clock_div_2);
}
while (1)
{
//loop
}
}
thanks a lot it worked. now my tiny13 working with 150uA @ 1.8 volt in active mode.