打印

我都快疯了,帮我看看吧,24C02读程序!

[复制链接]
2103|2
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
chqy326|  楼主 | 2007-3-20 10:23 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
pc, ov, FPC, sd
  list             p=16C57
  
  INCLUDE         "d:piclibp16c5x.inc"
;**************************************************
VAR0            EQU        08H
VAR1            EQU        09H


;**************************************************

TRISC_RD        EQU       0BFH     ;read rom data 
TRISC_WR        EQU      03FH    ;write rom data

COMM_WR           EQU       0A0H
COMM_RD               EQU       0A1H

#DEFINE            PC_SDA    PORTC,7
#DEFINE            PC_SCL    PORTC,6
;**************************************************

                ORG        0000H
                GOTO    RESET

ROM_START:            
                MOVLW    TRISC_RD
                TRIS    7
                CALL    NOP_4
                BTFSS    PC_SDA
                GOTO    START_ERR
                MOVLW    TRISC_WR
                TRIS    7
                CALL    NOP_4
                BSF        PC_SDA
                CALL    NOP_4
                BSF        PC_SCL
                CALL    NOP_4
                BCF        PC_SDA
                CALL    NOP_4
                BCF        PC_SCL
                CALL    NOP_4
                
                BTFSC    PC_SDA
                GOTO    ROM_START
                RETLW    00H


RESET:
                CALL    ROM_START


WR_COM:            MOVLW    08H
                MOVWF    VAR0
                MOVLW    COMM_WR
                MOVWF    VAR1                
                CALL    WR_LOOP

                MOVLW    00H
                MOVWF    VAR1
                MOVLW    08H
                MOVWF    VAR0
                CALL    WR_LOOP

                CALL    ROM_START
                MOVLW    08H
                MOVWF    VAR0
                MOVLW    COMM_RD
                MOVWF    VAR1                
                CALL    WR_LOOP
                
                MOVLW    08H
                MOVWF    VAR1

READ1:            MOVLW    TRISC_RD
                TRIS    7
READ2:            BSF        PC_SCL
                RLF        VAR0
                BSF        VAR0,0
                BTFSS    PC_SDA
                BCF        VAR0,0
                BCF        PC_SCL
                DECF    VAR1
                SKPZ
                GOTO    READ2

                MOVLW    TRISC_WR
                TRIS    7
                BSF        PC_SDA
                CALL    NOP_4
                BSF        PC_SCL
                CALL    NOP_4
                BCF        PC_SCL

                CALL    ROM_STOP
                GOTO    $

ROM_STOP:        BCF        PC_SDA
                MOVLW    TRISC_WR
                TRIS    7
                BSF        PC_SCL
                CALL    NOP_4
                BSF        PC_SDA
                CALL    NOP_4
                RETLW    00H

                
START_ERR:        NOP
                NOP
                GOTO    ROM_START    

NOP_4:            RETURN        


WR_LOOP:        
                RLF        VAR1
                MOVLW    TRISC_WR 
                TRIS    7
                BTFSC    STATUS,C
                BSF        PC_SDA
                BTFSS    STATUS,C
                BCF        PC_SDA
                CALL    NOP_4
                BSF        PC_SCL
                CALL    NOP_4
                DECF    VAR0
                SKPZ
                GOTO    WR_LOOP                

                

                BSF        PC_SCL
                CALL    NOP_4
                BCF        PC_SCL
                RETLW    00H
                END


谁有的话,发一个给我吧,
chqy326@163.com
沙发
梦幻空花| | 2007-3-22 15:03 | 只看该作者

为什么总是有人做重复劳动呢?

买本张明峰教主的书不就有现成的了。
至少可以参考比较哪里ERROR了

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

13

主题

24

帖子

0

粉丝