attiny167-esxz ATMEL Corporation, attiny167-esxz Datasheet - Page 35

no-image

attiny167-esxz

Manufacturer Part Number
attiny167-esxz
Description
8-bit Avr 8-bit Microcontroller Microcontroller With 16k Bytes In-system Programmable Flash And Lin Controller
Manufacturer
ATMEL Corporation
Datasheet
7728A–AUTO–07/08
Here is a “light” C-code of a clock switching function using automatic clock monitoring.
C Code Example
void ClockSwiching (unsigned char clk
#define CLOCK
#define CLOCK
#define CLOCK
#define CLOCK
#define WD
#define WD
unsigned char previous
}
}
// Disable interrupts
// Save the current system clock source
// Enable the new clock source
// Wait for clock validity
// Switch clock source
// Wait for effective switching
// Shut down unneeded clock source
// Re-enable interrupts
// Enable the watchdog in automatic reload mode
temp = SREG; asm ("cli");
CLKCSR = 1 << CLKCCE;
CLKCSR = CLOCK
previous
CLKSELR = ((sut << 4 ) & 0x30) | (clk
CLKCSR = 1 << CLKCCE;
CLKCSR = CLOCK
while ((CLKCSR & (1 << CLKRDY)) == 0);
CLKCSR = 1 << CLKCCE;
CLKCSR = CLOCK
while (1){
}
if (previous_clk != (clk_number & 0x0F)) {
CLKSELR = previous
CLKCSR = 1 << CLKCCE;
CLKCSR = CLOCK
SREG = temp;
WDTCSR = (1 << WDCE) | (1 << WDE);
WDTCSR = (1 << WDE ) | WD
CLKCSR = 1 << CLKCCE;
CLKCSR = WD
CLKCSR = 1 << CLKCCE;
CLKCSR = CLOCK
if ((CLKSELR & 0x0F) == (clk
_
_
ARL
2048CYCLES
_
clk = CLKSELR & 0x0F;
_
_
_
_
RECOVER
ENABLE
SWITCH
DISABLE
_
_
ENABLE
ARL
_
_
_
_
RECOVER;
ENABLE;
SWITCH;
DISABLE;
_
ENABLE;
_
_
RECOVER;
_
clk;
clk, temp;
0x05
0x02
0x04
0x01
0x06
0x07
_
2048CYCLES;
_
number & 0x0F)) break;
_
number, unsigned char sut) {
_
number & 0x0F);
ATtiny167
35

Related parts for attiny167-esxz