《防爆磁力启动器原理与维修》 * 技术教程集合 * PLC入门教程 电工基础教程
论坛使用帮助 PLC视频教程下载 升级VIP用户的方法成伟新帖

PIC单片机的I2C应用程序2

[复制链接]
查看2891 | 回复0 | 2011-9-7 23:00:19 | 显示全部楼层 |阅读模式
<





; This source code provides a demonstration of the MSSP peripheral
; on the PIC16F87x MCU.
;*********** The subroutines for EEPROM *****************
;
; EE_Random_Read ; EEPROM Random address Read from EEPROM
; EE_SEQU_Read ; EEPROM Sequential Read form EEPROM
; EE_Ack_Check ; Polling current status of EEPROM
; EE_Page_Write ; Page Write function for EEPROM
; EE_Byte_Write ; Write a byte to EEPROM with address setting
;
;*********** The subroutines for I2C *****************
;
; Init_I2C_Master ; Initial I2C Module for Master Mode , 7-bit address
; StartI2C ; Send a START Condition !!
; StopI2C ; Send s STOP Condition
; RstartI2C ; Send a Repeat Start conditional to I2C
; Non_Ack ; Send a Non-acknowledge signal to I2C
; An_Ack ; Send a acknowledge signal to I2C
; Sebd_Byte ; Send a byte to I2C bus
; RecI2C ; Enable Read a byte form slave device
; I2C_Done : Wait the I2C completed the currect process
;
;*****************************************************************************************
list p=16f877a
#include
;
;***************************************
;
CBLOCK 0x20
I2C_Ctrl
I2C_Addr
I2C_Data
I2C_Page_Length
D_Count
ENDC
cblock 0x40
I2C_Page_Buffer:8
I2C_SEQU_Buffer:8
endc
;
;***************************************
w_temp EQU 0x72
status_temp EQU 0x73
pclath_temp EQU 0x74
;
;***************************************
;
EEPROM_CMD equ 0xA0 ; Device adress of Slave Point
EE_Read equ .1
EE_Write equ .0
;
#define SCL PORTC,3 ; I2C SCL pin
#define SDA PORTC,4 ; I2C SDA pin
;
;********************************************
; Locates startup code @ the reset vector
;********************************************
Reset_Addr
org 0x00
nop
goto Main_Init
;
org 0x04
goto ISR
;
;***************************************************************************
;**** The Start Address of ISR is 0x004
;**** \"PUSH\"
热帖推荐
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则