At 12:08 AM 7/01/99 PST, you wrote:
>Content-type: text/plain; charset=US-ASCII
>Content-transfer-encoding: 7BIT
>Content-description: Mail message body
>
>i have been working on a datalogger project that requires
>recalibration of a timing loop based on outside temperature. Chip is
>16c84. i created a small program to
>setup the wdt
>clear a counter
>clrwdt
>run a loop till timer times out
>display answer on leds at portb
>go to sleep
>start over.
>
>im attaching the code. .
When SLEEP is executed the program will stop there and on a WDT timeout it
will start at the next instruction and then go to the label "go". It will
not go to the instructions where you evaluate what type of timeout it was.
This should be done after the SLEEP instruction if this is what you want.
good luck,
Peter Grey
{Quote hidden}>heres the problem: it doesent work. when wdt trips, it goes back to
>top, instead of being routed to display routine, it reinitializes the
>count register, and basically orbits between the loop and
>re-initialization. playing around with it, i cant find evidence that
>the wdtimeout really clears bit 4 in status. as you can see from the
>code, i tried testing bit 4 first, then bit 3,, then the other way
>around. i tried catching it after the initialization. i tried to
>catch it by using the presence of data in the count register to goto
>the display routine. i have confirmed that the routine at the top
>does implement restart (status,4=1 and status,3=1) ok, sleep looks
>ok, and mclr looks ok. but wdt doesent seem to work...
>
>im using most recent (dos) mpasm on old 486 laptop.
>
>and what will happen if this is in a subroutine? the thought scares
>me. wakeup on sleep just continues with program counter, wdtimeout
>loses the stack??? i stayed home from work yesterday to work on this
>and im stumped.
>
>any help appreciated.
>alice
>
>alice
>Content-type: text/plain; charset=US-ASCII
>Content-transfer-encoding: 7BIT
>Content-description: Text from file 'pict7.asm'
>
>;======pict7.asm============1 aug 98===============
> list p=16c84
> radix hex
>;----------------------------------------------------
>;cpu equates (memory map)
>portb equ 0x06
>mine equ 0x0a
>mflag equ 0x0b
>check equ 0x0c
>temp equ 0x0d
>status equ 0x03
>tmr0 equ 0x01
>intcon equ 0x0b
>optreg equ 0x81
>trisb equ 0x86
>on equ 1
>to equ 4
>pd equ 3
>w equ 0
>c equ 0
>f equ 1
>z equ 2
>rp0 equ 5
>;----------------------------------------------------
> org 0x000
>; btfss status,4 ;timeout
>; goto to0ck ;=0
>; goto to1ck ;=1
>
>;to0ck btfsc status,3 ;powerdown
>; goto display ;to=0&pd=1=wdt
>; goto go ;to=0&pd=0=sleep
>
>;to1ck btfss status,3
>; goto display ;to=1&pd=0 mclr (could use for serial?)works
>; goto start ;to=1&pd=1 startup ...works
>
> btfsc status,3 ;-pd?
> goto test1 ;pd=1 means pu or clwdt
> goto test2 ;pd=0 set by sleep
> org 0x005
>
>test1 btfsc status,4 ;pd=1,to? clrwdt sets to=1
> goto start ;to=1& pd=1->powerup ....works
> goto go ;display ;to=0&pd=1->wdt ??????????
>
>test2 btfss status,4 ;pd=0,to=?
> goto go ;pd=0&to=0 ->sleep ???????
> goto display ;pd=0&to=1 ->mclr ...works
>
>start
> movlw b'00000000' ;load W with 0x00
> tris portb
> ; clrwdt ;to=1&pd=1 this prevents wdt in go
> movlw b'11011000' ;wdt=1&1:1...timeout is 18 ms
> option
> bcf status,rp0 ;back to bank0
> movlw 0x00 ;?????????????
> movwf mine ;put something in mine to start
>; clrf portb ;all lines low
> movlw b'00000111' ;bsf portb,0
> xorwf portb ;is this looping?
>; goto display
>
>go ; clrwdt
> movfw mine ;if wdt then mine has count in it
> sublw 0x00 ;is it empty?
> btfss status,z ;z well,does it?
> goto display ;cool. show me
>
>calib clrwdt ;at this point prescale is 0
>cycle ;time 1 wdt cycle
> ; incf mine,f ;1 tick
> ; movlw b'00000010' ;bsf portb,0
> movfw status
> movwf portb
> xorwf portb ;is this looping? ...yes,but....
> goto cycle ;2 ticks 5 total here
> bsf portb,6 ;never gets here if wdt
>
>display; clrwdt ;show mine if wdt handled right
> movfw mine
> movwf portb ;did it count??
> clrf mine ;setup for next run
> bsf portb,2
> goto snooze ;all done
>
>snooze ; clrwdt ;po=1&pd=1
>; movlw b'11011111' ;reset prescaler for long sleep
>; option
>; bcf status,rp0
> sleep ;pd=0,to=1. pgm continues...
> clrwdt
> bcf portb,2
> movlw b'11011000'
> option
> goto go ;loop
>;---------------------------------------------------
>
> end
>;------------------------------------------------------
>;at blast time, select:
>; memory unprotected
>; watchdog timer disabled (default is enabled)
>; standard xtal using 4 mhz
>; powerup timer on
>;======================================================
>