hi guys can any one help with assembly code for dimming an led using the pic16f88. ihave read the datasheet but i dont seem to underatand it i have come with code but it doesnt work can anybody tell me whats wrong with my code.
list p=16f88
INCLUDE "p16f88.inc"
_;****Set up the Constants****
STATUS equ 03h
TRISA equ 85h ;Address of the STATUS register
TRISB equ 86h
PORTA equ 05h ;Address of the tristate register for port A
PORTB equ 06h ;Address of Port A
COUNT1 equ 20h ;First counter for our delay loops
COUNT2 equ 21h ;Second counter for our delay loops
ANSEL equ 9Bh
OSCCON equ 8Fh
CCP1CON equ 17h
T2CON equ 12h
TMR2 equ 11h
CCPR1L equ 15h
PR2 equ 92h
PIR1 equ 0Ch
PIE1 equ 8Ch
movlw B'00000000' ; 31.25khz
bsf STATUS, 5
movwf OSCCON
nop
nop
nop
bcf STATUS, 5
movlw b'00111100'
movwf CCP1CON
bsf 03h,5 ;Go to Bank 1
movlw 00h ;Put 00000 into W
movwf TRISA ;Move 00000 onto TRISA – all pins set to output
movlw 00h ;Set the Port B pins
movwf TRISB ;to output. ;Put 00000 into W
movlw 00h
movwf ANSEL ;Move 00000 onto TRISA – all pins set to output
movlw b'11111111'
movwf PR2
bcf 03h,5 ;Come back to Bank 0
movlw b'00001111'
movwf TMR2
Start
movlw b'00001111'
movwf CCPR1L ; set duty cycle
Loop1
decfsz CCPR1L ;dimming led by varying the duty cycle
goto Loop1
goto Start
end
Bookmarks