⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 power.c

📁 这是三星公司的arm7 s3c44b0x芯片的所有外设中断程序
💻 C
字号:
//44BTEST : power.c
#include <math.h>
#include "..\inc\44b.h"
#include "..\inc\44blib.h"
#include "..\inc\def.h"
#include "..\inc\power.h"
#include "..\inc\rtc.h"
#define FIN 4000000
static void __irq SLWEint45Int(void);
//void Display_4GrayMonoImage(void);
char slw_exit=0;
void Test_SlowMode(void)
{
	int i;
	unsigned int save_MCON[9];
	unsigned int save_PCONE;
	//the value of memory control register in slow clock(1MHz)
	#if (BDRAMTYPE==DRAM)
	unsigned int MemCon[9]={0,0,0,0,0,0,0x10002,0x10002,0x800000+2033};
	#else //BDRAMTYPE==SDRAM
	unsigned int MemCon[9]={0,0,0,0,0,0,0x18000,0x18000,0x800000+2033};
	#endif
	rEXTINT=0x22222222; //falling edge
	pISR_EINT4567=(U32)SLWEint45Int;
	rINTMSK=~(BIT_GLOBAL|BIT_RTC|BIT_EINT4567);
	save_PCONE=rPCONE;
	rPCONE |= 0x3;//for monitoring FOUT
	Uart_Printf("rPCONE=0x%x\n",rPCONE);
	for(i=0;i<9;i++)
		save_MCON[i]=((unsigned int *)0x01c80004)[i];// *(unsigned int *)(0x01c80004+4*i);
	Uart_Printf("[POWER DOWN MODE TEST]\n");
	Uart_Printf("1)Entering SLOW mode.\n");
	Uart_Printf(" LEDs are flickered by 20ms period at %dMhz.\n",MCLK/1000000);
	Uart_Printf(" But, The frequency,in 1Mhz, is about %dms.\n",MCLK*20/1000000);
	Uart_Printf(" Press EINT 4/5 key to exit SLOW mode\n");
	Uart_TxEmpty(0); //To avoid being crushed the character
	rLOCKTIME=0x190;//0x7d0; //count=t_lock*Fin=2000 (t_lock=200us, Fin=10MHz)
	rCLKSLOW=5|(1<<4)|(1<<5); //PLL off,SLOW mode,SLVAL=5 Fout=Fin/(2*SLVAL)=1MHz
	ChangeMemCon(MemCon);//change memory control register(60MHz-->1MHz)
	while(!slw_exit)
	//now! slow mode:1Mhz, PLL off
	{
		Led_Display(0xf);
		Delay(100);
		Led_Display(0x0);
		Delay(100);
	}
	rINTMSK=BIT_GLOBAL;
	for(i=0;i<9;i++)
		MemCon[i]=save_MCON[i];
	ChangeMemCon(MemCon);//change memory control register(1MHz-->66MHz)
	//test
	// rCLKSLOW=2; //PLL on & Slow off
	// Uart_Printf("BYE!!\n");
	//test
	rCLKSLOW=2|(1<<4)|(0<<5); //PLL on
	for(i=0;i<2048;i++); //wait during PLL lock-time
	rCLKSLOW=2; //exit SLOW mode(disable slow_bit)
	rPCONE=save_PCONE;
	slw_exit=0;
}
void __irq SLWEint45Int(void)
{
	rEXTINPND=0xf; //clear EXTINPND reg.
	rI_ISPC=BIT_EINT4567; //clear pending_bit
	slw_exit=1;
}
void Test_PLL(void)
{
	int i,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(0x48,0x3,0x2);//Fin=10MHz, Fout=40MHz
	ChangePllValue(0x34,0x0,0x1);//Fin=10MHz, Fout=40MHz
	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
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -