日本久久久久曰精品免费,国产精品一级二级三级,乱子伦av无码中文字幕s,国产成人精品一区免费视频

技術(shù)熱線: 4007-888-234

技術(shù)支持

單片機AD轉(zhuǎn)換

更新時間: 2019-03-23

十年專注單片機方案開發(fā)的方案公司英銳恩,分享單片機AD轉(zhuǎn)換。英銳恩現(xiàn)提供服務產(chǎn)品涉及主控芯片:8位單片機、16位單片機、32位單片機及各類運算放大器等。

w EQU 00h f EQU 01h STATUS EQU 03h PORTB EQU 06h INTCON EQU 0Bh PIR1 EQU 0Ch PIR2 EQU 0Dh TMR1L EQU 0Eh TMR1H EQU 0Fh T1CON EQU 10h T2CON EQU 11h ADRESH EQU 1Eh ADCON0 EQU 1Fh TRISB EQU 86h PIE1 EQU 8Ch ADCON1 EQU 9FH TRISA EQU 85H

LAST EQU 20h W_TEMP EQU 21h STATUS_TEMP EQU 22h Scaler EQU 23h LAST1 EQU 24h TEMP EQU 25h

org 000h nop goto main org 004h goto intservice

intservice movwf W_TEMP ;存儲w寄存器內(nèi)容 swapf STATUS,w movwf STATUS_TEMP btfsc PIR1,0 ;判斷TIMER1是否溢出中斷 call Timer1 ;調(diào)用Timer1中斷服務程序 swapf STATUS_TEMP,w movwf STATUS swapf W_TEMP,f swapf W_TEMP,w ;恢復w和status的內(nèi)容 retfie

Timer1 bcf STATUS,5 bcf PIR1,0 ;將TIMER1的中斷使能標志清0 decf Scaler,f clrf TMR1L ;把TMR1清0,防止進位產(chǎn)生 movlw 88h;;;;;;;;;; movwf TMR1H movlw 2fh movwf TMR1L return

main call Initial mainloop call Delay call ADConvert subwf LAST,w btfsc STATUS,2 goto mainloop movwf LAST1 movf TEMP,w movwf LAST btfsc STATUS,0 goto Display1 goto Display2 ;goto mainloop

Initial movlw 00h movwf LAST bcf STATUS,5 clrf PORTB movlw 04h movwf Scaler bsf STATUS,5 clrf TRISB ;設(shè)定B口為輸出口 bcf STATUS,5 clrf T1CON ;設(shè)定TIMER1的時鐘為FOSC/4,不使用分頻器 clrf TMR1H clrf TMR1L clrf INTCON bsf INTCON,6 ;將外圍功能的中斷使能 bsf STATUS,5 clrf PIE1 bsf PIE1,0 ;將TIMER1的溢出中斷使能 bcf STATUS,5 clrf PIR1 clrf TMR1L movlw 88h;;;;;;;;;; movwf TMR1H movlw 2fh movwf TMR1L ;bsf T1CON,0 ;TIMER1開始計數(shù) bsf STATUS,5 movlw B'00001110' ;選擇A/D轉(zhuǎn)換輸入端RA0,參考電壓為VDD及VSS movwf ADCON1 bsf TRISA,0 ;設(shè)定A口<0>為輸入端 bcf STATUS,5 movlw B'10000001' ;工作時鐘為FOSC/32,并啟動A/D轉(zhuǎn)換模塊 movwf ADCON0 bsf INTCON,7 ;將中斷總開關(guān)打開,使中斷可以產(chǎn)生 return

ADConvert bcf STATUS,5 bsf ADCON0,2 ;執(zhí)行A/D轉(zhuǎn)換 wait btfsc ADCON0,2 goto wait movf ADRESH,w ;movlw B'00010000' andlw B'11111000' movwf TEMP bcf STATUS,0 rrf TEMP,f rrf TEMP,f rrf TEMP,f movf TEMP,w return

Display1 bcf STATUS,5 loop1 movlw B'11000000' movwf PORTB call Delay movlw B'01100000' movwf PORTB call Delay movlw B'00110000' movwf PORTB call Delay movlw B'10010000' movwf PORTB call Delay ;movlw B'11000000' ;movwf PORTB ;call Delay ;movlw B'01100000' ;movwf PORTB ;call Delay ;movlw B'00110000' ;movwf PORTB ;call Delay ;movlw B'10010000' ;movwf PORTB ;call 

Delay decfsz LAST1,f goto loop1 movlw B'00000000' movwf PORTB bcf STATUS,0 goto mainloop Display2 bcf STATUS,5

loop2 movlw B'10010000' movwf PORTB call Delay movlw B'00110000' movwf PORTB call Delay movlw B'01100000' movwf PORTB call Delay movlw B'11000000' movwf PORTB call Delay ;movlw B'10010000' ;movwf PORTB ;call Delay ;movlw B'00110000' ;movwf PORTB ;call Delay ;movlw B'01100000' ;movwf PORTB ;call Delay ;movlw B'11000000' ;movwf PORTB ;call Delay incfsz LAST1,f goto loop2 movlw B'00000000' movwf PORTB bcf STATUS,0 goto mainloop

Delay bsf T1CON,0 ;TIMER1開始計數(shù) Delay1 btfss Scaler,7 ;檢查Scaler的第7位是否為0 goto Delay1 bcf T1CON,0 ;TIMER1停止計數(shù) clrf TMR1L ;把TMR1清0,防止進位產(chǎn)生 movlw 88h;;;;;;;;;; movwf TMR1H movlw 2fh movwf TMR1L movlw 05h addwf Scaler,f return

end

404
返回首頁 |  返回上一頁
主站蜘蛛池模板: 宜川县| 齐齐哈尔市| 福州市| 灵丘县| 长海县| 玉树县| 贵南县| 梁平县| 蒙自县| 东源县| 灵璧县| 武隆县| 长顺县| 郧西县| 尼玛县| 信宜市| 和平县| 阿尔山市| 阜康市| 泰和县| 永登县| 田东县| 宜兰市| 昌黎县| 新泰市| 邢台县| 日土县| 浑源县| 沅江市| 涡阳县| 台东县| 江西省| 伊吾县| 庆元县| 卢湾区| 济宁市| 顺昌县| 邮箱| 南靖县| 台南市| 平凉市|