Course: MMBS Lab No: 08 Title: Pulse-Width Modulation (PWM) Module. CID: - Date
Course: MMBS Lab No: 08 Title: Pulse-Width Modulation (PWM) Module. CID: - Date
Course: MMBS
Lab No: 08
Title: Pulse-Width Modulation (PWM) Module.
CID: ________________
Date: _______________
S.No.
Name
SID
5922
HOOMA AMJAD
6007
Faculty/Lab Engineer
Comments
Initials
Marks
ANDLW 0xF8
IORLW 0x02
MOVWF T2CON
;PWM at 2500HZ
MOVF
;set postscaler to
T2CON,W
1
ANDLW 0x07
IORLW 0x00
MOVWF T2CON
;MOVLW D'63'
;movwf
CCPR1L
;set PWM to zero
;CLRF CCPR1L
;set PWM to zero
BCF CCP1CON,4
BCF CCP1CON,5
BSF
T2CON, TMR2ON
;and start the
timer running
0x0000
NOP
;for bootloader compatibility
NOP
NOP
;GOTO START
;ORG
0x0010
;START
;bsf status,5
;bcf status,5
;CALL Initialise
mainloop
BANKSEL ADCON1
A2D
MOVLW 0x06
MOVWF ADCON1
BANKSEL PORTA
BANKSEL TRISC
MOVLW 0
all outputs
MOVWF TRISC
movlw b'00000011'
movwf trisb
BANKSEL PORTC
;turn off
;set PORTC as
increment
btfss portb,0
btfsc portb,0
goto Continue_1
delay_1
btfss portb,0
goto delay_1
incf CCPR1L
goto increment
Continue_1
decrement
btfss portb,1
btfsc portb,1
goto mainloop
delay_2
btfss portb,1
goto delay_2
decf CCPR1L
goto decrement
GOTO mainloop
;end of Delay routines
END
MOVF
CCP1CON,W
;set
CCP1 as PWM
ANDLW 0xF0
IORLW 0x0C
MOVWF CCP1CON
MOVLW
D'126'
BANKSEL PR2
permanently on
MOVWF PR2
BANKSEL TMR2
value
MOVF
16
T2CON,W
;set prescaler to