大香蕉大香蕉在线播放-日韩av在线一区中文字幕-日韩熟女熟妇久久精品综合-精品免费视频一区二区三区

技術(shù)熱線: 4007-888-234
設(shè)計開發(fā)

專注差異化嵌入式產(chǎn)品解決方案 給智能產(chǎn)品定制注入靈魂給予生命

開發(fā)工具

提供開發(fā)工具、應(yīng)用測試 完善的開發(fā)代碼案例庫分享

技術(shù)支持

從全面的產(chǎn)品導(dǎo)入到強大技術(shù)支援服務(wù) 全程貼心伴隨服務(wù),創(chuàng)造無限潛能!

新品推廣

提供新的芯片及解決方案,提升客戶產(chǎn)品競爭力

新聞中心

提供最新的單片機資訊,行業(yè)消息以及公司新聞動態(tài)

利用PIC的PWM實現(xiàn)數(shù)模轉(zhuǎn)換的方法

更新時間: 2019-03-25
閱讀量:2300

硬件圖:

 

3cb4317700b54fa3a81c287de7a81526.png

源程序:

; PWM port (in w), pin, duty
; Generates a bit stream of 256 1s and 0s with the specified
; duty cycle. If this bit stream is run through a simple RC
; integrator, the result is an analog voltage output of
; (duty/255) * (PIC supply voltage). For example, if duty is
; 100 and the supply is 5 volts, then the integrated output of
; pwm would be (100/255) * 5 = 1.96 volts. In many applications,
; pwm output should be buffered with a unity-gain op-amp
; circuit. In those cases, the pwm output pin should be set up
; as an output when Pwm is called, then immediately switched to
; input when Pwm is done. This prevents the steady-state output
; of the pin from affecting the voltage set by Pwm.

  P = pic16c55
        #include <16c55.inc>   ; processor assembler definitions
        _CONFIG _xt_osc & _wdt_off & _protect_off
        reset start

        org 8
duty Res d'1' ; Pwm duty cycle.
acc Res d'1' ; Pwm accumulator.
index Res d'1' ; Temporary counter for pwm.
pin Res d'1' ; Pin number to pulse (0-7).

; Device data and reset vector

 org 0

; Table to convert pin number (0-7) into bit mask (00000001b to 10000000b).
Pinz         ADDWF pcl                 
             RETLW d'1'                
             RETLW d'2'
             RETLW d'4'
             RETLW d'8'
             RETLW d'16'
             RETLW d'32'
             RETLW d'64'
             RETLW d'128'

start        MOVLW d'0'                 ; All outputs.
             TRIS 5h
             CLRF 5h                    ; Start with LED off.
             CLRF duty                  ; Initial brightness = 0.
             CLRF index                 ; Clear loop counter for pwm.
start_loop   MOVLW d'2'                 ; Pin 2.
             MOVWF pin

 MOVLW d'0'                 ; of port ra.
             CALL pwm                   ; Send pwm to LED.
             INCF duty                  ; Turn up brightness.
             GOTO start_loop            ; Endless loop
; Upon entry, the desired pin must already be set up as an output.
; Variable "pin" contains the pin number (0-7). The w register contains a
; number representing the output port (0-2) for RA through RC. The variable
; duty contains the desired duty cycle from 0 to 255.

Pwm          MOVWF fsr                  ; Point to the port number.
             MOVLW 5h                   ; Add offset for port RA.
             ADDWF fsr
             MOVF pin,w                
             CALL Pinz                  ; Get bit mask from the table.
             MOVWF pin                  ; Put the mask into pin.
Pwm_loop     MOVF duty,w                ; Let acc = acc + duty
             ADDWF acc

             MOVF pin,w                
             BTFSC status,c             ; IF carry THEN pin = 1
             IORWF indirect             ; ELSE pin = 0.
             COMF pin,w                
             BTFSS status,c            
             ANDWF indirect             

    DECFSZ index               ; Repeat 256 times.
             GOTO Pwm_loop
             RETLW 0h                  

            
            
             end


操的我的逼逼好爽好多水| 大鸡巴插我在线观看| 黑人大鸡把操逼视频| 国产精品免费99久久久| 草草久性色av综合av| 大肌巴日小个子女人视频| 小嫩骚逼操死你视频| 日韩欧美一区二三区风间由美| 久久亚洲精品无码AV宋| 大肉棒插了按摩视频| 欧美精品第一区二区三区| 亚洲国产精品伦理在线看| 日韩在线中文字幕在线视频| 久久精品一区二区三区免费看| 多男用舌头伺候一女| 一区二区三区av精品| 热精品韩国毛久久久久久| 大鸡巴操小逼的视频| 大鸡巴射在穴穴里的视频| 肏亚洲女人小骚逼| 日韩精品人妻一区二区免费| 国产高清乱码女大生AV| 想被操在线啊啊啊啊| 极品美女销魂一区二区三区| 欧美巨屌虐无毛骚逼| 大鸡吧天天草黑逼| 一级风流国产片a级| 日韩美女一区二区三区香蕉视频| 欧美精品国产一区二区在线观看| 骚逼嫩鸡巴喷水视频| 日韩无码av三级片| 玩弄邻居少妇呻吟11p| 裸体美女被操的啊啊直叫| 蜜臀AV无码国产精品尤物| 国产高清乱码女大生AV| 中文字幕日韩亚洲| 粉色av一区二区三区| 91麻豆精品福利在线观看| 欧美高清一二三区| 操小骚逼高潮视频| 欧美日韩久久久久久久久|