Using 8155 in 51 MCU System

Publisher:BlissfulJourneyLatest update time:2021-01-29 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Introduction: The RAM storage space and number of pins of the microcontroller itself are often insufficient. When there is not much need for external expansion, the 8155 chip is the first choice.


An 8155 can provide 256 bytes of RAM, 3 parallel IO interfaces and a 14-bit timer.


The 8155 also has an internal address latch. If you just need to expand the 8155, you can omit the commonly used address latch 74LS373.


Next, write a program that uses the microcontroller's own resources to drive 16 LEDs in a pipeline.


Then, modify it to be driven by 8155.


The assembly language program for using the 51 single-chip microcomputer to drive 16 LED flowing lights is as follows.


;=========================================================


;16 LEDs are connected to P0 and P2.


ORG0000H


START:


MOV30H,#254;On-chip RAM


MOV31H, #255; 30H31H has only one low level


;-------------------------------------


MOVR2,#16;Loop 16 times


LOOP:


MOVP0,30H; output to LED


MOVP2,31H


CALLDLY200MS; Delay


CALLSHIFT_L; shift


DJNZR2, LOOP; loop 16 times


SJMPSTART; Start from the beginning again


;-------------------------------------


SHIFT_L: Shift 16-bit number one bit to the left


MOVA,30H


RLCA; high shift into Cy


MOV30H,A


;---------------


MOVA,31H


RLCA;Cy moves into the low bit, and the high bit moves into Cy


MOV31H,A


;---------------


MOVA,30H


MOVACC.0,C; write Cy (high bit) to low bit


MOV30H,A


;---------------


RIGHT


;-------------------------------------


DLY200MS:; Delay 200ms, error 0us


MOVR6,#197;


DL0:


MOVR7,#250;1


DJNZR7,$;2*250=500


DJNZR7,$;2*256=512


DJNZR6,DL0;(1+500+512+2)*197=199955


MOVR7,#19;1


DJNZR7,$;2*19=38


NOP;1


RIGHT;1+199955+1+38+1+2=199998


;-------------------------------------


END


;========================================================


The circuit corresponding to the above program is too simple, so the illustration is not shown here. Readers can draw the diagram themselves.


When an 8155 is added to the circuit, the circuit can be connected as follows:

In the figure, since P2.7 and P2.0 are used to connect to CS and IO/M, the interface address and memory address of 8155 are:


;I/O address:


COMMANDEQU7F00H


PORTAEQU7F01H


PORTBEQU7F02H


PORTCEQU7F03H


TIMER_LEQU7F04H


TIMER_HEQU7F05H


;MEM address:


;7E00H~7EFFH


Therefore, the previous running light program needs to be modified as follows:


;=========================================================


;51 single chip microcomputer water lamp (16 lamps)


;P0,P2 external 16 LEDs - changed to PA,PB


;30H,31H on-chip RAM - changed to off-chip


ORG0000H


START:


MOVDPTR,#COMMAND


MOVA,#00000011B;PA mode 0 output, PB mode 0 output


MOVX@DPTR,A


INCDPTR;Go to PA


MOVA,#00110011B; Test common anode 7-segment digital tube


MOVX@DPTR,A


INCDPTR; Go to PB


MOVA,#00001111B


MOVX@DPTR,A


;MOV30H,#254;--Change to 7E30H


;MOV31H,#255;--Change to 7E31H


MOVDPTR,#7E30H


MOVA,#254


MOVX@DPTR,A


MOVDPTR,#7E31H;RAM7E30H7E31H


There is only one low level in MOVA,#255;


MOVX@DPTR,A


;-------------------------------------


MOVR2,#16;Loop 16 times


LOOP:


;MOVP0,30H; output to LED


;MOVP2,31H


MOVDPTR,#7E30H


MOVXA,@DPTR


MOVDPTR,#PORTA


MOVX@DPTR,A


MOVDPTR,#7E31H


MOVXA,@DPTR


MOVDPTR,#PORTB


MOVX@DPTR,A


CALLDLY200MS; Delay


CALLSHIFT_L; shift


DJNZR2, LOOP; loop 16 times


SJMPSTART; Start from the beginning again


;-------------------------------------


SHIFT_L: Shift 16-bit number one bit to the left


;MOVA,30H


MOVDPTR,#7E30H


MOVXA,@DPTR


RLCA; high shift into Cy


;MOV30H,A


MOVX@DPTR,A


;---------------


;MOVA,31H


MOVDPTR,#7E31H


MOVXA,@DPTR


RLCA;Cy moves into the low bit, and the high bit moves into Cy


;MOV31H,A


MOVX@DPTR,A


;---------------


;MOVA,30H


MOVDPTR,#7E30H


MOVXA,@DPTR


MOVACC.0,C; write Cy (high bit) to low bit


;MOV30H,A


MOVX@DPTR,A


;---------------


RIGHT


;-------------------------------------


DLY200MS:; Delay 200ms, error 0us


MOVR6,#197;


DL0:


MOVR7,#250;1


DJNZR7,$;2*250=500


DJNZR7,$;2*256=512


DJNZR6,DL0;(1+500+512+2)*197=199955


MOVR7,#19;1


DJNZR7,$;2*19=38


NOP;1


RIGHT;1+199955+1+38+1+2=199998


;-------------------------------------


END


;=========================================================


In the original program, all instructions for reading and writing 30H and 31H are changed to reading and writing external RAM.


All instructions for outputting P0 and P2 are changed to outputting to off-chip PA and PB.


Written in this way, the length of the program has nearly doubled. Haha, there is no other way, I have to do this.


After modification, you can use the resources of 8155 to conduct the running light experiment.


The effect shown is that only one LED is glowing, which is relatively simple, so I won’t illustrate it here.


Reference address:Using 8155 in 51 MCU System

Previous article:How to implement custom download in operation in STC microcontroller
Next article:51 MCU DIY PLC Programming

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号