⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 i2c应用程序2.txt

📁 This code implements the basic functions for an I2C slave device using the SSP module. All I2C funct
💻 TXT
字号:
;****************************************************************************
; 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 <p16f877a.inc>

;
;***************************************
;
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" & "POP" 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -