Assembly program for reading and writing 24C02 by single chip microcomputer

Publisher:快乐时刻Latest update time:2012-10-12 Source: 21icKeywords:MCU Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
;简洁的24C02读写汇编程序
;--------------------------------------------
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
Keywords:MCU Reference address:Assembly program for reading and writing 24C02 by single chip microcomputer

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

Automatic metering feeding system based on 8031 ​​single chip microcomputer
1 Introduction In 1985, a candy factory introduced a 116EM production line of metering feeders with microcomputers from SIMON Electronics of Germany for candy production. Due to the long time of introduction, incomplete drawings and materials, and inconvenient maintenance by the foreign party, production wa
[Microcontroller]
Automatic metering feeding system based on 8031 ​​single chip microcomputer
The principle of I2C bus digital potentiometer and its interface design with single chip microcomputer
1 Introduction  ; ; ; With the increasing application of I2C bus, there are more and more types of interface chips and memories compatible with I2C bus. Among them, digital potentiometers have been recognized by a large number of electronic engineering technicians for their convenient adjustment, long service life, li
[Microcontroller]
The principle of I2C bus digital potentiometer and its interface design with single chip microcomputer
Design and implementation of digital barometer based on 51 single chip microcomputer
1. Introduction A barometer is a device that uses a pressure-sensitive element to directly convert the measured air pressure into a current or voltage signal that is easy to detect and transmit, and then processes it through subsequent circuits and displays it in real time. The core component is the air pre
[Microcontroller]
Design and implementation of digital barometer based on 51 single chip microcomputer
51 single chip microcomputer-simple application of timer
1. Details In the previous lecture, we know that the initial value of the "16-bit variable" synthesized by TH0 and TL0 must be at least 0 and cannot be a negative number. So we have to satisfy: 65536-(x/(12/11059200)) =0. The solution is x = 0.071111 seconds = 71.111 milliseconds. That is to say, the longest t
[Microcontroller]
Detailed explanation of idata, xdata, pdata, and data of 51 MCU
data: fixedly refers to the first 128 RAM from 0x00 to 0x7f, which can be directly read and written with acc, with the fastest speed and the smallest generated code. bit: refers to the bit addressable area from 0x20 to 0x2f idata: fixedly refers to the first 256 RAM from 0x00 to 0xff, of which the first 128
[Microcontroller]
Studying transient processes using microcontroller data acquisition system
0 Introduction   In teaching experiments and scientific experiments, we often need to understand the charging voltage, current curve, and discharge voltage curve, record and organize the data, and draw curves. Here, we use the microcontroller data acquisition system to intuitively understand the transition process of
[Microcontroller]
Kitchen timer based on AT89C2051 microcontroller
The device uses 5 minutes as a timing unit and can last up to 1 hour. It uses a 3V battery as the power source and has a buzzer alarm. The power consumption is about 6mA when working (using AT89C2051). It can use a 3V button battery and has an automatic shutdown function. The power consumption is negligible when not
[Microcontroller]
Kitchen timer based on AT89C2051 microcontroller
Selection of main parameters of 8051 compatible microcontrollers
function ImgZoom(Id)//Reset the image size to prevent the table from breaking{ var w = $(Id).width; var m = 715; if(w
[Microcontroller]
Selection of main parameters of 8051 compatible microcontrollers
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号