Hi I have this program which turns ON & OFF a led with a calculated time.
I want to calculate what’s the exact led ON time & led OFF time using a simulator or any other method.
I don’t know in what rate this led turns on & off.
My Oscillator = 4 MHz
Please help me to calculate this.
I want to calculate what’s the exact led ON time & led OFF time using a simulator or any other method.
I don’t know in what rate this led turns on & off.
My Oscillator = 4 MHz
Please help me to calculate this.
Code:
List p=16F628A
include <P16F628A.inc>
errorlevel -302
__config 3F18h
cblock 20h
W_Temp,S_Temp,TIME
endc
#define LED PORTB,0
org 0000h
goto Start
;***********
;ISR routine
;***********
org 0004h
bcf INTCON,GIE
movwf W_Temp
swapf STATUS,W
movwf S_Temp
btfss INTCON,T0IF
goto Away
bcf INTCON,T0IF
movlw .6
addwf TMR0,F
incf TIME,F
movf TIME,W
andlw 7fh
xorlw .125
btfss STATUS,Z
goto Away
btfss TIME,7
goto $+4
clrf TIME
bcf LED ;turn OFF led
goto Away
clrf TIME
bsf TIME,7
bsf LED ;turn ON led
Away swapf S_Temp,W
movwf STATUS
swapf W_Temp,F
swapf W_Temp,W
bsf INTCON,GIE
retfie
;*******************************
;Initialisation -setup the ports
;*******************************
Start bsf STATUS,RP0
clrf TRISB
movlw b'00000011' ;set prescaller to 16
movwf OPTION_REG
bsf INTCON,T0IE
bsf INTCON,GIE
bcf STATUS,RP0
clrf PORTB
Hang nop
goto Hang
end