LIST P=16F628;f=inhx8m
#include "P16F628.INC" ; Include header file
__CONFIG _PWRTE_ON & _WDT_OFF & _INTRC_OSC_NOCLKOUT & _BODEN_ON & _LVP_OFF & _CP_OFF & _MCLRE_OFF
;------------------------------------------------------------
errorlevel -302 ; suppress banksel warning messages during assembly
errorlevel -311 ; suppress HIGH operator warning messages during assembly
cblock 0x20 ; Beginn General Purpose-Register
;-------------------------- counters
d1
d2
d3
;--------------------------
endc
;--------------------------
;--- Reset --------------------------------------------------
org h'00'
goto init ; reset -> init
;--- Interrupt ----------------------------------------------
org h'04'
init;clrf PORTA
;clrf PORTB
movlw 0x07 ; Turn comparators off and enable pins for I/O
movwf CMCON
bcf STATUS,RP1
bsf STATUS,RP0 ; Bank 1
movlw 0xFF ; all input
movwf TRISA
movlw 0x00
movwf TRISB ; all output
bcf STATUS,RP0 ; Bank 0
call pause
movlw 0xFF
movwf PORTB
call pause ; wait
;---------------------
clrf T2CON
clrf TMR2
clrf INTCON
bsf STATUS,RP0
clrf PIE1
bcf STATUS,RP0
clrf PIR1
bsf STATUS,RP0
movlw 0xFF
movwf PR2 ; compare with 255
bcf STATUS,RP0
movlw b'00000011'
movwf T2CON ; prescaler 1:16 and postscaler 1:1
movlw 0x3C
movwf CCP1CON
;************************************************************
Start
movlw .0
movwf CCPR1L
call pause
incfsz CCPR1L,f
goto $-2
call pause
movlw .255
movwf CCPR1L
call pause
decfsz CCPR1L,f
goto $-2
goto Start ; repeat
;************************************************************************
;
;************************************************************************
pause
;199998 cycles 2msec
movlw .100
movwf d1
movlw .3
movwf d2
Delay_0
decfsz d1, f
goto $+2
decfsz d2, f
goto Delay_0
return
end
Far Too Complicated!!Happy to hear you got it going. If you're still interested, here's an embarrassingly old example (attached).
Cheerful regards, Mike
I think a more appropriate response would have been "thank you" (lol).Far Too Complicated!!
Rich (BB code):bcf STATUS,RP1 bsf STATUS,RP0 ; Bank 1 movlw 0xFF movwf PR2 ; pwm width 255
PR2=0xFF;
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
S | Pic 16f628a ouput to Android via USB | General Electronics Chat | 3 | |
pickit 3 micro controller 16F628A on arduino uno ? | Microcontrollers | 1 | ||
A | A little 16F628A Demo :D | Microcontrollers | 2 | |
A | PIC 16f628a 7 seg. multiplexing | Microcontrollers | 3 | |
C | Migrating code from 16F627 to 16F628A: Getting errors | Microcontrollers | 6 |
by Aaron Carman
by Duane Benson
by Aaron Carman
by Jake Hertz