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

WDT WatchDog Questions?

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








WDT WatchDog Questions?
PostPosted: Wed Mar 19, 2008 3:18 am     Reply with quote

Hi,

I would like to know, How I can calculate the time-out period? my pic is a PIC16F688,I do not understand that the time-out period for each Prescale Rate.

I think:
Bit Value = Prescale Rate -->c
0000 = 1:32 -->equals 1ms
0001 = 1:64 -->equals ???????
0010 = 1:128 -->equals ???????
0011 = 1:256 -->equals ???????
0100 = 1:512 (Reset value) -->equals ???????
0101 = 1:1024 -->equals ???????
0110 = 1:2048 -->equals ???????
0111 = 1:4096 -->equals ???????
1000 = 1:8192 -->equals ???????
1001 = 1:16384 -->equals ???????
1010 = 1:32768 -->equals ???????
1011 = 1:65536 -->equals 268 seconds


Please me a good answer to this question.

Best Regars
Guest_7068
Guest







PostPosted: Wed Mar 19, 2008 4:49 am     Reply with quote

You must note that this version of the chip has 2 scalers.
Option_Reg : This is a standard pre-scaler that allows scaling of the WDT from 1:1 to 1:128

WDTCON : This register allows additional pre-scaling of the WDT from 1:32 to 1:65536

The WDT runs off a 31 Khz Internal Oscillator, so the lowest WDT period value you get is 31 Khz /32 ~= 1ms

The default value (RESET value) is
Option_Reg = 1:1
WDTCON = 1:512
This will give you a rate: 31 Khz / 512 = 16ms

Now, understanding the CCS options is a little tricky as they have to keep the old chip and new chip options compatible. so they use the following method:
Code:

SETUP_WDT(WDT_18MS | WDT_DIV_16);


WDT_18MS --> This is the old constant which sets up the chips which have only 1 prescaler
WDT_DIV_16 --> This will mean that 18 ms DIV by 16 ~= 1ms

Now, if you want to setup the defult value of 16 ms, you will use:
Code:

 SETUP_WDT (WDT_18MS | WDT_TIMES_1); // 18 ms * 1 --> This is logically close to 16 ms


Similarly, if you want to set the highest timeout period of 268 seconds you will use
Code:

SETUP_WDT(WDT_2304MS | WDT_TIMES_128); // This will actually mean 2304 * 128 = 292 seconds which is logically close to 268 seconds


So, depending on the period you want, you can do a simple math like WDT_xxMS | WDT_TIMES_X (or WDT_DIV_X), which will give you a number close to the actual value.
Guest








PostPosted: Wed Mar 19, 2008 5:15 am     Reply with quote

Hi, thanks for your response,

I configure the WDTCON = 0x10, for the pre-escaler 1/8192 this watchdog time period is big aprox. 8seg or more. I think that the time period for 1/65536 correspond the 268sec, and 1/4096 the 1sec. I would like to know how calculate these values.



Code:
#include <16F688.h>
#device ADC=10
#fuses INTRC_IO,WDT,NOMCLR,NOPROTECT, BROWNOUT,NOPUT
#use delay(clock=4000000)
#use STANDARD_IO(C)
#BYTE OSCCON = 0x8F  //endereço do OSCCON register
#BYTE WDTCON = 0x18 //endereço do WDTCON

void main(void) {
   float VPS,VBAT;

   OSCCON=0x61;  //Configuração do registo OSCCON 4MHZ, 71->8MHZ
   WDTCON = 0x10; //Configuração do wdt para preescales 1:8192 >

 //  setup_adc_ports(3);
 //  setup_adc(ADC_CLOCK_DIV_16);

   setup_adc_ports(3);
   setup_adc(ADC_CLOCK_DIV_16);  //4us por amostra

      delay_ms(1000); //1s
   delay_ms(1000); //1s
   delay_ms(1000); //1s

   output_high(PIN_A5);//

  while (true)
   {
             restart_wdt();
.................

}}



Best Regards
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