亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? 16f73 與 pic16c74a 通訊.txt

?? PIC單片機C源代碼集合
?? TXT
字號:

  
;*******************************************************************
; IR_FILTER.ASM
; sample AD channel x and 篩選出 頻率of puck and goals
; 16f73用SPI 方式通過 SSP 組件與 PIC16C74A 聯系
;*******************************************************************
;歌林電子制作實驗室www.nbglin.com 
;TEL:0574-88464538 email:nbpic@126.com
;
; portc<1> determines if the puck value值在 LEDs顯示
; portc<2> determines which (if the puck is not shown) of the two goal
; values is shown on the LEDs, and switches the order they are sent to
; the 74A host.
; 第一最后發送 (the defensive goal) is shown on the LEDs (if the
; the puck is not)
; portc<0> determines if the low or high byte is shown on the LEDs
;*******************************************************************
;

LIST w=1, n=0 
LIST p=16C73A 
__CONFIG b'11111110110010'
#INCLUDE "P16C73A.INC" 

w_temp equ 0x20 
goal2_b equ 0x30 ; beginning of goal2 bins
goal2_e equ 0x5F ; end of 24 two bytegoal2 bins
goal1_b equ 0x60 ; beginning of goal1 bins
goal1_e equ 0x7F ; end of 16 two byte goal1 bins
goal1_out_l equ goal1_b ; output from algorithm
goal1_out_h equ goal1_b+1; output from algorithm
goal2_out_l equ goal2_b ; output from algorithm
goal2_out_h equ goal2_b+1; output from algorithm

; Bank 1

CBLOCK 0xA1
puck_acc_l, puck_acc_h ; puck accumulator for past ad values
goal1_acc_l, goal1_acc_h; goal1 accumulator for past ad values
goal2_acc_l, goal2_acc_h; goal2 accumulator for past ad values
dc_acc_l, dc_acc_h ; accumulator for all past ad values
puck_ptr ; pointer to puck bins
goal1_ptr ; pointer to goal1 bins
goal2_ptr ; pointer to goal2 bins
past_ptr ; poiter to last of the saved AD values
fpuck_past_ptr ; pointer to first saved AD val used for puck
fgoal1_past_ptr ; pointer to first saved AD val used for goal1
fgoal2_past_ptr ; pointer to first saved AD val used for goal2
ENDC

pastval_b equ 0xB0 ; beginning of past AD values
pastval_e equ 0xBF ; end of 16 saved past AD values
puck_b equ 0xC0 ; beginning of puck bins
puck_e equ 0xFF ; end of the 32 two byte puck bins 
puck_out_l equ puck_b ; output from algorithm
puck_out_h equ puck_b+1; output from algorithm

; misc constants
ad_cycle equ d'30' ; 30 us sampling period
num_ad equ d'96' ; number of samples in one run
spi_delay equ 30 ; extra delay between sent bytes in us
;
;
; ***************************** Reset vector

ORG 0x0000
reset clrf INTCON ; disable interrupts
goto start

; ***************************** Interrupt vector

ORG 0x0004
interrupt
goto reset ; interrupts should be disabled

;****************************** Initialization code

ORG 0x0020
start
BANKSEL PORTB
clrf PORTB
clrf PORTC
BANKSEL TRISB
movlw 0x00
movwf TRISB
movlw b'00010111'
movwf TRISC
init_ad ; set up AD module on all channels
; channel 0 active
init_timer1_ad ad_cycle ; set up AD sampling every ad_cycle us 
init_spi ; set up SPI communication
init_timer0 ; set up timer0 as timer w/o prescaler

;****************************** Main routine 

