|
list p=16f627a include "p16f627a.inc" STATUS EQU 03H ;定义状态寄存器地址 PORTB EQU 06H T2CON EQU 12H CCPR1L EQU 15H CCP1CON EQU 17H OPTION_REG EQU 81H TRISB EQU 86H PR2 EQU 92H RP0 EQU 5 ;寄存器体选 ORG 0000H GOTO MAIN ORG 0005H MAIN BSF STATUS,RP0 ;选择体1 BCF TRISB,3 ;设置RB3为输出 BCF STATUS,RP0 ;选择体0 MOVLW B'00000000' MOVWF PORTB ;初始化IO口 PWM BSF STATUS,RP0 ;选择体1 MOVLW D'25' MOVWF PR2 ;周期26US=(PR2+1)*4*Tosc*T2分频 BCF STATUS,RP0 ;选择体0 MOVLW B'00001100' MOVWF CCPR1L ;占空比13US=(CCP1L:CCP1COM<5:4>)*Tosc*T2 MOVLW B'00001100' MOVWF CCP1CON ;pwm输出模式选择11xx MOVLW B'00100100' MOVWF T2CON ;<1:0>TMR2分频比1,<2>使能TMR2 END
|
|