• slider image 442
  • slider image 483
  • slider image 484
  • slider image 485
  • slider image 486
  • slider image 487
  • slider image 488
  • slider image 491
:::


Browsing this Thread:   1 Anonymous Users






Re: 請問各位大大 要寫出外部EEPROM 24LCXX 的問題
#3
版主
版主


查看用戶資訊
開watch window,配合單步及設立中斷點來偵錯吧!

發表於: 2006/4/19 17:16
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請問各位大大 要寫出外部EEPROM 24LCXX 的問題
#2
版主
版主


查看用戶資訊
看不出來接收的資料是放在 datai 裡,只知道呼叫了富城式 RX 但不知 RX 副程式的內容為何?

發表於: 2006/4/19 16:51
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


請問各位大大 要寫出外部EEPROM 24LCXX 的問題
#1
新會員
新會員


查看用戶資訊
我是使用MICROCHIP放在網路上的程式
寫入時可以確定是我寫入的DATA
我是用示波器測量出波型
在讀取時我發現讀出的數值也正確
可是我不知道它將讀出的值放在哪裡

由程式的語法得知,他把資料放在datai 的位置
可是我把datai位置的資料叫出來,發現是不對的

想請問是否讀取錯誤

以下是MICROCHIP的程式
PIC10F202 and
;   
the PIC12F675 are supported by this code.
    LIST 
P=12F675       This can be either 10F202 or 12F675

;   GPIO pin descriptions
;   SDA                 bit 0
;   SCL                 bit 1
;
;   
4MHz internal oscillator is being usedthus each instruction
;   cycle 1000 ns
;
;*******************Include 
file**********************************
;   Include 
the appropriate header fileonly one will be selected
  IFDEF __10F202
    
include "p10f202.inc"       This is the include file for a PIC10F202
    __CONFIG  _MCLRE_OFF 
_CP_OFF _WDT_OFF
  
ENDIF

  
IFDEF __12F675
      
include "p12f675.inc"     This is the include file for a PIC12F675
    __CONFIG  _INTRC_OSC_NOCLKOUT 
_WDT_OFF _PWRTE_OFF _MCLRE_OFF _BODEN_OFF _CP_OFF _CPD_OFF
  
ENDIF
  
errorlevel  -302              Suppress message 302 from list file
;*****************************************************************
    
org     0x000               Set the reset vector
    
goto    start               Go to the beginning of main
;*******************Macro definitions*****************************
  
IFDEF __10F202
SETTRIS macro                   
Macro to set TRIS regon PIC10F202
    tris    GPIO                
Copy value to TRIS reg.
    
endm
  
ENDIF

  
IFDEF __12F675
SETTRIS macro                   
Macro to set TRISIO regon PIC12F675
    banksel TRISIO              
Select Bank 1
    movwf   TRISIO              
Copy value to TRISIO reg.
    
banksel GPIO                Select Bank 0
    endm
  
ENDIF
;*******************
Begin Main Program****************************
  include 
"i2c_routines.inc"    This is the I2C code
start
    bsf     GPIO
,SCL            Set SCL high
    movlw   SDA_IN              
Configure SDA to be an input
    SETTRIS                     
Copy value to TRISB register
    
goto    BYTEREAD            Call byte read routine    

;*******************Byte read test subroutine*********************
;           
This routine tests the byte read feature
;           of the serial EEPROM device.  It will read
;           16 bytes of data from the device starting at
;           address 0x501 byte at a time.
;*****************************************************************
BYTEREAD
    movlw   .16
    movwf   bytecount           
Initialize counter to 16 bytes

    movlw   0x50
    movwf   address             
Initialize byte address to 0x50
rxbyte
    call    BSTART              
Generate start bit
                                
Now send the control byte
                                
; for a writeto set address
    movlw   WRITE_ADDR
    movwf   datao               
Copy control byte to buffer
    call    TX                  
Output control byte to device

                                
Nextthe address pointer
    movf    address
,W           Copy address to WREG
    movwf   datao               
Copy address to buffer
    call    TX                  
Output address to device

    call    BSTART              
Generate another start bit
                                
to switch to read mode
    movlw   READ_ADDR
    movwf   datao               
Copy control byte to buffer
    call    TX                  
Output control byte to device

                                
; Finally, read the data byte
    bcf     buffer
,ACKB         Select to send NO ACK bit
    call    RX                  
Input data from device

    call    BSTOP               
Generate stop bit
    incf    address
,F           Increment address pointer
    decfsz  bytecount
,F         Check if finished looping
    
goto    rxbyte              ; Continue looping
    
goto    BYTEREAD

    END


發表於: 2006/4/19 15:27
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部







You can view topic.
不可以 發起新主題
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create PDF files.
You cannot get print page.

[進階搜尋]


:::

Microchip連結

https://www.facebook.com/microchiptechnologytaiwan/
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=13
https://mu.microchip.com/page/tmu
http://elearning.microchip.com.tw/modules/tad_link/index.php?cate_sn=1
https://page.microchip.com/APAC-PrefCenters-TW.html
http://www.microchip.com/
http://www.microchip.com/treelink
http://www.microchipdirect.com/
http://www.microchip.com.cn/newcommunity/index.php?m=Video&a=index&id=103
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=2
http://www.microchip.com.tw/Data_CD/eLearning/index.html
http://www.microchip.com.tw/RTC/RTC_DVD/
https://www.microchip.com/development-tools/
https://www.youtube.com/user/MicrochipTechnology
[ more... ]

教育訓練中心

!開發工具購買
辦法說明 [業界客戶] [教育單位]
----------------------------------
!校園樣品申請
辦法說明 [教師資格] [學生資格]
----------------------------------