音影先锋亚洲天堂网|电影世界尽头的爱完整版播放|国产 熟女 91|高清无码免费观看欧美日韩|韩国一区二区三区黄色录像|美女亚洲加勒比在线|亚洲综合网 开心五月|7x成人在线入口|成人网站免费日韩毛片区|国产黄片?一级?二级?三级

登錄 免費注冊 首頁 | 行業(yè)黑名單 | 幫助
維庫電子市場網(wǎng)
技術(shù)交流 | 電路欣賞 | 工控天地 | 數(shù)字廣電 | 通信技術(shù) | 電源技術(shù) | 測控之家 | EMC技術(shù) | ARM技術(shù) | EDA技術(shù) | PCB技術(shù) | 嵌入式系統(tǒng)
驅(qū)動編程 | 集成電路 | 器件替換 | 模擬技術(shù) | 新手園地 | 單 片 機 | DSP技術(shù) | MCU技術(shù) | IC 設(shè)計 | IC 產(chǎn)業(yè) | CAN-bus/DeviceNe

請教高手看看我的程序

作者:doherty 欄目:單片機
請教高手看看我的程序
說明,這是一個簡單的i2c接口24LC01的程序
但是在icd上運行時,沒有反映,大家?guī)兔纯窗?br>源程序如下:
list    p=16F877
    #include <p16F877.inc>
;
DATA_W        EQU    75h            ;the Write reg
DATA_R        EQU    76h            ;the Read reg
DL1        EQU    77h            ;delay parameter reg
DL2        EQU    78h            ;delay parameter reg
SCL        EQU    3            ;I2C clock LINE
SDA        EQU    4            ;I2C data LINE
ADDRESS        EQU    0            ;the SEEPROM address you want to write in
VALUE        EQU    55h            ;the TEST VALUE you want to write
;
;
    org    000h
    nop
    clrf    PCLATH
    call    Init_I2C
    clrf    DATA_R
    movlw    VALUE
    movwf    DATA_W                ;load the VALUE which to be send to the SEEPROM
    call    Write                ;Write the SEEPROM
    call    Delay10ms            ;wait for the SEEPROM to compelte the update
    call    Read                ;Read-back the VALUE which has just send
    movf    DATA_R,W
    movwf    PORTD                ;DISPLAY the Read-back VALUE
Here    
    goto    Here                ;loop
;
;*****************************************************************************************************8
Write
    call    I2C_Idle            ;check if the bus is free

    banksel    SSPCON2                
    bsf    SSPCON2,SEN        ;generate a start signal

    banksel    PIR1
    btfss    PIR1,SSPIF
    goto    $-1                ;wait for the start signal to be generate
    bcf    PIR1,SSPIF            ;clear the SSPIF flag
    
    movlw    b'10100000'
    banksel    SSPBUF
    movwf    SSPBUF                ;send the DEVICE Address information

    banksel    PIR1
    btfss    PIR1,SSPIF
    goto    $-1                ;wait for the address to be send
    bcf    PIR1,SSPIF            ;clear the SSPIF flag

    movlw    ADDRESS                
    banksel    SSPBUF
    movwf    SSPBUF                ;send the Write Address information

    banksel    PIR1
    btfss    PIR1,SSPIF
    goto    $-1                ;wait for the Write Address to be send
    bcf    PIR1,SSPIF            ;clear the SSPIF flag

    movf    DATA_W,W            
    banksel    SSPBUF
    movwf    SSPBUF                ;send the VALUE to be send to the SEEPROM
        
    banksel    PIR1
    btfss    PIR1,SSPIF
    goto    $-1                ;wait for the VALUE to be send
    bcf    PIR1,SSPIF            ;clear the SSPIF flag

    banksel    SSPCON2
    bsf    SSPCON2,PEN            ;generate the stop signal
    
    banksel    PIR1
    btfss    PIR1,SSPIF        
    goto    $-1                ;wait for the stop signal to be setup
    bcf    PIR1,SSPIF            ;clear the SSPIF flag

    return
;

Read
    call    I2C_Idle
    
    banksel    SSPCON2
    bsf &n
2樓: >>參與討論
羽翔
你的$-1子程序在哪。
程序沒全吧?

3樓: >>參與討論
黃果樹
re
to 羽翔 $-1 當(dāng)前地址減一

to doherty  看程序太累.你到MICROCHIP的網(wǎng)站去找例子吧

4樓: >>參與討論
wesleyyan
去看APPLICATION NOTE
看人家的程序?qū)嵲谑抢,我同意黃果樹的建議,
PIC的APPLICATION NOTE我覺得是做的最好的!
去看就會有收獲:) 

參與討論
昵稱:
討論內(nèi)容:
 
 
相關(guān)帖子
PICSTARTPLUS 編程器如何升級?
PIC單片機菜鳥再求教!
軟件如何處理抗干擾問題
設(shè)計問題請教
那種PIC單片機可記1--99999個TTL脈沖數(shù)
免費注冊為維庫電子開發(fā)網(wǎng)會員,參與電子工程師社區(qū)討論,點此進入


Copyright © 1998-2006 m.58mhw.cn 浙ICP證030469號