2017-2018-1 20155331 Embedded C language

Source: Internet
Author: User
Tags volatile
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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.