Documente Academic
Documente Profesional
Documente Cultură
CALL Delay
JMP REPEAT
Calculate delay generated by the
program
Delay: MOV R2, #10
Loop1: MOV R1, #200
Loop2: MOV R0, #248
Loop3: DJNZ R0, Loop3
DJNZ R1, Loop2
DJNZ R2, Loop1
RET
END
In the original 8051, one machine cycle lasts 12 oscillator periods.
Therefore, to calculate the machine cycle for the 8051, we take
1/12 of the crystal frequency, then take its inverse,
1/12 x crystal frequency
Time for per Machine cycle=1/f
Design an 8051 based system for interfacing the
Programmable Peripheral interface (PPI) device
8255
• Specifications
Use AT89s8252 (flash MC with In System
Programming(ISP)
Use 12 MHz freq.
Use on chip program memory to storing program
instructions
Use 82C55A PPI device
Allocate the address space 8000 to FFFF to 8255.
initialise port A, port B, port C of 8255 as output
ports in mode 0.
• Hardware
Here we are allocating the address space 8000 to FFFF to 8255
8255 activated when the 15th bit of address line becomes 1, here we use NOT gate
to invert A15 line before applying to CS\ line of 8255.
In this configuration 8255 requires only four address space namely 8000 for Port
A, 8001 for Port B, 8002 for Port C, 8003 for control register, rest of addresses left
unused.
A decoder can be used if we have more than one device is connected.
The octal latch 74LS373 latches lower order address bus which is multiplexed with
data lines.
A 3 to 8 decoder chip, 74LS138, decodes the address bus to generate the CS\
signal for 8255, here we have only one A15 address line to decode, rest of two are
grounded, intention is to assert the CS\ signal of 8255 when A15 is 1.
The i/p condition corresponds to this is 001, decoded for this is 1(y1), you can
replace decoder with NOT gate.
P1.0 is connected to reset pin of 8255
When 8051 is initialised , the port P1.0 automatically generates a reset high signal
for 8255.
Control word
D7 D6 D5 D4 D3 D2 D1 D0
D3
1 0 0 0 0 0 0 0
ORG 0000H
JMP Main
ORG 0003H
RETI
ORG 0013H
RETI
ORG 001BH
RETI
ORG 0023
RETI
Main: CLR P1.0
MOV SP, #08
MOV A, #80 ;LOAD INITIAL CONTROL WORD
MOV DPTR, #8003 ;
MOVX @DPTR, A
JMP $
END
• Design an 8051 based system to
interface 8255 and Connect LEDs to
Port A of 8255. Develop an ALP
program for 0 to 255 counter.
#include< reg52.h> rd=1; //Disabling read
sbit A0=P1^0; wr=0;
sbit A1=P1^1; P2=0x80; //Making all ports output
sbit wr=P3^6; A0=1; //Selecting control register
sbit rd=P3^7; A1=1; //Selecting control register
void delay(unsigned int no) while(1){
{ wr=1;
unsigned int i; delay(10000);
for(i=0;i<=no;i++); A0=0;
} A1=0;
wr=0;
void main(){ P2=0x0F;
P1=0x00; //Port-1 as Output wr=1;
P3=0x00; // Port-3 as Output A0=0;
P2=0x00; // Port-2 as Output A1=0;
delay(10000); delay(10000);
wr=0;
P2=0xF0;
}
}