uaefame
New Member
Good afternoon,
I am trying to turn an LED on and off every 2 second. I am using PIC 16F818. I am interested in using internal timming and I am setting it to 4MHz.
Here are my codes
I would like to know why my LED doesn't function as I expect it is the problem in the coding because I was able to turn led on and off using PIC16F84a.
My header file is as follow
Help needed!
Q> Is there a problem with my coding?
Q> How can I set an internal timmer? I am following the datasheet page 38 of PIC16F818?
Thanks in advance
I am trying to turn an LED on and off every 2 second. I am using PIC 16F818. I am interested in using internal timming and I am setting it to 4MHz.
Here are my codes
Code:
list p=16F818 ; list directive to define processor
#include <p16F818.inc> ; processor specific variable definitions
__config H'3F10'
movlw b'01100000'
movwf OSCCON
cblock 0x0c
d1,d2,d3
endc
bsf STATUS,5
movlw 00h
movwf TRISA
bcf STATUS,5
START movlw 02h
movwf PORTA
call Delay2sec
movlw 00h
movwf PORTA
call Delay2sec
goto START
Delay2sec
;1999996 cycles
movlw 0x11
movwf d1
movlw 0x5D
movwf d2
movlw 0x05
movwf d3
Delay2sec_0
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto Delay2sec_0
;4 cycles (including call)
return
END
I would like to know why my LED doesn't function as I expect it is the problem in the coding because I was able to turn led on and off using PIC16F84a.
My header file is as follow
Code:
Configuration Bits
__CONFIG H'3F10'
;sets INTRC-A6 is port i/o
;WDT off
;PUT on
;MCLR tied to VDD
;A5 is I/O
;BOD off
;LVP disabled
;Flash Program Write disabled
;Background Debugger disabled
;CCP function on B2
;Code Protection disabled
Help needed!
Q> Is there a problem with my coding?
Q> How can I set an internal timmer? I am following the datasheet page 38 of PIC16F818?
Thanks in advance