Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Watchdog timer with Pic18F4550

Status
Not open for further replies.

dima82

Newbie level 1
Joined
Dec 15, 2011
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,291
Hello,

I'm trying to use WDT for power saving modes with 18f4550 micro-controller, but it seems only to go to sleep and it won't wake up.
The code is bellow. Am I doing something wrong?

#include <P18f4550.h>

int COUNTER=0xFF;

#pragma config DEBUG = ON
#pragma config ICPRT = OFF
#define NOP
#define DELAY
#define WDT

//#pragma config CONFIG2Hbits.WDTEN = ON
#pragma config WDTPS = 32768

void main(void)
{

TRISC=0;
TRISD=0;
TRISAbits.TRISA0=0;
ADCON0 = 0x01;
ADCON1 = 0x00;
ADCON2 = 0x1D;

while(1)
{
ADCON0bits.GO = 1;
while (ADCON0bits.DONE == 1);
PORTC=ADRESL;
PORTD=0xFF;
FSR0L=0x00;
LOOP: EECON1 = 0x06; //WRITE TO MEMORY
INDF0 = ADRESH;
EEDATA = INDF0;
// EEDATA = 0xFF;
EECON1bits.WREN = 1;
INTCONbits.GIE = 0;
EECON2 = 0x55;
EECON2 = 0xAA;
EECON1bits.WR = 1;
INTCONbits.GIE = 1;
EECON1bits.WREN = 0;
DELAY(250);
EEADR = FSR0L;
NOP;
NOP;
FSR0L++;
COUNTER--;
// CONFIG2H = 0x1F;
WDTCONbits.SWDTEN = 1; //enable watchdog timer
Sleep();
WDTCONbits.SWDTEN = 0; //turn off watchdog timer
if (COUNTER!=0x00)
goto LOOP;
}
}
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top