联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codinghelp

您当前位置:首页 >> Web作业Web作业

日期:2018-05-26 06:54


Due Wednesday, May 23th, 11:55pm.

Digital Clock

For this assignment, you are required to write code for a digital clock and test it in EdSim51. In

this assignment, you are supposed to use timers, interrupts, keypad, switches and LCD. It

should behave as follows:

The two lines on LCD should display the clock time (HH:MM:SS) on the first line, and date (DDMM-YY)

in the second line.

On power up, it starts from 00:00:00 (01-01-00 for the date) and increments once every second

until 23:59:59 before wrapping around, then it increments the date. If DD reaches the limits, it

wraps around and increments the month and so on. You should take care of the limits of the

day DD based on the month and year. In other words, in February, the number of days is 28 and

so on.

To be order to setup the time or the date, SW0/SW1 (using external interrupt 0/1) can be used

to enter the time/date setting mode, where the time or the date can be setup using the keypad

as following:

1. When you close the switch SW0 (connected to port pin P3.2), it enters the time

setting mode, and the cursor should be shown on the digit being modified in line 1.

a) If [*] key is pressed, it moves the cursor to the left (or wraps around in the same line

when the leftmost position is reached).

b) If [#] key is pressed, it moves the cursor to the right (or wraps around in the same

line when the rightmost position is reached).

c) Typing the digit on the keypad causes the digit under the cursor to be set and the

position to be moved to the right (or wrap around).

d) An invalid input digit at any position should not be accepted (e.g., the hour cannot

be greater than 23; the minutes cannot be greater than 59, etc.).

2. When you close the switch SW1 (connected to port pin P3.3), it enters the date

setting mode, and the cursor should be shown on the digit being modified in line 2.

a) If [*] key is pressed, it moves the cursor to the left (or wraps around in the same line

when the leftmost position is reached).

b) If [#] key is pressed, it moves the cursor to the right (or wraps around in the same

line when the rightmost position is reached).

c) Typing the digit on the keypad causes the digit under the cursor to be set and the

position to be moved to the right (or wrap around).

d) An invalid input digit at any position should not be accepted (e.g., the month cannot

be greater than 12; the day cannot be greater than 31 or 30 or 28 depending on the

shown month, etc.).

Rules and Guidelines:

1. The assignment code must be written in C-language and be fully compiled by either

SDCC or Keil compilers.

2. The Generated hex file should be fully functional on EdSim51.

3. You can start by studying the codes uploaded with this assignment (timer.c and

interrupt.c) to understand the operation of both the timers and the interrupt. You can

also utilize these codes in your assignment.

4. To be able to correctly compile any of your codes using SDCC compiler to work properly

on EdSim51, you need to do the following 3 steps (some of these commands options

may be not necessary as some of them are already the default values, you can refer to

the SDCC manual for more information):

>> sdcc --model-small -mmcs51 --Werror -I. -c FILENAME.c

>> sdcc --model-small -mmcs51 --Werror -I. --iram-size 0x100 --code-size 0x1000 \

--code-loc 0x0000 --stack-loc 0x30 --data-loc 0x30 --out-fmt-ihx FILENAME.rel

>> packihx FILENAME.ihx > FILENAME.hex

5. To be able to easily demonstrate the function of the clock, you can use a delay of

around 100ms for the clock increment instead of the actual 1 second, and adjust the

EdSim51 update Freq to 50000.

Turn In Requirements:

? You are required to turn in 2 files:

- The C code (assignment5.c)

- The generated hex file (assignment5.hex) that is compatible with EdSim51.

? You have to add comments to different parts of your file to describe your coding.


版权所有:留学生编程辅导网 2020 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp