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.
Previous article:How to implement custom download in operation in STC microcontroller
Next article:51 MCU DIY PLC Programming
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- Rambus Launches Industry's First HBM 4 Controller IP: What Are the Technical Details Behind It?
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- [Full cash back for orders, capped at 300 yuan] MPS Mall Power Design Products Recommendation, Huge Discount Experience Season!
- [CH549 Review] Part 4 Low-Level Driver Software Review - Touch Button Driver
- 【AT32F421 Review】+ DHT22 Temperature and Humidity Detection
- Crazy Shell AI open source drone GPIO (remote control indicator light control)
- Where can I get an evaluation board for Toshiba's rice-sized Bluetooth module?
- [Atria AT32WB415 Series Bluetooth BLE 5.0 MCU] PWM breathing light
- 30V8A stepper motor driver, step angle 1.8 degrees, required accuracy 0.1 degrees, should I choose chip or H bridge
- Circuit diagram of leakage alarm automatic control socket
- How to detect mosquitoes using ultrasonic sensor circuit
- 2021 National College Student Electronics Competition Released