"Single Chip Microcomputer" Experiment-Experiment 7 8255 Parallel Port Experiment

"Single Chip Microcomputer" Experiment-Experiment 7 8255 Parallel Port Experiment

1. The purpose of the experiment

(1) Further master the use and programming methods of timers
(2) Master the principle and application of seven-segment digital display numbers

2. Experimental content

(1) Design the circuit, use 8255A to realize the switch to control the light-emitting diode on and off. (The parallel port works in mode 0)
(2) Digital stopwatch design. Two digital tubes are required to display the tens and ones of the stopwatch respectively. The display time is 0~59s. When 60s is over, the stopwatch is automatically cleared and starts to display from 0 again.
Insert picture description here
Insert picture description here

Note: The
format used when writing data to the off-chip memory is: XBYTE[address]=data;
Note:
(1) The six-digit digital tubes are all common cathodes, among which LED1~LED6 are the common terminals, which need to be selected for bit selection. Connect to low level; LEDA~LEDG and LED-DP are 8-segment digital tubes. When they are connected to high level, each segment can be lit.
(2) When using, remove the jumper on the right side of the digital tube on the circuit board.

#include<reg51.h>
#include<absacc.h>
#define pa8255 0x7cff
#define pb8255 0x7dff
#define pc8255 0x7eff
#define con8255 0x7fff

char led[]={
    
    0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x3f};

int i=0;
int j=0;
int num=0;

void main(){
    
    
	
	XBYTE[con8255]=0x80;

	TMOD=0x01;
	TH0=0x3c;
	TL0=0xb0;
	TR0=1;
	EA=1;
	ET0=1;
	XBYTE[pa8255]=led[9];
	XBYTE[pb8255]=led[9];
	while(1){
    
    
				while(TF0==0);
				TF0=0;
				TH0=0x3c;
				TL0=0xb0;
	}
}

shuma() interrupt 1{
    
    
	
	num++;
	if(num%20==0){
    
    
		XBYTE[pb8255]=led[j%10];
		j++;
		
		if(num%200==0){
    
    
			XBYTE[pa8255]=led[i%10];
			i++;
		}
	}
}

Guess you like

Origin blog.csdn.net/weixin_44652589/article/details/114904729