|
|
View previous topic :: View next topic |
Author |
Message |
Plater
Joined: 21 Feb 2013 Posts: 8
|
12LF1822 trouble after sleep, watchdog never fires? [Solved] |
Posted: Thu Feb 21, 2013 11:44 am |
|
|
CCS compiler 4.140
I am working with the pic 12LF1822 and I cannot seem to get the watchdog system to work.
I feel like I must be missing something really simple, since I have seen nothing else about it.
Now excusing that the pic wizard doesn't produce compilable code for the watchdog (it tires to use the wrong constants that are not available).
I made this dirt simple example to show that the PIC never wakes up from the sleep call.
Sample code:
Code: |
#include <12LF1822.h>
#device ICD=TRUE
#device adc=16
#FUSES INTRC_IO //Internal RC Osc, no CLKOUT
#FUSES WDT_SW //No Watch Dog Timer, enabled in Software
#FUSES PUT //Power up Timer
#FUSES PLL_SW //4X HW PLL disabled, enabled in Software
#FUSES DEBUG //Debug mode for use with ICD
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#use delay(clock=500000)
#define LED_LIGHT_PIPE PIN_A4
void main()
{
setup_oscillator(OSC_500KHZ | OSC_INTRC | OSC_PLL_OFF );
output_low(LED_LIGHT_PIPE);//turns LED off
setup_wdt(WDT_ON|WDT_8S);//Turn watchdog on, scaler should = 8ms, WDT_ON and WDT_8S are in the .h
sleep();//The pic never wakes back up
setup_wdt(WDT_OFF);
output_high(LED_LIGHT_PIPE);//turns LED on
for(;;)
{//never ending loop
delay_ms(100);
}
}
|
I have also tried using #FUSE WDT and not setting anything in software
(Defaults to a 2s time).
So far the only way I have found to wake it up is with INT_EXT or INT_AD (With AD set to use internal clock ONLY, otherwise it doesn't work).
I really need to be able to put the pic to sleep, I need the power savings.
Does anyone have working code to put this PIC asleep AND have it wake up from the watchdog?
Last edited by Plater on Thu Feb 21, 2013 1:11 pm; edited 1 time in total |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Feb 21, 2013 12:09 pm |
|
|
Quote: | I feel like I must be missing something really simple
|
It's because you have these two fuses:
Quote: |
#device ICD=TRUE
#FUSES DEBUG |
If the compiler sees either one of those, it shuts off WDT, PROTECT,
and BROWNOUT. Your ICD unit doesn't allow those in debug mode,
so the compiler helpfully shuts them off for you. Unfortunately it
doesn't warn you that it has done this. CCS really ought to add that
feature.
This information about some features not being allowed in Debug mode
is buried in the ICD2 help file in MPLAB. Search for "Requirements for
debug mode". |
|
|
Plater
Joined: 21 Feb 2013 Posts: 8
|
|
Posted: Thu Feb 21, 2013 1:10 pm |
|
|
You are correct, I removed those two lines and the watchdog fired as desired.
I came from using the PIC18F6527 which didnt seem to care about that.
I was using the watchdog just fine with:
Code: |
#include <18F6527.h>
#device ICD=TRUE
#device adc=8
#FUSES WDT //Watch Dog Timer
#FUSES WDT4096 //Watch Dog Timer uses 1:4096 Postscale
#FUSES INTRC_IO //Internal RC Osc, no CLKOUT
#FUSES NODEBUG //No Debug mode for ICD(*)
|
Honestly, I never even knew what that #device ICD=TRUE was doing, I was just carrying it over.
Thanks! |
|
|
|
|
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
|