power control
来源:互联网 发布:有哪些污的游戏知乎 编辑:程序博客网 时间:2024/06/05 00:20
//=========================================================================
// 工程名称: E0_Demo2440_Power_Manage
// 组成文件: power_manage.c
// 功能描述: 练习电源管理与时钟功能,改变主频,通过软延时观察LED
// 硬件连接: GPG0~GPG2与3位LED相连
//=========================================================================
#include "2440addr.h"
#include "2440lib.h"
#define MPLLCON (*(volatile unsigned *)0x4c000004)//MPLL Control
#define CLKDIVN (*(volatile unsigned *)0x4c000014)//Clock divider control
#define CAMDIVN(*(volatile unsigned *)0x4c000018)
#define CLKSLOW(*(volatile unsigned *)0x4c000010)
#define CLKCON(*(volatile unsigned *)0x4c00000c)
#define MPLL400MHz 0x5c<<12 | 0x1 <<4 | 0x1<<0
#define CLKDIV2 0x05
#define CONT_NUM 0
void delay(unsigned long dly)
{
for(; dly > 0; dly--);
}
void enable_irq_pend(void)
{
ClearPending(BIT_EINT2);//清除中断标志,防止勿中断
ClearPending(BIT_EINT3);
ClearPending(BIT_EINT4_7);
rEINTPEND |= (0x01<<4);//清子中断标志
EnableIrq(BIT_EINT2); //使能中断
EnableIrq(BIT_EINT3);
EnableIrq(BIT_EINT4_7);
rEINTMASK &= ~(0x01<<4);//使能子中断
}
void disable_irq(void)
{
ClearPending(BIT_EINT2);//清除中断标志,防止勿中断
ClearPending(BIT_EINT3);
ClearPending(BIT_EINT4_7);
rEINTPEND |= (0x01<<4);//清子中断标志
DisableIrq(BIT_EINT2); //使能中断
DisableIrq(BIT_EINT3);
DisableIrq(BIT_EINT4_7);
rEINTMASK |= (0x01<<4);//使能子中断
}
void __irq EintHandler(void)
{
disable_irq();
CLKCON &= ~(1<<2);//通过中断唤醒空闲模式
rGPGDAT |= 0x07;//全亮
}
void gpio_init(void)
{
//初始化 LED IO
rGPGCON &= ~((0x03<<(0<<1))|(0x03<<(1<<1))|(0x03<<(2<<1)));
rGPGCON |= ((0x01<<(0<<1))|(0x01<<(1<<1))|(0x01<<(2<<1)));
rGPGUP &= ~((0x01<<0)|(0x01<<1)|(0x01<<2));
//中断IO初始化
rGPFCON &= ~((0x03<<(0<<1))|(0x03<<(1<<1))|(0x03<<(2<<1))|(0x03<<(3<<1))|(0x03<<(4<<1)));
rGPFCON |= ((0x02<<(2<<1))|(0x02<<(3<<1))|(0x02<<(4<<1)));
rGPFUP &= ~((0x01<<2)|(0x01<<3)|(0x01<<4));//使能上拉
rGPFDAT &= ~((0x01<<0)|(0x01<<1));//低两位输出0
pISR_EINT2 = (unsigned)EintHandler; //初始化中断入口
pISR_EINT3 = (unsigned)EintHandler;
pISR_EINT4_7 = (unsigned)EintHandler;
rEXTINT0 &= ~((0x07<<8)|(0x07<<12)|(0x07<<16));//中断触发方式
rEXTINT0 |= ((0x02<<8)|(0x02<<12)|(0x02<<16));
disable_irq();
}
int Main(void)
{
int cont = CONT_NUM;
int led_value = 1;
memcpy(0x0,(unsigned char *)0x30000000,0x1000); //拷贝程序到0地址
gpio_init();
while(1)
{
cont++;
//无PLL时钟,采用上电初始时钟,较慢
if(16 == cont)//初始化PLL
{
MPLLCON = MPLL400MHz; //MPLL = FCLK = 400M
CLKDIVN = CLKDIV2; //HCLK = FCLK/4 = 100MHZ;PCLK = HCLK/2 = 50MHz
CAMDIVN = 0;
}
if(32 == cont)//进入慢速模式
{
CLKSLOW |= (1<<4)|(1<<5)|(1<<7);
CLKSLOW &= ~0x07;
}
else if(35 == cont)//退出慢速模式
{
CLKSLOW &= ~((1<<4)|(1<<5)|(1<<7));
}
else if(51 == cont)//进入空闲模式 CPU 停止工作
{
cont = 17;
enable_irq_pend();
CLKCON |= (1<<2);
}
rGPGDAT = led_value;
led_value <<=1;
if(led_value == 0x08)
led_value = 1;
delay(150000);
}
}
- power control
- 功率单位(power control)
- STM32L-Power control(PWR)
- STM32L-Power control(PWR)
- STM32L--Power control(PWR)
- 为什么power control 在 LTE系统不再重要
- Android WIDGETS 下的Power control修改的流程
- MS power control levels 终端功率控制等级
- power
- power
- power
- Power
- Power
- power
- HERO Lighting Technology Co., Ltd.—High Power LED Luminaire and LED Control System Manufacturer
- ARM explains good interrupt control for low power processors -Joseph Yiu
- [FAQ16698]Power Control Widget UI界面正常,但是点击图标很久才有反应
- Control
- jquery 请求ie缓存,数据不更新的问题【ajax禁用缓存解决ie数据不更新的问题】
- 浅谈Javascript编码规范
- IBM Ponder This史上最难谜题:给出谜底猜谜面
- DM8168 EVM OMX
- mysql中的limit語句
- power control
- SQL Server数据导入导出工具BCP详解及xp_cmdshell
- 如何使用josn
- 建立连接
- hdu 3788 hdoj 3788
- C#多线程的使用
- 1341. 明明的随机数
- Android 4.0
- 《谁在谋杀中国经济》与程序员