at90pwm81-16se ATMEL Corporation, at90pwm81-16se Datasheet - Page 37

no-image

at90pwm81-16se

Manufacturer Part Number
at90pwm81-16se
Description
8-bit Avr Microcontroller With 8k Bytes In- System Programmable Flash
Manufacturer
ATMEL Corporation
Datasheet
7734M–AVR–03/10
can stop the previous clock source. It will be better to run this sequence once the interrupts disabled. The
user (code) has the responsibility of the clock switching sequence.
Here is a “light” C-code that describes such a sequence of commands.
Warning:
In the AT90PWM81, only one among the external clock sources can be enabled at a given time and it is
not possible to switch from external clock to external oscillator as both sources share one pin.
Also, it is not possible to switch the synchronization source of the PLL when the sytem clock is PLL/4.
See
As they are two CSEL adresses to access the Calibrated internal RC oscillator 8.0/1.0 MHz, the change
between the two frequencies is not allowed by the clock switching features. The CKRC81 bit in MCUCR
register must be used for this purpose.
C Code Example
Table 6-1 on page 28
void ClockSwiching (unsigned char clk-number, unsigned char sut) {
#define CLOCK-RECOVER
#define CLOCK-ENABLE
#define CLOCK-SWITCH
#define CLOCK-DISABLE
unsigned char previous-clk, temp;
}
// Disable interrupts
// “Recover System Clock Source” command
// “Enable Clock Source” command
// Wait for clock availability
// “Clock Source Switching” command
// Wait for effective switching
// “Disable Clock Source” command
// Re-enable interrupts
asm ("cli"); temp = SREG;
CLKCSR = 1 << CLKCCE;
CLKCSR = CLOCK-RECOVER;
previous-clk = CLKSELR & 0x0F;
CLKSELR = ((sut << 4 ) & 0x30) | (clk-number & 0x0F);
CLKCSR = 1 << CLKCCE;
CLKCSR = CLOCK-ENABLE;
while ((CLKCSR & (1 << CLKRDY)) == 0);
CLKCSR = 1 << CLKCCE;
CLKCSR = CLOCK-SWITCH;
while (1){
}
CLKSELR = previous-clk;
CLKCSR = 1 << CLKCCE;
CLKCSR = CLOCK-DISABLE;
SREG = temp; asm ("sei");
CLKCSR = 1 << CLKCCE;
CLKCSR = CLOCK-RECOVER;
if ((CLKSELR & 0x0F) == (clk-number & 0x0F)) break;
to identify these cases.
0x05
0x02
0x04
0x01
AT90PWM81
37

Related parts for at90pwm81-16se