PIC单片机模拟I2C接口程序
PIC单片机模拟I2C接口程序
PIC单片机模拟I2C接口程序
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ; File Name: i2c_low.asm
; Author: Alan G. Smith
; Purpose: This code is borrowed from Microchip with all of the fancy
; stuff taken out.
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
InitI2CBusMaster
;************************************************************
TxmtStartBit
bsf Bus_Busy ; on a start condition bus is busy
bsf STATUS, RP0 ; Select page 1
bsf _SDA ; set SDA high
bsf _SCL ; clock is high
call Delay40uSec ; This is necessary for setup time
bcf _SDA ; This gives a falling edge on SDA while clock is high call Delay47uSec ; Necessary for START HOLD time
return
;************************************************************
TxmtStopBit
bsf STATUS, RP0 ; Select page 1
bcf _SCL ; clock is low
bcf _SDA ; set SDA low
bsf _SCL ; clock is pulled up
call Delay40uSec ; Setup time for STOP condition
bsf _SDA ; rising edge on SDA while CLOCK is high
call Delay47uSec ; makes sure a START isn‘t sent immediately after a STOP
bcf Bus_Busy ; The bus isn‘t busy anymore
return
;************************************************************
AbortI2C
call TxmtStopBit ; Send a stop bit
bsf Abort ; set the abort bit
return
;************************************************************
TxmtSlaveAddr
movf SlaveAddr, w ; Move slave address to W
bcf ACK_Error ; reset Acknowledge error bit
movwf I2CData ; move W to I2C Data
bcf I2CData, LSB ; Set for write
你可能喜欢
- 模拟I2C程序
- 工程电路
- MCS-51单片机
- 轻松学习
- SPI总线
- 通信协议接口
- PIC单片机的模拟I2C通信的源程序5页
- 非常实用的模拟I2C程序8页
- C51单片机模拟I2C总线驱动程序设计8页
- STM32_ADS1110的通讯程序IO口模拟I2C5页
- PIC单片机模拟I2C接口程序6页
- 单片机模拟I2C总线汇编程序软件包8页
- 电气工程师_电路基础91页
- 电气工程师_电路的分析方法81页
- 20种工程电路7页
- 工程电路分析答案(英文版)15页
- 工程电路分析答案(英文版)34页
- 工程电路分析答案(英文版)19页
- 第9章 MCS-51单片机系统应用扩展技术44页
- 第3章 MCS-51单片机指令系统88页
- 第8章 MCS-51单片机系统基本扩展技术56页
- 3_MCS-51单片机的汇编语言指令系统101页
- MCS-51单片机指令周期表3页
- 第2章 MCS-51单片机结构78页
- SPI总线协议及SPI时序图详解7页
- SPI总线协议27页
- SPI总线4页
- SPI总线解剖详解7页
- SPI总线协议及SPI时序图详解5页
- IIC和SPI总线5页


