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

12F683 Undefined indentifier WDT_1152MS

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



Joined: 06 May 2009
Posts: 3

View user's profile Send private message

12F683 Undefined indentifier WDT_1152MS
PostPosted: Wed May 06, 2009 10:25 am     Reply with quote

Hi,

I use PCM Compiler V4.004 to complile my code for PIC12F683.
I got "Undefined identifier WDT_1152MS on this line:
setup_wdt( WDT_1152MS );

The same code compilers if I change header file from 12F683.h to 16F73.h.

Could anybody help me with this?

Thanks in advance.

Jeff
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed May 06, 2009 10:30 am     Reply with quote

That's a very early version and shouldn't be used for anything.
But, look in the 12F683.h file to see if WDT_1152MS is defined there.

It's also possible that you didn't construct the program properly.
The #include file for the PIC goes at the top of the program.
Don't just put a #device statement there. Example:
Code:
#include <12F683.h>
#fuses INTRC_IO, WDT, MCLR, PUT, BROWNOUT
#use delay(clock=4000000)

//=============================
void main()
{
setup_wdt(WDT_1152MS);

   
while(1)
  {
   restart_wdt();
  }
 
}
 
embedded123



Joined: 06 May 2009
Posts: 3

View user's profile Send private message

PostPosted: Wed May 06, 2009 10:38 am     Reply with quote

Thanks for your quick reply.

I checked 12F683.h, here is the snip:
Quote:
////////////////////////////////////////////////////////////////// WDT
// Watch Dog Timer Functions: SETUP_WDT() or SETUP_COUNTERS() (see above)
// RESTART_WDT()
//
#define WDT_ON 1
#define WDT_OFF 0

#define WDT_DIV_32 1
#define WDT_DIV_64 3
#define WDT_DIV_128 5
#define WDT_DIV_256 7
#define WDT_DIV_512 9
#define WDT_DIV_1024 11
#define WDT_DIV_2048 13
#define WDT_DIV_4096 15
#define WDT_DIV_8192 17
#define WDT_DIV_16394 19
#define WDT_DIV_32768 21
#define WDT_DIV_65536 23


In 16F73.h, it is this:
Quote:
///////////////////////////////////////////////////////////////// WDT
// Watch Dog Timer Functions: SETUP_WDT() or SETUP_COUNTERS() (see above)
// RESTART_WDT()
//
#define WDT_18MS 8
#define WDT_36MS 9
#define WDT_72MS 10
#define WDT_144MS 11
#define WDT_288MS 12
#define WDT_576MS 13
#define WDT_1152MS 14
#define WDT_2304MS 15


What should I do?

Regards,

Jeff







PCM programmer wrote:
That's a very early version and shouldn't be used for anything.
But, look in the 12F683.h file to see if WDT_1152MS is defined there.

It's also possible that you didn't construct the program properly.
The #include file for the PIC goes at the top of the program.
Don't just put a #device statement there. Example:
Code:
#include <12F683.h>
#fuses INTRC_IO, WDT, MCLR, PUT, BROWNOUT
#use delay(clock=4000000)

//=============================
void main()
{
setup_wdt(WDT_1152MS);

   
while(1)
  {
   restart_wdt();
  }
 
}
 
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed May 06, 2009 10:53 am     Reply with quote

Copy and paste the definitions from the 16F73.h file into the 12F683.h file.

But be aware that vs. 4.004 is complete junk. (As you can see from the
missing #defines). It didn't become stable until months later. I don't
really want to answer any more questions on it.
embedded123



Joined: 06 May 2009
Posts: 3

View user's profile Send private message

PostPosted: Wed May 06, 2009 11:00 am     Reply with quote

Thanks for answering my question.
Ttelmah
Guest







PostPosted: Thu May 07, 2009 2:21 am     Reply with quote

Just think for yourself....
The 'point' is that the watchdog, only ever actually supports 'divisors'. The 'times' that result from these, are very variable. As a convenience, on some chips, CCS calculated the (suupposed) time that the particular divisors give, and include constants for these in the include file, but it is always really better, and safer, to read the data sheet, and work out for yourself, what divisor you need, and what the minimum time is that this will equate to.
Now, the 'default' core time for the watchdog, is 17mSec on these chips. So the divisors give:
WDT_DIV_32 544mS
WDT_DIV_64 1088mS
WDT_DIV_128 2176mS
WDT_DIV_256 4352mS
WDT_DIV_512 8704mS
WDT_DIV_1024 17408mS

These are all approximate, so (for example), WDT_DIV_64, gives a minimum of 640mSec, to a maximum of 1920mSec.
You will note that _none_ correspond to a nominal 1152mSec.

Don't use the constants for the 16F73. This has a completeley different watchdog, with different timings supported, and different constants needed. The 683, can't actually give this time, with the 'closest' being using the /64 or /128 dividers.

So, think for yourself, chose the divisor that _in it's worst case_, exceeds the shortest period at which you will refresh the watchdog, and even on chips that offer these 'time' values, do not rely on them, but read the data sheet, and be sure you know what the times really may be....

As a further comment though, as PCM has already said, 4.004, will be unlikely to give working code. Read the V4 thread at the top of the forum. At 4.004, the compiler was (fit own rude word here...).

Best Wishes
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Thu May 07, 2009 4:13 am     Reply with quote

I also considered to answer something similar as Ttelmah, that the 12F683 has different registers than the 16F673 and you should use the constants provided with the 12F683.h file. Then I realized, that during the various V4.xxx iterations the coding of setup_wdt() and the *.h file constants apparently have been changed. I checked the code from a recent PCM version, and I must confess, that I don't understand at first sight what they are doing now. I know, that with PCM V3.xxx the 12F watchdog has been programmed by using WDT_DIV_xxx constants, which would the obvious and direct way to my opinion. Now they are doing something different, also involving the prescaler.

I'm not using PCM V4.xxx up to now due to several changes that are incompatible with existing projects, the WDT programming seems to be one of these.
Ttelmah
Guest







PostPosted: Thu May 07, 2009 8:54 am     Reply with quote

Worse though, they have obviously not read the data sheet.....
They give a 18mSec watchdog a the lowest setting, while on the 683, the default shortest watchdog 'time', is 17mSec, with a minimum of 10mSec, and max of 30mSec. The basic watchdog interval is shorter than on most chips.
The newer compiler do still accept the smaller divisor values though, so these are 'standard', and the better way to go. Smile
It is really symptomatic of the CCS 'attitude', of trying to hide the hardware. When they hide the settings, and then get them wrong, it is a bit of a pain.

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