您当前的位置:五五电子网电子知识单片机-工控设备PIC单片机PIC的I2C读写程序 正文
PIC的I2C读写程序

PIC的I2C读写程序

点击数:7488 次   录入时间:03-04 11:36:41   整理:http://www.55dianzi.com   PIC单片机

, TITLE " TWO WIRE/I2C BUS INTERFACE WITH PIC16C5x "
;
LIST P=16C54
;
;*****************************************************************************
;**  Two wire/I2C Bus READ/WRITE Sample Routines of MicroChip's
;**  24Cxx / 85Cxx serial CMOS EEPROM interfacing to a 
;**  PIC16C54 8-bit CMOS single chip microcomputer
;**  Revsied Version 2.0 (4/2/92).
;**
;**     Part use = PIC16C54-XT/JW                                           
;**  Note:  1) All timings are based on a reference Crystal Frequency of 2MHz
;**            which is equivalent to an instruction cycle time of 2 usec.
;**         2) Address and literal values are read in octal unless otherwise
;**            specified.
;
;
;       Program:          I2CBUS.ASM 
;       Revision Date:   
;                         12-12-95      Compatibility with MPASMWIN 1.30
;
;********************************************************************** 
;
;*****************************************************************************
;
;-----------------------------------------------------------------------------
;       Files Assignment
;-----------------------------------------------------------------------------
;
PC      EQU     2               ; Program counter
STAT    EQU     3               ; PIC status byte
FSR     EQU     4               ; File Select Register
RA      EQU     5               ; Port A use to select device address
RB      EQU     6               ; RB7 = SDA, RB6 = SCL
;
STATUS  EQU     08              ; Status register
FLAG    EQU     09              ; Common flag bits register
EEPROM  EQU     0A              ; Bit buffer
ERCODE  EQU     0B              ; Error code (to inDICate bus status)
ADDR    EQU     10              ; Address register
DATAI   EQU     11              ; Stored data input register
DATAO   EQU     12              ; Stored data output register
SLAVE   EQU     13              ; Device address (1010xxx0)
TXBUF   EQU     14              ; TX buffer
RXBUF   EQU     15              ; RX buffer
COUNT   EQU     16              ; Bit counter
;
TIMER0  EQU     18              ; Delay timer0
TIMER1  EQU     19              ; Delay timer1
;
;
;-----------------------------------------------------------------------------
;                     Bit Assignments
;-----------------------------------------------------------------------------
;
; Status bits
;
Z       EQU     2
C       EQU     0
;
; FLAG Bits
;
ERR1    EQU     0               ; Error flag
;
; Instruction Destination Bits
;
F       EQU     1
W       EQU     0
;
; EEPROM Bits
;
DI      EQU     7               ; EEPROM input
DO      EQU     6               ; EEPROM output
;
; I2C Device Bits
;
SDA     EQU     7               ; RB7, data in/out
SCL     EQU     6               ; RB6, serial cLOCk
;
;END FILES/BITS EQUATE
 PAGE
;
;-----------------------------------------------------------------------------
;       Two wire/I2C - CPU communication error status table and subroutine

[1] [2] [3] [4] [5]  下一页


本文关键字:程序  PIC单片机单片机-工控设备 - PIC单片机