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

    EEPW首頁 > 嵌入式系統 > 設計應用 > 基于PIC16F84的兩組PWM輸出的實例源程序

    基于PIC16F84的兩組PWM輸出的實例源程序

    作者: 時間:2012-08-12 來源:網絡 收藏

    產生兩組

    本文引用地址:http://www.czjhyjcfj.com/article/171049.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 ;
    DEF_WORK1 = 2 ;
    DEF_WORK2 = 8 ;
    PORT_OUT = PORTB ;
    PIN_1 = 0 ;
    PIN_2 = 1 ;
    ;********************** VARIABLE DEFINITIONS***************************
    CBLOCK 0x0C
    w_temp ; variable used for context saving
    status_temp ; variable used for context saving
    PWM_FULL ;
    PWM_WORK_CFG1 ;
    PWM_WORK_CFG2 ;
    PWM_WORK_CNT1 ;
    PWM_WORK_CNT2 ;
    ENDC
    ;**********************************************************************
    ;****************** ***********************
    ;**********************************************************************
    ORG 0x000 ; processor reset vector
    ResetStart
    goto main ; go to beginning of program
    ;**********************************************************************
    ;****************** *************************
    ;**********************************************************************
    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 ;
    bcf STATUS,RP0

    decfsz PWM_FULL,F ;
    goto ISR_PWM1
    bsf PORT_OUT,PIN_PWM1 ;
    bsf PORT_OUT,PIN_PWM2
    movlw FULL_WORK ;
    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 ;
    goto ISR_PWM2
    bcf PORT_OUT,PIN_PWM1 ;
    ISR_PWM2
    decfsz PWM_WORK_CNT2,F ;
    goto ISR_EXIT
    bcf PORT_OUT,PIN_PWM2 ;
    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
    ;**********************************************************************
    ;**********************************************************************
    InitPWM
    bsf STATUS,RP0 ;
    bcf PORT_OUT,PIN_PWM1
    bcf PORT_OUT,PIN_PWM2
    bcf STATUS,RP0
    bsf PORT_OUT,PIN_PWM1 ;
    bsf PORT_OUT,PIN_PWM2
    movlw FULL_WORK ;
    movwf PWM_FULL
    movlw DEF_WORK1
    movwf PWM_WORK_CFG1
    movwf PWM_WORK_CNT1
    movlw DEF_WORK2
    movwf PWM_WORK_CFG2
    movwf PWM_WORK_CNT2
    retlw 0

    pwm相關文章:pwm是什么


    pwm相關文章:pwm原理



    上一頁 1 2 下一頁

    評論


    相關推薦

    技術專區

    關閉
    主站蜘蛛池模板: 区。| 泰安市| 交城县| 许昌市| 伊春市| 留坝县| 宁河县| 宜都市| 昭通市| 定南县| 星子县| 安乡县| 新和县| 长阳| 宜川县| 阳西县| 澜沧| 安庆市| 西平县| 历史| 广宗县| 乡宁县| 阿坝县| 绥棱县| 富顺县| 长沙县| 宜兴市| 辽源市| 五寨县| 施甸县| 龙泉市| 鹤岗市| 北京市| 安多县| 建瓯市| 南雄市| 鄂温| 海兴县| 开鲁县| 双城市| 永清县|