Jump to content

watchdog


HawThorn
 Share

Recommended Posts

Hello,

I try to use and configure the watchdog with the mios. I read the part of the watchdog in the datasheet. And I have a look in the files of the sdcc_skeleton.

And I found this code in pic18f452.h

extern __sfr __at 0xfd1 WDTCON;
typedef union {
	struct {
		unsigned SWDTEN:1;
		unsigned :1;
		unsigned :1;
		unsigned :1;
		unsigned :1;
		unsigned :1;
		unsigned :1;
		unsigned :1;
	};

	struct {
		unsigned SWDTE:1;
		unsigned :1;
		unsigned :1;
		unsigned :1;
		unsigned :1;
		unsigned :1;
		unsigned :1;
		unsigned :1;
	};
} __WDTCONbits_t;

extern volatile __WDTCONbits_t __at 0xfd1 WDTCONbits;

but I'm not sure it's the good place to do my modification. In the WDTCON the bit 5, 6 and 7 are unimplemented (read as 0)

It's hard to found the right place of the watchdog in the sdcc skeleton.... the wathdog is more a  assembler fonction than a C.

So, where do I have to have a look to found and modify the watchdog timer period bits?

Laurent

Link to comment
Share on other sites

I have absolutly no idea what you mean with "watchdog"  :-[

but maybe three hints that may be better than no answer at all:

1. you can setup a custom timer (see C-Function Reference @uCApps.de)

2. you can change values in your code by calling the appropriate variable names (I haven't looked up the code, but if the global var is named WDTCONbits you should be able to access it's bits by WDTCONbits.SWDTE = 0; or something like that. It's a bad idea to mess around in the pic18f452.h file, cause this is just a header providing the structure that's inside the pic...

3. you can mix ASM and C code by calling __asm and __endasm; (see wiki entry in appDev: http://www.midibox.org/dokuwiki/doku.php?id=application_development   -> how to mix C and ASM.

Hope this is of some use, ;)

Best regards,

Michael

Link to comment
Share on other sites

Watchdog timer: it's configured in a way which doesn't allow to enable/disable it via software. It's always enabled, and it is serviced by MIOS within the mainloop (after USER_Tick has been called)

If USER_Tick stalls longer than 2 seconds, the PIC will be reset. If your routine needs longer (this is critical, >20 mS will cause a MIDI In buffer overrun if a bulk of data is received at the same time), than you have to issue a "clrwdt" instruction in order to service the watchdog, and to avoid a reset.

Best Regards, Thorsten.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...