;NAME: Marquee ;AUTOR: ;CONTENT: P1.0~P1.7 connect to light emitting diodes L1~L8
CSEG AT 4000H ; define the starting address, why is it 4000H? ;Memory: Program memory, data memory unified addressing, up to 64K, on-board ROM (16K); RAM ; (32K) for user use, expandable to 48k. The user memory starts at 4000H; 8051 original ; The interrupt entry addresses are all located at the corresponding addresses after offset 4000H LJMP START CSEG AT 4100H START: MOV A, #01H; Light up the first LED first. #01 is chosen because an inverter is added. LOOP: MOV P1, A; Output from P1 port to light emitting diode DELAY500MS: ; Delay 0.5 seconds MOV R7,#0BH DL1: MOV R6,#5CH DL0: MOV R5,#7AH DJNZ R5,$ DJNZ R6,DL0 DJNZ R7,DL1 RL A; Shift left one position and light up the next LED LJMP LOOP END
;NAME: Input and output interface (read whether the switch is closed or open);AUTOR: ;TIME: April 12, 2012 18:22:14;CONTENT: P1.0~P1.7 are connected to buttons K1~K8; SO0~SO7 of 74LS273 are connected to light-emitting diodes L1~L8, and the chip select terminal CSU8\ is connected to CS0 (determined by the entry address selected by the program). PORT EQU 0CFA7H ; chip select address CS0 CSEG AT 4000H ; absolute addressing, same as above LJMP START CSEG AT 4100H START: MOV P1, #0FFH LOOP: MOV A, P1; read the switch status from P1 port MOV DPTR, #PORT MOVX @DPTR, A ; Output from 74LS273 to LED LJMP LOOP ; loop END
Connection method of chip select address 74ls172
74LS273 is an 8-bit data/address latch. This example uses 74LS273 to expand the I/O output port. The value on the data bus is latched in 74LS273 through the chip select signal and the write signal, and the data is output at the port of 74LS273. When the value on the data bus is cancelled, since 74LS273 can latch the signal, the output of 74LS273 remains unchanged until new data is latched.
1. Hardware Design
Create a new Design and add the following components (omit the crystal oscillator and reset circuit):
Component Name | Category | parameter | Remark |
Microprocessor ICs 8051 Family | Microcontroller | ||
LED-YELLOW | Optoelectronics Leds | LED | |
RES | Resistors Generic | 270Ω | resistance |
74LS273 | TTL 74LS Series Flip-Flop & Latches | Bistable Multivibrator & Latch | Latches |
74LS32 | TTL 74LS Series Gates & Inverters | Gates & Inverters | OR Gate |
Use 8 light-emitting diodes to display the output data of the microcontroller. When the output is low, the LED lights up. D0~D7 of 74LS273 are 8-bit data input terminals, connected to the P0 port of the microcontroller, Q0~Q7 are 8-bit data output terminals, CLK is the trigger clock input terminal, and MR is the data clear enable terminal. Use OR gate 74LS32 for address decoding. The input terminals of U3:A are connected to the P2.7 port and WR port of the microcontroller respectively, and the output terminal is connected to the CLK port of 74LS273.
From the truth table of 74LS273, we can see that when MR is low, all Q terminals are 0, otherwise the Q terminal is determined by the D terminal, so MR should be set to a high level. CLK completes the data latch operation at the rising edge, so the output of U3:A must complete a change from low to high. When the write instruction is valid, the output is low. Only when P2.7 is low at the same time can a level change from low to high be achieved when the write instruction is completed. In this way, after the write is completed, the data is locked by 74LS273. It can be seen that the address of 74LS273 should be 0XXX XXXX XXXX XXXX, and we usually set it to 7FFF.
2. Programming
In Keil C51, there are the following memory types:
code is the program memory read by MOVC a, @A+DPTR
data Internal data memory that can be directly accessed
idata Internal data memory accessed by Mov @Rn
bdata Bit addressable internal memory
xdata External data memory accessed by MOVX @DPTR
pdata External data memory accessed by MOVX @Rn
For ease of use, a macro definition is provided in the absacc.h file. For example, the address 0x7fff in this example can be written as XBYTE[0x7fff].
#include "at89x51.h"
#include "absacc.h"
#define A74273 XBYTE[0x7fff]
void main(void)
{
A74273 = 0x2b;
while(1);
}
Note: When the write instruction is valid (it should be WR, high when invalid), the output is low level. Only when P2.7 is low level at the same time, can a level change from low to high be realized when the write instruction is completed. In this way, after the write is completed, the data is locked by 74LS273. It can be seen that the address of 74LS273 should be 0XXX XXXX XXXX XXXX, and we usually set it to 7FFF.
Previous article:Store internal memory in external data storage
Next article:Different data types achieve the same function: Difference in code
- Popular Resources
- Popular amplifiers
- MCU Principles and Interface Technology C51 Programming (Edited by Zhang Yigang)
- 51 single chip microcomputer is very simple - Introduction to Proteus and assembly language and examples
- SN54LVTH540, SN74LVTH540,pdf(3.3-V ABT 16-BIT BUFFERS/DRIVER
- W83116WG pdf Datasheet(V11 Low Power Clock Gen for Intel CK50
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!
- 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
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Millimeter wave sensors bring new intelligence to industrial applications
- Switching Power Supply Interest Group Task 05
- DC/DC power supply circuit (MP2562 chip) chip breakdown failure when powering on
- [Chuanglong TL570x-EVM] Establish startup service - print helloworld
- Chestnut Development Board-TI5708 First Hands-On Exploration
- Review summary: National Technology low-power series, N32L43x is now available for testing
- Some information about mobile power supplies (power banks)
- 【CH579M-R1】+U disk read/write
- 77G millimeter wave antenna design
- Unboxing of Materials - STM32F767 & ESP32