bruce,
to make things clear. i've written it in a program to have a 31.25ms timer at a prescale of 1:8,yielding a 250ms to overflow TIMER1. i verified it in a oscilloscope that it is accurate.
i hope now that everything clear for you now. the decideTimeInterval counter now increments every second avoiding fast incrementing, like you said.Code:define debug_reg porta 'nevermind my serial LCD display debugger define debug_bit 0 define debug_baud 2400 define debug_mode 1 define inthand checkNow define OSC 8 CMCON=7 time var word timeL var time.byte0 timeH var time.byte1 decideTimeInterval var word TIMEINTERVAL con 600 ;----------------------- setup: debug 12,"Starting",10,13," Program",4 pause 2000 intcon = %11000000 ;setting up gie and peie bits time = 3036 ;calibrated to have 31.25ms scale tmr1L = timeL ;65536 - time (preload value) tmr1H = timeH flag = 0 PIR1.0 = 0 PIE1.0 = 1 T1CON = %110001 ;setting up to 1:8 prescale ;31.25ms x 8 = 250ms/count ;-------------------------------- main: if flag = 4 then ;(250ms x 4 = 1s) second ticker flag = 0 decideTimeInterval = decideTimeInterval + 1 gosub updateTime endif if decideTimeInterval = TIMEINTERVAL then ;this one is the notorious routine. it's just a reset condition. decideTimeInterval = 0 ;It resets unexpectedly. In contrast to this, endif ;changing the decideTimeInterval to BYTE and of course ;TIMEINTERVAL <= 255 will function properly goto main ;---------------------------- updateTime: DEBUG "Time:",#decideTimeInterVal return ;------------------------ ;interrupt handler @checkNow pie1.0 = 0 flag = flag + 1 time = 3036 toggle = portb.3 ;my monitor to oscilloscope, it accurately toggles at 250ms cycle TMR1L = timeL TMR1H = timeH PIR1.0 = 0 PIE1.0 = 1 resume
any ideas?
thanks and I appreciate very much
regards,
yettie




Bookmarks