Ðề tài: Pic-thac Mac
View Single Post
Old 31-12-2005, 09:07 PM   #3
mafd_47a
Đệ tử 3 túi
 
Tham gia ngày: Sep 2005
Bài gửi: 54
:
Delay là hàm rất hay được sử dụng trong PIC đê thuận tiện bạn nên dùng hàm delay mẫu sau ( đoạn delay này có trong www.piclist.com )

Dung cho thach anh 4M
PHP Code:
                                  Su dung thanh ghi r3,r2,r4
DELAY255    movlw    0xff        
;delay 255 mS
        
goto    D0
DELAY250    MOVLW    .250
        
GOTO    D0
DELAY100    movlw    d
'100'        ;delay 100mS
        
goto    D0
DELAY50        movlw    d
'50'        ;delay 50mS
        
goto    D0
DELAY20        movlw    d
'20'        ;delay 20mS
        
goto    D0
DELAY10        MOVLW   D
'10'
        
GOTO    D0
DELAY5        movlw    0x05        
;delay 5.000 ms (4 MHz clock)
D0        movwf    R2
D1        movlw    0xC7            
;delay 1mS
        movwf    R3
        movlw    0x01
        movwf    R4
Delay_0
        decfsz    R3
f
        
goto    $+2
        decfsz    R4
f
        
goto    Delay_0

        decfsz    R2    
,f
        
goto    D1
        retlw    0x00 
mafd_47a vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn