• <li id="00i08"><input id="00i08"></input></li>
  • <sup id="00i08"><tbody id="00i08"></tbody></sup>
    <abbr id="00i08"></abbr>
  • 新聞中心

    EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > PIC16F84產(chǎn)生兩組PWM輸出的實(shí)例源程序

    PIC16F84產(chǎn)生兩組PWM輸出的實(shí)例源程序

    作者: 時(shí)間:2011-05-17 來(lái)源:網(wǎng)絡(luò) 收藏

    兩組

    本文引用地址:http://www.czjhyjcfj.com/article/150739.htm

    ;**********************************************************************
    list p=16F84 ; list directive to define processor
    #i nclude p16F84.inc> ; processor specific variable definitions

    __CONFIG _CP_OFF _WDT_OFF _PWRTE_OFF _RC_OSC

    ; '__CONFIG' directive is used to embed configuration data within .asm file.
    ; The lables following the directive are located in the respective .inc file.
    ; See respective data sheet for additional information on configuration word.


    ;********************** CONST DEFINITIONS******************************
    FULL_WORK = 10 ; 程???P戳w]?
    DEF_WORK1 = 2 ; 1??P戳w]?
    DEF_WORK2 = 8 ; 2??P戳w]?
    PORT_OUT = PORTB ; PWM塊?梆
    PIN_PWM1 = 0 ; PWM1塊?}?
    PIN_PWM2 = 1 ; PWM2塊?}?
    ;********************** VARIABLE DEFINITIONS***************************
    CBLOCK 0x0C
    w_temp ; variable used for context saving
    status_temp ; variable used for context saving
    PWM_FULL ; 程???P戳p計(jì)竟(?計(jì))
    PWM_WORK_CFG1 ; PWM1 ??P戳]w既?竟
    PWM_WORK_CFG2 ; PWM2 ??P戳]w既?竟
    PWM_WORK_CNT1 ; PWM1 ??P戳p計(jì)竟(?計(jì))
    PWM_WORK_CNT2 ; PWM2 ??P戳p計(jì)竟(?計(jì))
    ENDC
    ;**********************************************************************
    ;****************** 垂??m?{Αi?I ***********************
    ;**********************************************************************
    ORG 0x000 ; processor reset vector
    ResetStart
    goto main ; go to beginning of program
    ;**********************************************************************
    ;****************** い_A叭{Αi?I *************************
    ;**********************************************************************
    ORG 0x004 ; interrupt vector location
    movwf w_temp ; save off current W register contents
    movf STATUS,w ; move status register into W register
    movwf status_temp ; save off contents of STATUS register

    bsf STATUS,RP0
    bcf INTCON,T0IF ; M埃p?竟い_X腹
    bcf STATUS,RP0

    decfsz PWM_FULL,F ; 浪dO?ЧΘ??P戳
    goto ISR_PWM1
    bsf PORT_OUT,PIN_PWM1 ; PWM1/PWM2?_Highq?
    bsf PORT_OUT,PIN_PWM2
    movlw FULL_WORK ; ?s]w???P戳p計(jì)竟
    movwf PWM_FULL
    movf PWM_WORK_CFG1,W
    movwf PWM_WORK_CNT1
    movf PWM_WORK_CFG2,W
    movwf PWM_WORK_CNT2
    goto ISR_EXIT
    ISR_PWM1
    decfsz PWM_WORK_CNT1,F ; 浪dPWM1??P戳
    goto ISR_PWM2
    bcf PORT_OUT,PIN_PWM1 ; ??P戳擋??N塊?]?Lowq?
    ISR_PWM2
    decfsz PWM_WORK_CNT2,F ; 浪dPWM2??P戳
    goto ISR_EXIT
    bcf PORT_OUT,PIN_PWM2 ; ??P戳擋??N塊?]?Lowq?
    ISR_EXIT
    movf status_temp,w ; retrieve copy of STATUS register
    movwf STATUS ; restore pre-isr STATUS register contents
    swapf w_temp,f
    swapf w_temp,w ; restore pre-isr W register contents
    retfie ; return from interrupt
    ;**********************************************************************
    ;****************** ?lてPWM *******************************
    ;**********************************************************************
    InitPWM

    pwm相關(guān)文章:pwm原理



    上一頁(yè) 1 2 下一頁(yè)

    評(píng)論


    相關(guān)推薦

    技術(shù)專(zhuān)區(qū)

    關(guān)閉
    主站蜘蛛池模板: 扎赉特旗| 胶南市| 普定县| 泰安市| 贵溪市| 长丰县| 衡阳市| 沅陵县| 隆林| 汕尾市| 潼关县| 黑龙江省| 武隆县| 八宿县| 银川市| 达拉特旗| 德安县| 张家港市| 桃园市| 山阴县| 汶川县| 株洲县| 崇礼县| 成都市| 察隅县| 鄯善县| 静安区| 西藏| 怀远县| 平阳县| 云和县| 封丘县| 凤庆县| 三河市| 水富县| 铜梁县| 临桂县| 武穴市| 邢台县| 治多县| 哈尔滨市|