pll_drv.h

Go to the documentation of this file.
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 //_____ I N C L U D E S ____________________________________________________
00019 
00023 //_____ M A C R O S ________________________________________________________
00024 
00028 #define PLLx24          ( (0<<PLLP2) | (0<<PLLP1) | (0<<PLLP0) )
00029 #define PLLx12          ( (0<<PLLP2) | (0<<PLLP1) | (1<<PLLP0) )
00030 #define PLLx08          ( (0<<PLLP2) | (1<<PLLP1) | (0<<PLLP0) )
00031 #define PLLx06          ( (0<<PLLP2) | (1<<PLLP1) | (1<<PLLP0) )
00032 #define PLLx04          ( (1<<PLLP2) | (0<<PLLP1) | (0<<PLLP0) )
00033 #define PLLx03          ( (1<<PLLP2) | (0<<PLLP1) | (1<<PLLP0) )
00034 #define PLLx04_8        ( (1<<PLLP2) | (1<<PLLP1) | (0<<PLLP0) )
00035 #define PLLx02          ( (1<<PLLP2) | (1<<PLLP1) | (1<<PLLP0) )
00036 
00037 
00042 #define Start_pll(clockfactor)                                                  \
00043            (PLLCSR = ( clockfactor  | (1<<PLLE)  ))
00044 
00046 #define Is_pll_ready()       (PLLCSR & (1<<PLOCK) )
00047 
00049 #define Wait_pll_ready()     while (!(PLLCSR & (1<<PLOCK)))
00050 
00052 #define Stop_pll()           (PLLCSR  &= (~(1<<PLLE)) ) 
00053 
00054       // Start the PLL in autofactor mode
00055       // regarding FOSC define
00056 #if   (FOSC==2000)
00059    #define Pll_start_auto()   Start_pll(PLLx24)
00060 #elif (FOSC==4000)
00061    #define Pll_start_auto()   Start_pll(PLLx12)
00062 #elif (FOSC==6000)
00063    #define Pll_start_auto()   Start_pll(PLLx08)
00064 #elif (FOSC==8000)
00067    #define Pll_start_auto()   Start_pll(PLLx06)
00068 #elif (FOSC==12000)
00069    #define Pll_start_auto()   Start_pll(PLLx04)
00070 #elif (FOSC==16000)
00071    #define Pll_start_auto()   Start_pll(PLLx03)
00072 #elif (FOSC==20000)
00073    #define Pll_start_auto()   Start_pll(PLLx04_8)
00074 #elif (FOSC==24000)
00075    #define Pll_start_auto()   Start_pll(PLLx02)
00076 #else
00077    #error   "FOSC should be defined in config.h"
00078 #endif
00079 
00081 
00083 #endif  // PLL_DRV_H
00084 
00085 

Generated on Fri Mar 17 16:02:03 2006 for Atmel by  doxygen 1.4.6-NO