Вы находитесь на странице: 1из 4

NATIONAL UNIVERSITY OF SCIENCES AND TECHNOLOGY College of Electrical and Mechanical Engineering Department of Electrical Engineering

EE-219 Microprocessor & Digital Systems 8051 Microcontroller Labs Peripherals Project # 1
Assigned : Syndicate A - Wednesday, 21st March, 2012 Submission Deadline : Syn A Wednesday, 28th March, 2012 (during lab only) Syn B Thursday, 29th March, 2012 (during lab only) Syndicate B Thursday, 22nd March, 2012

Spring 2012 (DE 32-EE)

STOP WATCH USING 8051


This is an individual coding project. Each student is supposed to write his/her own code. Students who made generic boards in groups of 2 can share hardware for demonstration of project. If copying of code is caught, all the students involved will be

penalized. The original author of the code will not be spared. OBJECTIVES: To make a stopwatch using 8051 which counts seconds (0 to 60) and minutes from 0 To incorporate START, STOP and RESET capability in stop watch REFERENCE: Mazidi and McKinlay, The 8051 Microcontroller and Embedded Systems, I. Scott MacKenzie, The 8051 Microcontroller, Chapter # 4: TIMER OPERATION Chapter # 9: TIME PROGRAMMING IN ASSEMBLY AND C 9 minutes

MATERIALS: 8051 assembler and simulator (Keil) 8051 generic board with LEDs connected to ports Switches for giving input (you can connect your generic board with trainers available in Elec II lab and use the switches on those trainers) 3 seven segment displays for showing timer value in minutes and seconds. (1 SSD will be used for showing minutes and 2 SSDs will be used for showing seconds)

DETAILS: Designate one port as input and 3 ports as output. Port selection for input and output is your own choice. Select any 3 pins on the input port for the three functions : START, STOP and RESET. Use push buttons for taking input. When the push button is pressed, the microcontroller should perform the respective function of START, STOP or RESET. (You can observe the stopwatches available in most mobile phones to understand the START, STOP and RESET functionality) Upon reset or power-up, the counter should NOT start counting. It should only start counting when START signal is given to microcontroller. START: START is used to signal the microcontroller to start counting. the timer in any mode that you want. Use timer to count time. (You are not allowed to use delay loops.) You can use Keeping in mind the oscillator clock on which your microcontroller is How you count minutes using timers and extra logic is entirely upto you. STOP: STOP is used to signal the microcontroller to stop counting. should continue to be displayed on the SSDs. The time counted so far shouldn't be erased from the microcontroller. It After pressing STOP, if START is pressed again, the microcontroller should resume counting time from the point where it was stopped. running, calculate the value of timer register to count time in seconds.

RESET: When RESET is pressed, the minutes and seconds counted so far should be reset to zero. If the counter was running at the time RESET was pressed, it should continue to run after being reset to zero. If the counter was stopped at the time RESET was pressed, the time counted should not start counting.

so far will be reset to zero. This should be visible on the SSDs. The timer

Note on Seven Segment Displays:

In an SSD, 8 LEDs are arranged in such a way that digits from 0 to 9 and a dot can be formed by giving appropriate signals to the 8 pins of SSD. These pins are usually SSDs come in two configurations: Common anode (CA) In a common anode SSD, the anodes of all the LEDs are connected to the common pin, which should be given a logic HIGH. The cathodes of these LOW to turn on. LEDs are available as pins of SSD. These individual LED pins are given logic Common cathode (CC) labelled as alphabets 'a' to 'h'. Each pin of SSD turns on one LED. Keep in mind that

In a common cathode SSD, the negative terminals of all LEDs are connected to the common pin, which should be connected to ground. The anodes of all pin is given logic HIGH. PROJECT SUBMISSION: the LEDs are available as pins of SSD. To turn on any LED, its corresponding

Project submission includes 1. Demonstration of counter operation in lab on actuall hardware setup consisting of generic board connected with SSDs 2. Project report (details given on next page)

DETAILS OF PROJECT REPORT: Submit the project report in soft copy form only. The project report should include: Settings of timer Calculations using which you decided the value of timer register (THx and TLx) The complete uvision project folder (including your complete code). is given below: A table showing which leds of SSD are connected to which port pin. Explanation Example table is shown below. In this table you can see that the SSD pins 'a' to 'h' are connected to Port 0 pins 0 to 7 respectively. ('a' is connected with P0.0, 'b' is connected with P0.1, 'h' is connected with P0.7 and so on). For showing any digit on the SSD, you will need to turn on certain LEDs and

turn off the rest.. Fill that information in the following table. As a result, for showing each digital number on the SSD, there will be a unique code which you will send on port 0.

In this table, hypothetical values have been used. These will NOT work in your case. Digit on SSD 0 1 2 3 4 5 6 7 8 9 Hex value Port 0 0x7E 0x12 0x67 0x37 0x1B 0x3D 0x7D 0x16 0x7F 0x3F h P0.7 0 0 0 0 0 0 0 0 0 0 g P0.6 1 0 1 0 0 0 1 0 1 0 f P0.5 1 0 1 1 0 1 1 0 1 1 e P0.4 1 1 0 1 1 1 1 1 1 1 d P0.3 1 0 0 0 1 1 1 0 1 1 c P0.2 1 0 1 1 0 1 1 1 1 1 b P0.1 1 1 1 1 1 0 0 1 1 1 a P0.0 0 0 1 1 1 1 1 0 1 1

Вам также может понравиться