main 
BANKSEL ad_cnt
clrf ad_cnt
clear_regs goal1_b, goal1_e
clear_regs goal2_b, goal2_e
BANKSEL puck_acc_l
clrf puck_acc_l
clrf puck_acc_h
clrf goal1_acc_l
clrf goal1_acc_h
clrf goal2_acc_l
clrf goal2_acc_h
clrf dc_acc_l
clrf dc_acc_h
clear_regs pastval_b, pastval_e
clear_regs puck_b, puck_e
movlw puck_b - 2
movwf puck_ptr
movlw goal1_b - 2
movwf goal1_ptr
movlw goal2_b - 2
movwf goal2_ptr
movlw pastval_b - 1
movwf past_ptr
movlw pastval_b - d'16'
movwf fpuck_past_ptr
movlw pastval_b - d'8'
movwf fgoal1_past_ptr
movlw pastval_b - d'12'
movwf fgoal2_past_ptr
BANKSEL ADCON0 
wait_on btfss ADCON0, GO ; skip if a conversion is in progress
goto wait_on ; wait until conversion is started
goto wait_ad

check_ad
btfss ADCON0, GO ; skip if a conversion is in progress
call panic ; conversion already finished, we're
; too slow, give up!!!
wait_ad btfsc ADCON0, GO ; skip if the conversion is finished
goto wait_ad ; wait until conversion is finished

; update pointer to last AD value
BANKSEL past_ptr
incf past_ptr, f
movlw (pastval_e + 1) & 0xFF
subwf past_ptr, w
btfss STATUS, Z
goto cont1 ; ptr is not yet pastval_e+1 
movlw pastval_b ; wrap!
movwf past_ptr
cont1 movf past_ptr, w
movwf FSR
BANKSEL ADRES
movf ADRES, w
movwf INDF ; puts most recent AD value in list of past values 
; add most recent AD value to accumulators
BANKSEL puck_acc_l ; We're now in bank1 and will remain so until after handle_target
add_w_to_16 puck_acc_l ; add value pointed at by past_ptr (and FSR) to puck_acc
add_w_to_16 goal1_acc_l ; add value pointed at by past_ptr to goal1_acc
add_w_to_16 goal2_acc_l
add_w_to_16 dc_acc_l

; macro invoked once for each target (goal1, goal2, and puck)
handle_target MACRO f_past_pt, targ_ptr, targ_b, targ_e, acc_l
LOCAL cont1, cont2, cont3
; update pointer to first AD value in target accumulator
incf f_past_ptr, f
movlw (pastval_e + 1) & 0xFF
subwf f_past_ptr, w
btfss STATUS, Z
goto cont1 ; ptr is not yet pastval_e+1 
movlw pastval_b ; wrap!
movwf f_past_ptr
cont1 ; ...and to next bin
incf targ_ptr, f 
incf targ_ptr, f 
movlw (targ_e + 1) & 0xFF 
subwf targ_ptr, w
btfss STATUS, Z 
goto cont2 
movlw targ_b ; targ_ptr=targ_e+1 ==> wrap!
movwf targ_ptr
cont2 ; add target accumulator value to next bin
movf targ_ptr, w
movwf FSR
add_16_to_ind16 acc_l ; add contents of acc to bin pointed at by targ_ptr
; remove the oldest AD value in the target accumulator if it is old enough
movlw pastval_b
subwf f_past_ptr, w
btfss STATUS, C
goto cont3 ; C is clear ==> pastval_b is greater than ptr 
movf f_past_ptr, w ; ptr is legal ==> it points at an old enough value
movwf FSR
sub_ind_fr_16 acc_l 
cont3
ENDM

handle_goal1
handle_target fgoal1_past_ptr, goal1_ptr, goal1_b, goal1_e, goal1_acc_l
handle_goal2
handle_target fgoal2_past_ptr, goal2_ptr, goal2_b, goal2_e, goal2_acc_l
handle_puck
handle_target fpuck_past_ptr, puck_ptr, puck_b, puck_e, puck_acc_l

; loop back
BANKSEL ad_cnt
incf ad_cnt, f
movlw num_ad
subwf ad_cnt, w
btfss STATUS, C
goto check_ad ; C is clear ==> ad_cnt has not reached num_ad

; ca 141 instr ==> ca 28,2 us

