So my lovely ATtiny10 is capable of processing lots job and at this moment, I have no complaint about its processing speed. But I noticed the default clock speed is 1MHz, internal RC oscillator (8MHz) divided by 8. This is no novelty but I would summarise how to set it to 8MHz and even beyond by OSCCAL register.
.def R_TEMP1, R16
; setting clock divider change enable
LDI R_TEMP1, 0xD8
OUT CCP, R_TEMP1
; selecting internal 8MHz oscillator
LDI R_TEMP1, 0x00
OUT CLKMSR, R_TEMP1
LDI R_TEMP1, 0xD8
OUT CCP, R_TEMP1
; setting clock divider change enable
LDI R_TEMP1, (0<<CLKPS3)+(0<<CLKPS2)+(0<<CLKPS1)+(0<<CLKPS0);
OUT CLKPSR, R_TEMP1; set to 8MHz clock (disable div8)
Just in order to change clock divider from 8 (default) to 1, these processes are required. Putting 0xD8 to CCP register is required each step of CLKMSR and CLKPSR. Just inserting these code, the clock will be set to 8MHz.
More another way to speed bump or up is usage of OSCCAL register. In data sheet, we can see
the clock speed varies from 4 MHz up to around 15 MHz. I was a bit afraid of this modification since it may forget original calibrated number for OSCCAL by touching it but the OSCCAL is restored if our code does not touch OSCCAL.
OSCCAL can be touched as follows.
LDI R_TEMP1, 0xFF
; overclock (from 4MHz(0x00) to 15 MHz(0xFF))
OUT OSCCAL, R_TEMP1
If you need to recover to original calibrated state, just remove this code is enough....Actual operation can be found in the following movie (as an example by LED blinking..) Have fun!
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.