#define TIME_Addr 0xFFFFC0000
#define TIME *(volatile int *) (TIME_Addr+2)//这里需要将地址+2
int getHours()
{
int time = TIME;
return (time>>11) & 0x1F;
}
void SetHours(int hours)
{
int oldtime = TIME;
int newtime = oldtime & ~ (0x1F << 11);//将小时清零,保留分钟与秒钟
newtime |= (hours & 0x1F) << 11;//设置小时时间
TIME = newtime;
}
标签:Addr,int,TIME,基础,嵌入式,time,0x1F,oldtime
From: https://www.cnblogs.com/marryj/p/16997599.html