BANKSEL fgoal1_past_ptr ; bank 1 as required by the handle_target macro 
sublw 6
btfsc STATUS, C
goto handle_goal1 ; C is set ==> 6 >= ad_cnt-num_ad 
; ad_cnt-num_ad >= 7 ==> goal1 accumulator is zero
addlw 4 ; 4 + 6-(ad_cnt-num_ad) 
btfsc STATUS, C
goto handle_goal2 ; C is set ==> 10-(ad_cnt-num_ad) >= 0 
; ad_cnt-num_ad >= 11 ==> goal1 accumulator is zero
addlw 4 ; 4 + 10-(ad_cnt-num_ad) 
btfsc STATUS, C
goto handle_puck ; C is set ==> 14-(ad_cnt-num_ad) >= 0 
; ad_cnt-num_ad >= 15 ==> all target accumulators are zero; we're finished

;now find the bins with the greatest accumulated values
find_greatest16 goal1_b, goal1_e
find_greatest16 goal2_b, goal2_e
find_greatest16 puck_b, puck_e

BANKSEL dc_acc_l
bcf STATUS, C
rrf dc_acc_h, f
rrf dc_acc_l, f ; dc_acc = dc_acc/2

movlw dc_acc_l
movwf FSR
BANKSEL goal1_out_l
sub_ind16_fr_16 goal1_out_l
btfsc STATUS, C
goto after_sub_goal1
clrf goal1_out_l ; result negative (it should not) ==> set to zero
clrf goal1_out_h
after_sub_goal1
sub_ind16_fr_16 goal2_out_l
btfsc STATUS, C
goto after_sub_goal2
clrf goal2_out_l ; result negative (it should not) ==> set to zero
clrf goal2_out_h
after_sub_goal2
BANKSEL puck_out_l
sub_ind16_fr_16 puck_out_l
btfsc STATUS, C
goto after_sub_puck
clrf puck_out_l ; result negative (it should not) ==> set to zero
clrf puck_out_h
after_sub_puck

; put one of the results (high or low byte) on portb
; portc <1><2> equal to...
; 00:puck, 01:puck, 10:goal2, 11:goal2
BANKSEL PORTC
movlw goal2_out_l
movwf FSR
movlw goal1_out_l
btfsc PORTC, 2
movwf FSR
movlw puck_out_l
btfss PORTC, 1 
movwf FSR 
btfss PORTC, 0
incf FSR, f ; access high byte of result if portc <0> is clear
movf INDF, w
movwf PORTB

; send data to host PIC

VARIABLE i=1
WHILE i <=2 ; send 0xFF twice
BANKSEL SSPBUF
movf SSPBUF, w ; fetch received value
movlw 0xFF ; start by sending two 0xFF's
movwf SSPBUF ; transmit
wait_bf ; wait for transmission to complete
wait_us spi_delay ; wait spi_delay us
i++ 
ENDW
i=1
WHILE i <= 4 ; send 4 data words
; load address
IF i==1
movlw puck_out_l
ENDIF
IF i==2
movlw goal2_out_l
BANKSEL PORTC
btfsc PORTC, 2 ; portc<2> switrchrd the order... 
movlw goal1_out_l
ENDIF
IF i==3
movlw goal1_out_l
BANKSEL PORTC
btfsc PORTC, 2 ; ...of goal1 and goal2 
movlw goal2_out_l
ENDIF
IF i==4
movlw dc_acc_l
ENDIF
movwf FSR ; point at low byte
BANKSEL SSPBUF
movf SSPBUF, w ; fetch received value
movf INDF, w ; fetch low byte
movwf SSPBUF ; transmit 
wait_bf ; wait for transmission to complete
wait_us spi_delay ; wait spi_delay us
movf SSPBUF, w ; fetch received value
; also bank 0
movwf ad_source ; store it this time (should be received every time)
incf FSR, f ; point at high byte
movf INDF, w ; fetch high byte
movwf SSPBUF ; transmit 
wait_bf ; wait for transmission to complete
wait_us spi_delay ; wait spi_delay us
i++ 
ENDW

