适用于PIC系列,汇编、内存紧张的朋友用
SDA EQU 5 ;'OC'
SCL EQU 4
ACKF EQU 0
EE_VCC EQU 2
EE_WP EQU 1 ;'H' DISABLE 'L'ENABLE
DO EQU 7
TX_BUF EQU 0X30
BUF_IN EQU 0X31
EEPROM EQU 0X32
BIT_COUNT EQU 0X33
byte_count equ 0x34
ACK EQU 0X35
rom_buf1 equ 0x36
rom_buf2 equ 0x37
rom_buf3 equ 0x38
rom_buf4 equ 0x39
rom_buf5 equ 0x3a
;**********************启动信号***************************************
BSTART:
BSF PORTA,SDA
NOP
NOP
NOP
NOP
NOP
NOP
BSF PORTA,SCL
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
BCF PORTA,SDA
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
BCF PORTA,SCL
NOP
NOP
RETLW 0
;***********************停止信号********************************
BSTOP:
BCF PORTA,SDA
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
BSF PORTA,SCL
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
BSF PORTA,SDA
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
BCF PORTA,SCL
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
RETLW 0
;**********************发送N_ACK**************************
SEND_ACK:
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
BCF PORTA,SDA
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
BSF PORTA,SCL
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
BCF PORTA,SCL
NOP
NOP
NOP
NOP
NOP
NOP
RETLW 0
;**********************发送N_ACK**************************
READ_ACK:
BSF TRISA,SDA ;SET SDA IN
CLRF ACK
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
BSF PORTA,SCL
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
BTFSS PORTA,SDA
INCF ACK,F
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
BCF PORTA,SCL
BCF TRISA,SDA ;SET SDA OUT
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
RETLW ACK;0
;**********************发送一个字节**************************
BYTEOUT:
MOVLW D'8'
MOVWF BIT_COUNT
TXLP
nop
nop
CALL BITOUT
RLF TX_BUF,F
DECFSZ BIT_COUNT,F
GOTO TXLP
CALL READ_ACK
;CALL BITIN ;ACK
;BTFSC EEPROM,DI
; BSF PORTC,ACKF
RETLW 0
;************************接收一个字节*****************************
BYTEIN:
BSF TRISA,SDA ;SET SDA IN
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
CLRF BUF_IN
MOVLW D'8'
上一篇:PIC单片机USB MSC的应用:用 MMC/SD 卡作为储存设备进行读写
下一篇:PIC单片机 读/写 MMC/SD 卡的简单小程序
推荐阅读最新更新时间:2024-11-09 22:57
设计资源 培训 开发板 精华推荐
- 直流和步进电机驱动IC —— TC78H621FNG
- OP113FSZ 5V Only 18 位立体声运算放大器 DAC 的典型应用
- A8498 宽输入电压 3A 降压稳压器的典型应用
- 51单片机简易心形灯
- 【课程设计】液位控制系统
- TLP7820 隔离放大器的应用电路(电压检测)
- 使用 Analog Devices 的 LTC1261CS8-4.5 的参考设计
- 使用 Microchip Technology 的 MIC2225-4KYMT TR 的参考设计
- LTC2992CMS 双向 30V 至 300V 高侧功率监视器的典型应用
- AM1G-4805DZ ±5V 1 瓦 DC/DC 转换器的典型应用