00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef PLL_DRV_H
00016 #define PLL_DRV_H
00017
00018
00019
00023
00024
00028 #define PLLx06 ( (0<<PLLP2) | (0<<PLLP1) | (0<<PLLP0) )
00029 #define PLLx03 ( (0<<PLLP2) | (0<<PLLP1) | (1<<PLLP0) )
00030
00031
00036 #define Start_pll(clockfactor) \
00037 (PLLCSR = ( clockfactor | (1<<PLLE) ))
00038
00040 #define Is_pll_ready() (PLLCSR & (1<<PLOCK) )
00041
00043 #define Wait_pll_ready() while (!(PLLCSR & (1<<PLOCK)))
00044
00046 #define Stop_pll() (PLLCSR &= (~(1<<PLLE)) )
00047
00048
00049
00050 #if (FOSC==8000)
00053 #define Pll_start_auto() Start_pll(PLLx06)
00054 #elif (FOSC==16000)
00055 #define Pll_start_auto() Start_pll(PLLx03)
00056 #else
00057 #error "FOSC should be defined in config.h"
00058 #endif
00059
00061
00063 #endif // PLL_DRV_H
00064
00065