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 support@ccsinfo.com

PIC10F200 Watchdog Timer tripping

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



Joined: 21 Feb 2008
Posts: 24

View user's profile Send private message

PIC10F200 Watchdog Timer tripping
PostPosted: Tue Aug 10, 2010 8:01 am     Reply with quote

I am trying to use the 10F200 to simply wakeup on a change in state on PIN_B2 or PIN_B3 and set PIN_B0 and PIN_B1 high for one second. However, I am never waking up on a pin change in state. But I am waking up every 3.82 seconds due to the Watchdog Timer Timeout.

I am powering the PIC with 2.5V.
I have PCB compiler V4.099.

I have nothing connected to PIN_B1 or PIN_B0 except scope probes. On PIN_B2 and PIN_B3 I have a N-Fet that pulls the input low when the fet is turned on. Otherwise there is a 10.0Meg pullup resistor keeping the inputs high. I have 10.0Meg pullup and not something smaller so my current draw is as small as possible.

Also, when I pull PIN_B3 low, the Watchdog Timer no longer time's out but I also don't wake up from pin change.

Code:
#include <10F200.h>

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES NOMCLR                   //Master Clear pin used for I/O
#FUSES NOPROTECT                //Code not protected from reading

#use delay(clock=4000000)


#define OUTPUT_0      PIN_B0
#define OUTPUT_1      PIN_B1
#define DIGITAL_INPUT_1   PIN_B3
#define DIGITAL_INPUT_2   PIN_B2

#define set_options(value)   {#ASM         \
                              MOVLW  value \
                              OPTION       \
                              #ENDASM}
                             
#byte osccal = 0x05
#byte gpio = 0x06

void main()
{
   int8 cause;
   int8 state_1;
   int8 state_2;
   
   cause = restart_cause();
   set_options(0x5F);      //turn off weak pull-ups, enable wake on pin change
   osccal = osccal & 0xfe;
   gpio = 0x0C;
   
   set_tris_b(0b00001100);      //set GPIO - B0 output and B1, B2,B3 inputs
   
   output_low(OUTPUT_0);
   output_low(OUTPUT_1);
   
   while(1){
      state_1 = input(DIGITAL_INPUT_1);   //initial input check
      state_2 = input(DIGITAL_INPUT_2);
      delay_ms(100);               //debounce

      if(cause==PIN_CHANGE_FROM_SLEEP){   
         if( (state_1 == input(DIGITAL_INPUT_1)) || (state_2 == input(DIGITAL_INPUT_2)) ){   //it wasn't noise
            output_high(OUTPUT_0);
            output_high(OUTPUT_1);
            delay_ms(1000);
         }
      }
      if(cause==WDT_FROM_SLEEP){
         delay_ms(100);
         output_high(OUTPUT_0);
         output_high(OUTPUT_1);
         delay_ms(100);
         output_low(OUTPUT_0);
         output_low(OUTPUT_1);
         delay_ms(100);
         output_high(OUTPUT_0);
         output_high(OUTPUT_1);
         delay_ms(100);
         output_low(OUTPUT_0);
         output_low(OUTPUT_1);
      }
   
      output_low(OUTPUT_0);
      output_low(OUTPUT_1);

      //read inputs right before sleep
      state_1 = input(DIGITAL_INPUT_1);
      state_2 = input(DIGITAL_INPUT_2);
      sleep();         
   }
}
PCM programmer



Joined: 06 Sep 2003
Posts: 18255

View user's profile Send private message

PostPosted: Tue Aug 10, 2010 11:41 am     Reply with quote

Quote:
#include <10F200.h>

#FUSES NOWDT //No Watch Dog Timer
#FUSES NOMCLR //Master Clear pin used for I/O
#FUSES NOPROTECT //Code not protected from reading

#use delay(clock=4000000)

But I am waking up every 3.82 seconds due to the Watchdog Timer Timeout.

Your #fuses are set for NOWDT. How can the PIC be waking up from
WDT if it's not enabled ? Check your programmer (ICD, ICD2, etc).
Is it working correctly ? Run a 'Verify' operation on the PIC after you
have programmed it. Is it correct ? Does it show NOWDT was actually
set in the PIC ?
ntgcp_08



Joined: 21 Feb 2008
Posts: 24

View user's profile Send private message

PostPosted: Tue Aug 10, 2010 12:39 pm     Reply with quote

That is the issue, I don't want to wake up from the WDT. I am using an ICD2 and MPLAB v8.15 to program the part.

I just got everything working but can someone explain how?...

In MPLAB, under configure, configuration bits, I have the "Configuration Bits set in code" box checked. Therefore the fuses I have set in my code will be used and not the MPLAB settings. In MPLAB, The grayed out settings for the config bits are Watchdog Timer On, Code Protect Off, and Master Clear Enable Functions as Master Clear. However, If I program the board, the WDT is active and the MCLR is not acting as a digital input.

I then unchecked the "Configuration Bits set in code" box and change the config bits to Watchdog Timer Off, Code Protect Off, and Master Clear Enable Functions as GP3. Then I once again checked the "Configuration Bits set in code" box and the config bits became grayed out again but stayed as Watchdog Timer Off, Code Protect Off, and Master Clear Enable Functions as GP3. I then programed my chip and everything works as it should.

It appears no matter if I have the "Configuration Bits set in code" check box checked or unchecked it is still using the values set by MPLAB.

Either, I have it working now. Thanks for your input.
PCM programmer



Joined: 06 Sep 2003
Posts: 18255

View user's profile Send private message

PostPosted: Tue Aug 10, 2010 12:58 pm     Reply with quote

It's possibly an MPLAB bug. Or it could be due to your 2.5v Vdd voltage.
I'm not sure.
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