2017-2018-1 20155331 Embedded C language
Job Requirements:
In the exercise book to complete the drawings of the work, to seriously look at the topic requirements.
Submit Job
Cheating this semester results clear 0 (have the same, whether it is to others to pass the answer, or find someone else to answer all clear 0)
The reason why you did it wrong:
Oneself in the class did not be able to complete the study task very well.
Correct answer extraction hours:
#define Time_Addr 0xFFFFC0000 //实时钟芯片的IO映像基址是OxFFFFC0000 #define TIME *(volatile int *)(Time_Addr+2) int getHours() { int time=TIME; return (time>>11)&0x1F; }
Set Hours:
#define TIME_Addr 0xFFFFC0000 #define TIME *(volatile int *) (TIME_Addr+2) void SetHours(int hours) { int oldtime = TIME;int newtime = oldtime & ~ (0x1F << 11);//将小时清零,保留分钟与秒钟newtime |= (hours & 0x1F) << 11;//设置小时时间TIME = newtime;}int getHours(){int time = TIME;return (time>>11) & 0x1F;}
2017-2018-1 20155331 Embedded C language