Truncated match.
PICList
Thread
'help wanted!'
1998\01\25@174816
by
Jack Raats
I have to write code in which I've to wait minutes. Is it possible to
use the TIMER0 (TMR0) module to generate such delays? If so could anyone
send me some source code for example?
With greetings ... Jack Raats
1998\01\26@065332
by
Caisson
|
> Van: Jack Raats <spam_OUTjackTakeThisOuT
JARASOFT.XS4ALL.NL>
> Aan: .....PICLISTKILLspam
@spam@MITVMA.MIT.EDU
> Onderwerp: help wanted!
> Datum: zondag 25 januari 1998 23:28
>
> I have to write code in which I've to wait minutes. Is it possible to
> use the TIMER0 (TMR0) module to generate such delays?
IF your TIMER0 has an big enough resolution _and_ IF your clock goes slow
enough
it could work .... :-)
Generaly you mak a setup for the longest wait-time of your TIMER0, and than
create a software-counter on-interrupt (which functions as a extention of
the
hardware-timers). than let the software-counter set a flag when it
expires.
> If so could anyone send me some source code for example?
The below code is for a PIC16C74, it does not go for the longest
delay-time, but it's only an example ...
;----------------------------
org Interrupt
;----------------------------
;Because W-register is saved before the Bank-select bits are set for the
Interrupt-routine
;the register-bank in wich the W-register is saved is undetermined.
therefore the Storage-
;register S_WReg exists in _ALL_ register-banks !
movwf S_WReg ;Save W register
;/ ! S_WReg exists in _ALL_ regi
ster-banks !
swapf STATUS,W ;Save Status register
bcf STATUS,RP0 ;/ Select Register-bank #0
movwf S_SReg ;/
btfsc PIR1,TMR1IF ;Call Timer 1 routine
call I_Timer ;/ on interrupt
swapf S_SReg,W ;Restore Status register
movwf STATUS ;/
swapf S_WReg ;Restore W register
swapf S_WReg,W ;/
retfie
;----------------------------
;----------------------------
; Initialize Timer #1
InitTimer: clrf TMR1L ;Clear timer #1
clrf TMR1H ;/
movlw B'00000001' ;Initialize Timer #1
movwf T1CON ;/
bsf STATUS,RP0 ;Switch to Bank #1
bsf PIE1,TMR1IE ;Enable Timer #1 interrupt
bcf STATUS,RP0 ;Switch to Bank #0
movlw b'11000000' ;Enable global & peripheral
iorwf INTCON ;/ interrupts
return
;----------------------------
I_Timer: movlw low -10000 ;Re-Load timer
movwf TMR1L ;/ (+/- 100 Int's @ a 4MHz crystal)
movlw High -10000 ;/
movwf TMR1H ;/
bcf PIR1,TMR1IF ;Clear Interrupt-flag
decfsz SoftDelay ;Return if Software delay not done
return ;/
movlw 0x?? ;re-Load software counter
movwf SoftDelay ;/
bsf DelayDone,0 ;Set flag to indicate that the delay has
expired
return
;----------------------------
> With greetings ... Jack Raats
Greetz,
Rudy Wieser
More... (looser matching)
- Last day of these posts
- In 1998
, 1999 only
- Today
- New search...