View previous topic :: View next topic |
Author |
Message |
hello188
Joined: 02 Jun 2010 Posts: 74
|
WDT not working on PIC16F723A |
Posted: Wed Nov 23, 2011 8:28 am |
|
|
Code: | #INCLUDE<16F723A.h>
#FUSES WDT, HS, NOPLLEN,BORV25, PROTECT
#USE DELAY(clock = 4000000)
#USE FAST_IO(ALL)
void main(void){
setup_WDT(WDT_18MS);
delay_ms(500);
while(1){
output_bit(PIN_B0, !input(PIN_B0));
delay_ms(250);
}
} |
The code should never reach while(1) part because WDT should reset it during the delay portion. however, it still goes to while(1) to toggle the port pin. I don't know if it is compiler error? or am I doing something wrong? I am using compiler version 4.127 Thanks |
|
|
RF_Developer
Joined: 07 Feb 2011 Posts: 839
|
|
Posted: Wed Nov 23, 2011 9:00 am |
|
|
You're using fast io, but you don't set any io pins to output. That means your pin won't toggle. So therefore I'm wondering how you know its got into the while loop. Must be you're using a debugger. I have a very strong feeling that the watchdog is disabled automatically while debugging....
So how are you determining what's happening?
While the CCS compiler certainly has some bugs. and they can be pretty annoying, it should hardly be the first call for program malfunctions. Put another way, always assume you've made the error until you've proved beyond any doubt that you haven't. I've found CCS bugs, and noted changes, but I've tested and tested until I'm absolutely sure I can blame the compiler before ever mentioning it to anyone. I know my programs contain my bugs: some of them really subtle, some of them downright stupid programming 101 head-palm [spam]-ups, but at least I'm sure they are all mine.
RF Developer |
|
|
hello188
Joined: 02 Jun 2010 Posts: 74
|
|
Posted: Thu Nov 24, 2011 7:23 am |
|
|
Sorry, It was curtailed version of the original program. The original program sets the pins as output using set_tris function.
I found the problem was that I compiled the code using DEBUG option on MPLAB IDE. Changing that to RELEASE solved the problem.
Thank you for your attention. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9229 Location: Greensville,Ontario
|
|
Posted: Thu Nov 24, 2011 10:59 am |
|
|
hello188
You can have MPLAB default the build configuration to 'release' instead of 'debug'. |
|
|
|