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.

[PIC] Variable status after Wake up from sleep - 10F200

Status
Not open for further replies.

vijitron

Newbie level 6
Newbie level 6
Joined
Feb 22, 2009
Messages
12
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,366
Hi all

What will happen to the variables value (RAM) when i wakeup from sleep of 10F200 controller?

Will the value remains unchanged or totally it will resets from the beginning of the code?

I am using Hitech C 9.60 PL3 for 10F200 , after sleep the change in state of pin wakes up the controller

i lost the variable value. Is this the nature of the controller?
 

Hello,

The variables will be unchanged. In Sleep mode, the operation of a PIC microcontroller is suspended and the clock oscillator is switched off. The power consumption will be low how ever the status of the ports will be maintained. The device can be waked up by a watch-dog timer reset, an interrupt on INT0 pin, or port-on-change interrupt.

enjoy!!!
 

It looks to me that wakeup performs a normal reset.

If your code does not take this into account you will have a normal power on reset executed, and if the memory is reset you loose your content.

To fix it you need to check the status for the active wakeup flag, before performing a system init. If you see a wakup condition you leave the memory as it is.
 

It looks to me that wakeup performs a normal reset.

If your code does not take this into account you will have a normal power on reset executed, and if the memory is reset you loose your content.

To fix it you need to check the status for the active wakeup flag, before performing a system init. If you see a wakup condition you leave the memory as it is.

Hi Gorgon
I edited the code and removed the initialization at all . I am only declaring the variable in global.

This 10F200 controller dont have ISR, Now where to POLL the GPWUF flag (this flag is Reset flag /Wakeup Flag)

below is my code, tmCnter is reseting to 0 after wakeup.

Is my Polling of GPWUF is right?


Code:
#include <htc.h>
#define _XTAL_FREQ 4000000
__CONFIG(0x0feb);//(MCLRDIS |WDTDIS | UNPROTECT);


//Macros
#define DURATION 37//1200//28800		60sec * 60min=3600 sec /hour , counting every 1.5secs --> 3600/1.5=2400



//Global Variables
unsigned char i=0;
unsigned char Mode=0;
unsigned int tmCnter; 
void main()
{
  
OSCCAL=0b00001010;
OPTION=0b00000000;
TRIS  =0b00000001;
Mode=1;

if(GPWUF)
{
	GPWUF=0;
	
}
else
{
tmCnter=0;
}

	GPIO=0x04;
	
	__delay_ms(100);
	
	TRIS=0x01;
	__delay_ms(5);
	GPIO=0;
		tmCnter++;

	while(1)
	{

	tmCnter++;
	__delay_ms(100);
	if(tmCnter>5 && tmCnter<10)
	{
	

		__delay_ms(100);
		i=GPIO;
		#asm
		sleep
		#endasm
	}
	else if(tmCnter>10)
	{
		GPIO=0x04;
		__delay_ms(50);
		GPIO=0x00;
		__delay_ms(50);
	}


//	if(!(GPIO & 0x01))
//	{
//		Mode=2;
//		tmCnter=0;		//Clear the timer when the tilt switch pressed
//	}
//	if(tmCnter>DURATION)	//Wait or 12hrs 
//	{
//		Mode=2;	//after 12hrs change the mode to 2
//		
//	}
// 
//	
//	switch (Mode)
//	{
//		
//		case 1:
//				TRIS=0x01;
//				GPIO=0x0F;
//				__delay_ms(20);
//				GPIO=0x00;
//				
//				tmCnter++;
//				TRIS=0x03;
//				#asm 
//				sleep
//				#endasm
////				for(i=15; i>0; i--)
////				{
////					__delay_ms(100);
////				}
//				break;
//		case 2:
//				GPIO=0x0F;
//				__delay_ms(10);
//				GPIO=0x00;
//				__delay_ms(150);
//				GPIO=0x0F;
//				__delay_ms(10);
//				GPIO=0x00;
//				for(i=15; i>0; i--)
//				__delay_ms(100);
//				break;
//		
//				
//	}//End Switch

		
	

	}//End while(1)

}//End Main
	

//}
 

I don't know this compiler at all, but your use of 'GPWUF' implies that this is some sort of macro. Since GPWUF is bit7 in the STATUS register, I would have thought STATUS would have been a part of the expression. Since the definition is not listed I have no idea if your code is correct or not. Logically it looks ok, but as said I don't know if it is ok in the syntax.
 

Hi,

after sleep the change in state of pin wakes up the controller

After reading the code you pasted I have a question where in your code "pin wakes up the controller"? there is no interrupt service routine, no watch dog timer configured? How the devices wakes up?
 

/MCLR, WDT and wakeup all execute a general reset. For the wakeup the GPWUP flag is set in the status register. The /TO and /PD flags also combines to give the current reset source.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top