View previous topic :: View next topic |
Author |
Message |
tefbox
Joined: 15 Mar 2011 Posts: 5
|
wdt - reg address issue? PIC16f917 [solved] |
Posted: Tue Mar 15, 2011 7:31 am |
|
|
looking for help on using wdt on a PIC16F917.
I'm using PCM in mplabs. Have been trying to get the wdt working for much too long and decided I need help.
I wanted to s/w enable wdt, so I had #fuse NOWDT. No matter how I setup wdt I couldn't get it to function. No matter what I did in setup_wdt() the OPTION_REG remained 11111111 and WDTCON 00001000.
I looked at the disassembly listing and the addressing of registers didn't look right (that being said I had to learn assembly to understand this...so might be wrong).
Example c code
setup_wdt(WDT_ON); //assuming this changes bit0 in WDTCON
resulting assembly
BCF 0x3, 0x7
BCF 0x3, 0x6
BSF 0x3, 0x5 //bank1
MOVLW 0x1
MOVWF 0x17 //bank 1 selected addr ox97
I would have expected bank 2 with a MOVWF 0x5 (WDTCON addr 0x105). Watching registers with mplab sim the only change with the above code is bit 0 high in register CMCON1 at address 0x97
The only way to get WDT to work is to write my own assembly within my C (which I don't want to do), and adjust WDTCON and OPTION_REG that way.
using setup_wdt(WDT_18MS || WDT_TIMES_128) or any other possible combination also doesn't do anything to WDTCON and OPTION_REG.
I have the correct chip selected and header file. Prior to this I had done a quick test to get an LED flashing without a problem.
I've doubled my knowledge trying to figure this out (yes..didn't know much before)...but I need help...going crazy!
Thanks
Last edited by tefbox on Mon Mar 21, 2011 9:57 am; edited 1 time in total |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9221 Location: Greensville,Ontario
|
|
Posted: Tue Mar 15, 2011 7:45 am |
|
|
Two quick questions..
1) Does that PIC actually have a 'software enabled' WDT ? Some do, some don't acording to the PCM help file.If so maybe the version of PCM has a 'quirk' or 'bug' .If it doesn't it'd never work.
2) Normally WDT is setup as a hardware failsafe, incase the program 'hangs' or goes into 'lala land'. Why do you want to control it's operation from within the program? If the program never enables it and goes 'funny' you'ld never reset ! |
|
|
newguy
Joined: 24 Jun 2004 Posts: 1907
|
|
Posted: Tue Mar 15, 2011 7:59 am |
|
|
It's been many years since I've used a 16 series PIC, so I'm probably wrong, but I thought that the 16's WDT could only be enabled/disabled via fuse settings. I thought it was only the 18's that could enable/disable the WDT in software.... |
|
|
tefbox
Joined: 15 Mar 2011 Posts: 5
|
|
Posted: Tue Mar 15, 2011 8:34 am |
|
|
The PIC16F9XX series can enable/disable wdt in s/w (SWDTEN bit of WDTCON), only if the WDTE bit in the config register wasn't enabled with #fuse.
I planned on using watchdog to wake-up from sleep. It seemed the easiest way to exit sleep and continue program execution. |
|
|
tefbox
Joined: 15 Mar 2011 Posts: 5
|
|
Posted: Mon Mar 21, 2011 10:01 am |
|
|
The addressing issue with WDTCON has been solved by CCS, they've sent me a revised devices4.dat file to replace my current one. Everything is addressing correctly now!
I'm impressed with how fast a revision was made. |
|
|
|