i have a simple project which mis-uses the watchdog timer in a 12F509 to produce eye-catching warning flashes;my question is how do i get more control other than just enabling the WDT in the config's and ducking for cover ?
the only forum example was,i think,for a 18F part.adding the 'c code' block threw up errors because the registers are not the same in baseline parts...
before my flaky internet drops out again ; does anybody have any examples of using a single tact. switch to turn on and off a PIC either off completely or just into power saving sleep (12F509 target powered from button cell)
control over WDT timeout
Moderator: Benj
-
- Posts: 26
- Joined: Mon Apr 17, 2017 9:55 pm
- Has thanked: 2 times
- Been thanked: 14 times
- Contact:
-
- Posts: 26
- Joined: Mon Apr 17, 2017 9:55 pm
- Has thanked: 2 times
- Been thanked: 14 times
- Contact:
Re: control over WDT timeout
specifically adding the following C block
option_reg = option_reg | 0b00001111; //Configure watchdog to 1:128 Postscaler
wdtcon = 0b00000111; //Configure watchdog 1:256 Prescaler, Software Watchdog enabled
produces a C file but wont produce a hex file; throwing the following errors:-
option_reg = option_reg | 0b00001111; //Configure watchdog to 1:128 Postscaler
wdtcon = 0b00000111; //Configure watchdog 1:256 Prescaler, Software Watchdog enabled
produces a C file but wont produce a hex file; throwing the following errors:-
- Attachments
-
- error code.PNG
- (6.12 KiB) Downloaded 2301 times
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: control over WDT timeout
Hi hackinblack,
Within 12F509 The register you are referring to as option_reg is just called OPTION.
However within 12F509 this register is Write only!
So instead ofyou must use instead
All this information can be found within the 12F509 datasheet.
You should also add C code block with a command to reset the watchdog timer:
Use Auto clear watchdog in project options.
I would not recommend using the 12F509, you will be facing several stack and memory issues as this chip is now outdated.
I would recommend using 12F1840 instead as its much superior with heaps more stack and memory and it runs of it's internal oscillator at a maximum speed of 32MHz!
With Flowcode V7 and above, registers are all in upper case.hackinblack wrote:option_reg = option_reg | 0b00001111; //Configure watchdog to 1:128 Postscaler
Within 12F509 The register you are referring to as option_reg is just called OPTION.
However within 12F509 this register is Write only!
So instead of
Code: Select all
OPTION = OPTION | 0b00001111;
Code: Select all
OPTION = 0b00001111;
The way the values of watchdog timer gets altered is by setting the 3 lower bits of OPTION register as WDTCON does not exist within 12F509.hackinblack wrote:wdtcon = 0b00000111;
All this information can be found within the 12F509 datasheet.
You should also add C code block with a command to reset the watchdog timer:
Code: Select all
MX_CLEAR_WATCHDOG;
Use Auto clear watchdog in project options.
I would not recommend using the 12F509, you will be facing several stack and memory issues as this chip is now outdated.
I would recommend using 12F1840 instead as its much superior with heaps more stack and memory and it runs of it's internal oscillator at a maximum speed of 32MHz!
Martin
-
- Posts: 26
- Joined: Mon Apr 17, 2017 9:55 pm
- Has thanked: 2 times
- Been thanked: 14 times
- Contact:
Re: control over WDT timeout
i quite agree; the newer little PICmicro's are incredible,but these are a tube i already have here...postage here is eye-watering like 15 euros for 1 chip
the use of upper case is partly what threw me and the differences between 12F and 18F registers;i foolishly tried to change as little as possible to get something going i actually wanted the WDTtimer to jump in,as it makes a more eye-catching blink.it now functions as intended!
thanks sooo much for the help. next time i may be forced to read the datasheet...
the use of upper case is partly what threw me and the differences between 12F and 18F registers;i foolishly tried to change as little as possible to get something going i actually wanted the WDTtimer to jump in,as it makes a more eye-catching blink.it now functions as intended!
thanks sooo much for the help. next time i may be forced to read the datasheet...
-
- Posts: 26
- Joined: Mon Apr 17, 2017 9:55 pm
- Has thanked: 2 times
- Been thanked: 14 times
- Contact:
Re: control over WDT timeout
other then removing a 'NOP' at the end of the sleep command;which doesn't seem to do anything...?it seems to work OK.
pity i can't test its current draw; as its running direct from a PICkit2.
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: control over WDT timeout
At least you are sorted for now?
All the best.
Ouch, that does seem very steep!hackinblack wrote:postage here is eye-watering like 15 euros for 1 chip
Not a problem, I try and help when I can.hackinblack wrote:thanks sooo much for the help.
All the best.
Martin