Device 16F628A
XTAL = 4
Device 16F628A
XTAL = 4
Dim Timer As Word
Dim Led1Time As Word
Dim Led2Time As Word
ALL_DIGITAL = On
TRISB = 0 ' Configure PORTB as outputs
PORTB = 0 ' Clear PORTB
TRISA = 0
PORTA = 0
Main:
dec tick ;
Goto Main
' Assign some Interrupt associated aliases
Symbol T0IE = INTCON.5 ' TMR0 Overflow Interrupt Enable
Symbol T0IF = INTCON.2 ' TMR0 Overflow Interrupt Flag
Symbol GIE = INTCON.7 ' Global Interrupt Enable
Symbol PS0 = OPTION_REG.0 ' Prescaler ratio bit-0
Symbol PS1 = OPTION_REG.1 ' Prescaler ratio bit-1
Symbol PS2 = OPTION_REG.2 ' Prescaler ratio bit-2
Symbol PSA = OPTION_REG.3 ' Prescaler Assignment (1=assigned to WDT 0=assigned to oscillator)
Symbol T0CS = OPTION_REG.5 ' Timer0 Clock Source Select (0=Internal clock 1=External PORTA.4)
Dim Timer As Word
Dim Led1Time As Word
Dim Led2Time As Word
Dim tick As Word
ALL_DIGITAL = On
ON_HARDWARE_INTERRUPT GoTo Tmr0Int
tick =85
TRISB = 0 ' Configure PORTB as outputs
PORTB = 0 ' Clear PORTB
TRISA = 0
PORTA = 0
' Initiate the interrupt
GIE = 0 ' Turn off global interrupts
PSA = 0 ' Assign the prescaler to external oscillator
PS0 = 0 ' Set the prescaler
PS1 = 0 ' to increment TMR0
PS2 = 0 '
T0CS = 0 ' Assign TMR0 clock to internal source
TMR0 = 0 ' Clear TMR0 initially
T0IE = 1 ' Enable TMR0 overflow interrupt
GIE = 1 ' Enable global interrupts
Main:
If Timer > Led1Time + 10 Then
; yaklasık 1000 ms (1Saniye) de 1 Led 1 yak sondur
PORTA.0 = ~PORTA.0
Led1Time = Timer
EndIf
If Timer > Led2Time + 20 Then
; yaklasık 2000 ms (2Saniye) de 1 Led 2 yak sondur
PORTA.1 = ~PORTA.1
Led2Time = Timer
EndIf
GoTo Main
Tmr0Int:
;100.35 MS de 1 Tick...
If tick < 1 Then
tick = 196
Inc Timer ; Timer her 100 ms de 1 artıcak
EndIf
Dec tick
T0IF = 0 ' Clear the TMR0 overflow flag
Context Restore ' Restore the registers and exit the interrupt