; ensure enough time to set AD input channel
BANKSEL T1CON
bcf T1CON, TMR1ON ; stop timer1
BANKSEL TMR1H 
clrf TMR1H 
clrf TMR1L ; clear it
BANKSEL ADCON0 
bcf ADCON0, GO ; stop any AD conversion
BANKSEL ad_source
movf ad_source, w ; load received source pin number
sublw 4 
btfss STATUS, C 
goto after_adsel ; C is clear ==> 4 < ad_source ; not valid
; copy 3 lsb's to CHS2:CHS0
BANKSEL ADCON0
bcf ADCON0, CHS0 
bcf ADCON0, CHS1
bcf ADCON0, CHS2
btfsc ad_source, 0 ; same bank (0)
bsf ADCON0, CHS0 
btfsc ad_source, 1 
bsf ADCON0, CHS1
btfsc ad_source, 2 
bsf ADCON0, CHS2
after_adsel

; start timer1 again 
BANKSEL T1CON
bsf T1CON, TMR1ON 

; begin again
goto main


panic movlw 0xFF ; hang with PORTB LEDs half lit
BANKSEL PORTB
movwf PORTB
nop
clrf PORTB
goto panic


END

 

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产视频一区二区在线观看| 天天综合色天天综合色h| 一卡二卡三卡日韩欧美| 久久99精品国产麻豆不卡| 一本久道中文字幕精品亚洲嫩| 91精品国产综合久久香蕉的特点 | 成人国产免费视频| 欧美一区二区免费观在线| 亚洲视频网在线直播| 国产乱码精品一区二区三区五月婷 | 91亚洲午夜精品久久久久久| 欧美成人伊人久久综合网| 一区二区三区欧美在线观看| 国产福利视频一区二区三区| 日韩精品一区二区三区中文精品| 亚洲一区二区三区在线播放| 成人av在线一区二区| 久久久久久久久久美女| 美女看a上一区| 在线成人高清不卡| 亚洲国产成人高清精品| 色系网站成人免费| 亚洲三级小视频| 欧美一区日韩一区| 亚洲v中文字幕| 色综合久久久久综合体桃花网| 国产欧美精品一区二区三区四区| 精品写真视频在线观看| 日韩欧美亚洲一区二区| 久久99精品久久久久久| 欧美精品一区二区三区高清aⅴ| 日韩成人精品在线| 日韩欧美一区二区视频| 免费不卡在线观看| 欧美成人video| 国产九色精品成人porny| www久久久久| 成人免费高清在线观看| 国产精品久久久久久福利一牛影视| 成人午夜av电影| 亚洲精品少妇30p| 欧美性大战久久久久久久蜜臀| 亚洲综合在线免费观看| 欧美日韩二区三区| 精油按摩中文字幕久久| 久久久久久麻豆| 99精品国产视频| 一区二区三区欧美视频| 91精品国产色综合久久ai换脸| 黄色精品一二区| 综合激情网...| 国产精品久99| 色综合久久中文综合久久97| 亚洲va韩国va欧美va| 日韩精品一区二区三区四区视频| 国产精品一区专区| 亚洲女与黑人做爰| 欧美伦理视频网站| 国产精品一区二区久激情瑜伽| 欧美国产精品中文字幕| 欧洲视频一区二区| 精品一区二区三区在线观看| 国产精品美女久久久久久久久久久 | 亚洲男女一区二区三区| 欧美人妖巨大在线| 国产激情视频一区二区三区欧美| ...中文天堂在线一区| 91精品国产色综合久久不卡电影| 国产福利一区二区三区视频在线| 亚洲精品大片www| 日韩精品一区二区三区中文精品| 99久久伊人精品| 狠狠色综合日日| 亚洲综合在线视频| 欧美国产精品中文字幕| 欧美一区二区视频在线观看2022| 成人一区在线看| 久久综合综合久久综合| 一区二区三区欧美日| 欧美国产日韩在线观看| 日韩一级片在线播放| 97精品久久久午夜一区二区三区 | 国产视频视频一区| 欧美日韩激情一区二区| av激情综合网| 国产精品一区一区三区| 性欧美疯狂xxxxbbbb| 国产精品色在线| 日韩一卡二卡三卡| 欧美私模裸体表演在线观看| 东方欧美亚洲色图在线| 国内精品伊人久久久久av一坑| 亚洲一级电影视频| 亚洲国产精品二十页| 欧美va亚洲va| 69堂精品视频| 欧美日韩国产乱码电影| 色综合色狠狠综合色| 成人免费av在线| 成人一级视频在线观看| 国产精品乡下勾搭老头1| 日本最新不卡在线| 午夜精品久久久久久久99水蜜桃 | 麻豆一区二区99久久久久| 午夜精品福利一区二区三区av| 亚洲欧美经典视频| 亚洲色图另类专区| 亚洲欧美一区二区三区久本道91| 中文字幕乱码一区二区免费| 久久天堂av综合合色蜜桃网| 精品久久久久一区| 国产亚洲自拍一区| 国产亚洲午夜高清国产拍精品| 欧美精品一区二区三区蜜臀| 精品免费99久久| 久久亚区不卡日本| 日本一区二区三区国色天香| 国产精品三级视频| 亚洲欧美一区二区三区孕妇| 亚洲综合丝袜美腿| 亚洲午夜羞羞片| 亚洲国产一区二区三区| 午夜视频在线观看一区二区| 亚洲第四色夜色| 日本亚洲天堂网| 国产精品一区二区三区网站| 粉嫩av亚洲一区二区图片| 91麻豆成人久久精品二区三区| 色综合久久久久| 欧美一区二区网站| 国产欧美日韩精品a在线观看| 国产精品福利一区| 亚洲国产精品综合小说图片区| 亚洲成人激情自拍| 麻豆精品一区二区av白丝在线| 激情欧美日韩一区二区| 白白色 亚洲乱淫| 欧美久久久久久久久| 欧美videossexotv100| 国产精品女上位| 亚洲成人激情自拍| 国精品**一区二区三区在线蜜桃| 成人av免费在线播放| 在线精品国精品国产尤物884a| 91精品久久久久久久91蜜桃 | 亚洲自拍欧美精品| 精品在线你懂的| 91尤物视频在线观看| 欧美三级电影精品| 国产日本欧洲亚洲| 亚洲高清免费视频| 国产99久久久国产精品潘金 | 久久精品欧美一区二区三区不卡| 亚洲人吸女人奶水| 久88久久88久久久| 一本色道**综合亚洲精品蜜桃冫| 91精品麻豆日日躁夜夜躁| 国产精品超碰97尤物18| 天天爽夜夜爽夜夜爽精品视频| 国产成a人无v码亚洲福利| 欧美日韩高清在线| 中文字幕亚洲一区二区va在线| 日本欧美在线观看| 在线精品视频小说1| 欧美韩日一区二区三区四区| 免费视频一区二区| 91免费精品国自产拍在线不卡| 欧美变态凌虐bdsm| 五月激情丁香一区二区三区| 99久久精品国产精品久久| 久久亚洲一区二区三区四区| 日韩精品一卡二卡三卡四卡无卡| 一本大道久久a久久综合| 久久久久久久久久久久久久久99 | 日韩欧美一级在线播放| 一二三四区精品视频| 懂色av噜噜一区二区三区av| 欧美成人性福生活免费看| 一级日本不卡的影视| 色香色香欲天天天影视综合网| 国产欧美中文在线| 九九视频精品免费| 日韩写真欧美这视频| 亚洲电影激情视频网站| 在线观看免费一区| 亚洲欧美日韩精品久久久久| 成人污视频在线观看| 久久久99精品久久| 国产精品伊人色| 久久久另类综合| 国产一区二区调教| 26uuuu精品一区二区| 国产麻豆精品一区二区| 久久一夜天堂av一区二区三区| 久久电影网电视剧免费观看| 日韩欧美视频一区| 久久精品国产77777蜜臀| 日韩欧美国产成人一区二区| 日本网站在线观看一区二区三区 | 欧美日韩一区二区三区在线看|