CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

wdt - reg address issue? PIC16f917 [solved]

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
tefbox



Joined: 15 Mar 2011
Posts: 5

View user's profile Send private message

wdt - reg address issue? PIC16f917 [solved]
PostPosted: Tue Mar 15, 2011 7:31 am     Reply with quote

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: 9243
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Mar 15, 2011 7:45 am     Reply with quote

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: 1909

View user's profile Send private message

PostPosted: Tue Mar 15, 2011 7:59 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Mar 15, 2011 8:34 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Mar 21, 2011 10:01 am     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group