;--------------------------------------------
I2C_SDA EQU P1.6 ; PIN 5
I2C_SCL EQU P1.7 ; PIN 6
;=============================================
I2C_WRITE: ; WRITE 8 BYTES TO EEROM ; INPUT: A - A*8 = EEROM START ADDR
; R0 - RAN START ADDR
; USE: C, A, R0, R6, R7
ACALL I2C_START
ACALL OUT
MOV R6, #8
WR_LP:MOV A, @R0
ACALL OUT
INC R0
DJNZ R6, WR_LP
AJMP I2C_STOP
;==========================================
I2C_READ: ; READ 8 BYTES FROM EEROM ; INPUT: A - A*8 = EEROM START ADDR
; R0 - RAN START ADDR
; USE: C, A, R0, R6, R7
ACALL I2C_START
ACALL OUT
MOV R6, #8
MOV A, #0A1H; #RDCMD
ACALL OUTS
BRDLP:
MOV R7, #8
SETB I2C_SDA
INLP: CLR I2C_SCL
ACALL DELAY6
SETB I2C_SCL
NOP
MOV C, I2C_SDA
RLC A
DJNZ R7, INLP
CLR I2C_SCL
MOV @R0, A
INC R0
DJNZ R6, ACKLP
;;;;----------------------------
I2C_STOP:
CLR I2C_SDA
ACALL DELAY5
SETB I2C_SCL
ACALL DELAY5
SETB I2C_SDA
DELAY6:
NOP
DELAY5:
NOP
RET
;;-----------------------------
I2C_START:
SWAP A
RR A
MOV R6, A
MOV A, #0A0H; #WTCMD
ACALL OUTS
MOV A, R6
RET
;-------------------------------
ACKLP:
CLR I2C_SDA
SETB I2C_SCL
ACALL DELAY5
CLR I2C_SCL
AJMP BRDLP
;=======================
OUTS:
SETB I2C_SDA
SETB I2C_SCL
ACALL DELAY5
CLR I2C_SDA
ACALL DELAY5
CLR I2C_SCL
;========================
OUT:
SETB C
MOV R7, #9
OTLP: RLC A
NOP
MOV I2C_SDA, C
NOP
NOP
SETB I2C_SCL
ACALL DELAY5
CLR I2C_SCL
DJNZ R7, OTLP
RET
;========================
END
Previous article:Design of bank interest rate screen controlled by single chip microcomputer
Next article:MCU and FIFO interface assembly program
Recommended ReadingLatest update time:2024-11-16 18:02
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
- TCP/IP Detailed Volume 1: Protocols (2nd Edition)
- Charging box modified LED light
- Write a Unico tool for STEVAL-MKI109V3
- Human body blowing sensor module
- Parking Robot Embedded Engineer Recruitment
- C++ Computer Vision OpenCV Official Introduction (2017 Edition)
- I built a chassis over the weekend.
- Can you help me design a washing machine controller? It's paid. If you want, please contact me, QQ: 993849120
- 1. GD32L233C-START (unboxing), turn on the lights as usual.
- Implementation of first-order low-pass digital filtering on TI DSP