|
|
View previous topic :: View next topic |
Author |
Message |
tvlodek
Joined: 29 Jan 2008 Posts: 3
|
Problems setting up WDT and timer1 |
Posted: Tue Oct 07, 2008 8:16 am |
|
|
I'm using a 16F913 processor running at 31 kHz. Upon power up, the board initializes everything then just waits in sleep mode for an external interrupt, while flashing the display every 1/4 second. When it receives the interrupt, I had enabled timer0, using it as the timebase for 250 mS intervals, in the timer0 ISR, I measure some voltages, perform a few computations and display the results on a 7 segment display. I have been unable to leave the WDT enabled; unless I turn it off when servicing ISR_EXT, it seems I can't clear the wdt and the unit resets itself.
My problems are twofold; I can't seem to restart the wdt or change the prescalar. I guess the prescaler is shared with the wdt and timer0, I thought I may not be able to change the prescaler (I need a different prescaler for sleep mode as opposed to run mode (>500mS), so I decided to switch the time base to timer1. In the timer1 ISR, I load timer1 with xFF00. While running the ICD, I halt the program and find values less than 0xFF00. I think I read in the CCS documentation that you have to stop timer1 before you load it but that didn't change things. If anyone can tell me what I'm doing wrong, I'd appreciate it.. Thanks. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Oct 07, 2008 11:00 am |
|
|
Quote: |
I can't seem to restart the wdt.
While running the ICD, I halt the program and find values less than 0xFF00.
|
I don't know about the CCS ICD, but the help file for the Microchip ICD2
says this:
Quote: | Debugger Limitations
The Watchdog Timer (WDT) cannot be used when debugging. |
The CCS ICD probably has the same limitation. |
|
|
tvlodek
Joined: 29 Jan 2008 Posts: 3
|
|
Posted: Tue Oct 07, 2008 11:51 am |
|
|
I tried running the board stand alone and it still won't run right. I was able to set the wdt for sleep mode (divide by 1) then changed it to 2304MS and it was running right, I still wasn't able to set timer1 correctly but I only needed to get the timing right. Now I'm back to the drawing board.... As soon as I press the "run" button, it goes back to sleep, even though I attempt to clear the wdt numerous times in the ISR...... That, and MPLAB is just a pain in the neck, hanging up my computer, watching the hourglass for 5 minutes at a time, etc...... I don't know if this is a MPLAB thing or what..... Maybe I'll try running out of the CCS IDE..... |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Oct 07, 2008 11:59 am |
|
|
Post a very short program that demonstrates the problem. Here's an
example of what I mean:
http://www.ccsinfo.com/forum/viewtopic.php?t=28158&start=8
It's super short, and it shows how to wake up from sleep with Timer1.
The program that you post must be compilable without errors. It must
have the #include, #fuses, #use delay(), main(), variable declarations,
etc. Don't put in any Wizard code that is unrelated to demonstrating
the problem. i.e., don't put in code to setup the A/D, when your
problem is about the WDT. Most importantly, the program must be short. |
|
|
|
|
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
|