www.pudn.com > hf44b0_TEST.rar > Power.c


#include   
#include "..\inc\44b.h" 
#include "..\inc\44blib.h" 
#include "..\inc\def.h" 
#include "..\inc\power.h" 
#include "..\inc\rtc.h" 
 
#define FIN 4000000 
 
void Test_PLL(void) 
{ 
    int P_div, M_div, S_val, S_div, mck; 
 
    Uart_Printf("[Running change test of M/P/S value]\n"); 
 
    Uart_Printf("Input M vlaue\n"); 
    M_div=Uart_GetIntNum();         
    Uart_Printf("Input P vlaue\n"); 
    P_div=Uart_GetIntNum();     
    Uart_Printf("Input S vlaue\n"); 
    S_div=Uart_GetIntNum(); 
    S_val=pow(2,S_div); 
    mck=(  (M_div+8)*FIN  )/(  (P_div+2)*S_val  ); 
 
    Uart_Printf("MCLK=%d,M=0x%x,P=0x%x,S=0x%x\n",mck,M_div,P_div,S_div); 
    Uart_Printf("Now change PLL value\n"); 
    Uart_TxEmpty(0); 
     
    ChangePllValue(M_div,P_div,S_div); 
    Uart_Init(mck,115200); 
    Uart_Printf("...I'm running in changed MCLK...\nPress any key to return!\n"); 
 
    while(!Uart_GetKey()) 
    { 
	Led_Display(0xf); 
	Delay(1000); 
	Led_Display(0x0); 
	Delay(1000);; 
    } 
 
    ChangePllValue(PLL_M,PLL_P,PLL_S); 
    Uart_Init(0,115200); 
    Uart_Printf("Returned original clock\n"); 
} 
 
 
void Test_HoldMode(void) 
{ 
    Uart_Printf("[HOLD Mode(Normal mode with some stopped blocks)]\n"); 
    Uart_Printf("IIS,IIC,ADC,RTC,UART1,SIO,ZDMA,Timer,LCD are stopped step by step.\n"); 
    Uart_Printf("Check the current cunsumption. Type any key to exit.\n");	 
    //Except GPIO,BDMA,UART0 
    Uart_Printf("IIS off.\n"); 
    rCLKCON=0x3ff8; 
    Uart_Getch(); 
    Uart_Printf("IIC off.\n"); 
    rCLKCON=0x1ff8; 
    Uart_Getch(); 
    Uart_Printf("ADC off.\n"); 
    rADCCON|=0x20; 
    rCLKCON=0x0ff8; 
    Uart_Getch(); 
    Uart_Printf("RTC_control off.\n"); 
    rCLKCON=0x07f8; 
    Uart_Getch(); 
    Uart_Printf("UART1 off.\n"); 
    rCLKCON=0x05f8; 
    Uart_Getch(); 
    Uart_Printf("SIO off.\n"); 
    rCLKCON=0x05d8; 
    Uart_Getch(); 
    Uart_Printf("ZDMA01 off.\n"); 
    rCLKCON=0x05c8; 
    Uart_Getch(); 
    Uart_Printf("TIMER0123 off.\n"); 
    rCLKCON=0x05c0; 
    Uart_Getch(); 
    Uart_Printf("LCD off.\n"); 
    rCLKCON=0x0580; 
    Uart_Getch(); 
 
    Uart_Printf("Return to Normal Mode.\n");	     
    rCLKCON=0x7ff8; //IIS,IIC,ADC,RTC,UART,BRDMA,SIO,ZDMA,Timer,LCD	        
}