WDT and continuation of the program PIC32MX795F512L

General discussion on mikroC PRO for PIC32.
Post Reply
Author
Message
umbertomori
Posts: 45
Joined: 06 Feb 2018 11:48
Contact:

WDT and continuation of the program PIC32MX795F512L

#1 Post by umbertomori » 07 Sep 2021 12:51

Hi
i use WDT for weak-up from sleep the PIC32 micro.

I use WDT for continuation program, not for restart micro (for save energy).

I use istructions:

if(RCON & 0x18)asm eret;
(see manual Microchip page 4)

The system is unstable, sometimes it freezes on startup and freezes if I press the reset button.
What can it be?
Thanks

My simple test program:
(1 flash led if pressed button or start WDT every 4 seconds)



//******************************************************************************
//For weak-up if pressed button
//******************************************************************************
void INT0_Interrupt() iv IVT_EXTERNAL_0 ilevel 7 ics ICS_SRS
{
//IFS0.B3=0; //INT0IF_bit
IFS0bits.INT0IF=0;
}



//******************************************************************************
//
//******************************************************************************
void main()
{
Delay_ms(100);
if(RCON & 0x18)asm eret;//start for execution program if wdt

AD1PCFG = 0xFFFF; // Configure AN pins as digital I/O
JTAGEN_bit = 0; // Disable JTAG

//Disabilita comparatori
CM1CON.B15=0;
CM2CON.B15=0;

//Set In/Out
TRISG14_bit=0; //Buzzer
TRISG15_bit=0; //Led
TRISG12_bit=0; //Led
TRISD0_bit=1; //Button


//Set INT0 (external button from H to L level)
INT0IP0_bit=0; //Set INT0 interrupt
INT0IP1_bit=0; //priority
INT0IP2_bit=1; //to 4
INT0EP_bit =0; //falling edge
INT0IE_bit =1; //Set interrupt

DisableInterrupts();

Beep(3,250);


while(1)
{
Clear_WDT();
Led_Int=1;
Delay_ms(1000);
Led_Int=0;
Delay_ms(50);

EnableInterrupts();
asm wait;
DisableInterrupts();
wdt.pdf
(162.69 KiB) Downloaded 41 times
}
}

Umberto Italy

User avatar
Tanja_Kovacevic
mikroElektronika team
Posts: 98
Joined: 09 Aug 2021 11:39

Re: WDT and continuation of the program PIC32MX795F512L

#2 Post by Tanja_Kovacevic » 09 Sep 2021 15:48

Hi Umberto,

Since you opened the ticket with the same question,
we will continue the conversation via e-mail
due to the simpler exchange of files, images, etc.

Kind regards,
Tanja

Post Reply

Return to “mikroC PRO for PIC32 General”