Question
LAB5 Using the 8051 Counters in polling mode Overview The purpose of this lab is to control and program the MC8051 Counters of the micro-controller
LAB5 Using the 8051 Counters in polling mode
Overview
The purpose of this lab is to control and program the MC8051 Counters of the micro-controller in a given sequence. The program displays current count of Counter 0 on port 1 (P1) and Counter 1 on port 2 (P2). The initial P1 value is F0H and is E1H for port P2. Display update takes place on every counters initiated clock pulse. Counter0 and Counter1 are programmed in mode 2 using the polling mode, no interrupts. The status of TF0 and TF1 are displayed on Port 3 bit 0 (P3.0) and bit 1 (P3.1) respectively.
Steps
First, configure and initialize the required parallel ports; Counter 0 to mode 2, and Counter1 to mode 2. The Main program starts at code memory address 40H, The main program only function is updating P1 & P2 and displaying the two overflow flags on port 3.
Second, in the main program configure the two Counters for Mode 2 with the given initial two counts. Start Counterr0, initiate the external clock pulses on your Keil simulator, and display its accumulated count value on P1. Continue updating port P1 and the status of TF0 on P3.0. Do the same for Counter1 after Counter0 overflows.
Third, configure the debugger display to include the Timer0, Timer1, P1, P2, P3, and the Clock Control windows. Make sure that the Timers windows are configured for no external interrupts and external pin clocks. The clock window can be used to control the CPU clock speed, which can help during the debugging process.
Run the program and monitor all displayed windows. Verify the operation of the two Counters, TF0 & TF1, and the three display ports.
Test and debug your program. Also document and submit your final report along with the well documented list file. You can slow the Counters and Ports update by controlling the MC clock using the clock window in the PREPHERALS selection.
THIS IS WHAT I HAVE SO FAR:
;Programmer: Lawrence Thomas
;Lab 5
ORG 0H ;START THE PROGRAM AT ADDRESS 0H
JMP MAIN
ORG 40H ;START MAIN CODE AT BIT ADDRESS 40H
MAIN:
MOV TMOD,#01100110B ;CONFIGURE COUNTER 1 & 2 IN MODE 2.
MOV TH0, #0F0H ;LOAD TH0 WITH THE INITIAL VALUE F0H
MOV TH1, #0E1H ;LOAD TH1 WITH THE INITIAL VALUE E1H
MOV P1, #0 ;SET PORT 1 UP AS OUTPUT
MOV P2, #0 ;SET PORT 2 UP AS OUTPUT
MOV P3, #0 ;SET PORT 3 UP AS OUTPUT
SETB P3.4 ;MAKE T0 INPUT
SETB P3.5 ;MAKE T1 INPUT
SETB TR0 ;START COUNTER 0
BACK1:
MOV A,TL0 ;COPY COUNT TL0 INTO THE ACCUMLATOR
MOV P1,A ;DISPLAY IT ON PORT 1
JNB TF0,BACK1 ;KEEP LOOPING UNTIL IF TF = 0
SETB P3.0
CLR TR0
CLR TF0
BACK2:
MOV A,TL1 ;COPY COUNT TL0 INTO THE ACCUMLATOR
MOV P2,A ;DISPLAY IT ON PORT 1
JNB TF1,BACK2 ;KEEP LOOPING UNTIL IF TF = 0
SETB P3.1
CLR TR1
CLR TF1
END
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started