我有買microchip的實驗版app013
上面有tc77 不過它卻沒有附程式範例
所以想請問各位大大哪邊可以找到相關的範例(組語)
我找過microchip的網站 不過好像沒有
我試著寫了一個程式 不過我也不知道對不對
因為燈號一直沒變化 該怎麼測試呢?
我是初學者 我的程式如下
謝謝
板上晶片換成16f877 頻率4m
#include <p16f877a.inc>
cblock 0x20
v1,v2,v3,v4,v5,d1,d2,d3
endc
SCS equ 2
SCK equ 1
SIO equ 0
mian:
org 0x00
nop
goto start
start:
org 0x08
banksel TRISB
bsf TRISB,SIO
bcf TRISB,SCK
bcf TRISB,SCS
movf TRISB,f
clrf TRISD
banksel PORTD
clrf PORTD
sensor:
call getdata
movwf PORTD
call delay0
goto sensor
getdata:
bsf PORTB,SCS
bsf PORTB,SCK
bcf PORTB,SCS
call delay
movlw .16
movwf v2
getdata2:
bcf PORTB,SCK
call delay
bsf PORTB,SCK
call delay
bsf STATUS,C
btfss PORTB,SIO
bcf STATUS,C
btfss v2,3
goto n8
rlf v3,f
goto ne
n8:
rlf v5,f
ne:
decfsz v2,f
goto getdata2
bsf PORTB,SCS
retlw v5
delay:
movlw 0x1f
movwf v1
decfsz v1,f
goto $-1
return
delay0:
movlw .1
movwf d1
delay1:
movlw .100
movwf d2
delay2:
movlw .100
movwf d3
delay3:
decfsz d3,f
goto delay3
decfsz d2,f
goto delay2
decfsz d1,f
goto delay1
return
end