|
|
View previous topic :: View next topic |
Author |
Message |
young
Joined: 24 Jun 2004 Posts: 285
|
wake up from sleep |
Posted: Fri Nov 12, 2004 1:49 pm |
|
|
when I see the device file for PICs, I found that there is several restart_cause() returns,
Quote: |
#define WDT_FROM_SLEEP 0
#define WDT_TIMEOUT 8
#define MCLR_FROM_SLEEP 16
#define NORMAL_POWER_UP 24
|
however in the datasheet for example for 16F76 for sleep wake up method
there is plenty, much more than just these four restart_cause() result to weak up from sleep, like
1. External Reset input on MCLR pin, which is MCLR_FORM_SLEEP
2.Watchdog Timer wake-up, which is for WDT_FROM_SLEEP and WDT_TIMEOUT
there is no restart_cause result related to 3.interrupt from INT pin,
,RB port change or peripheral interrupt. for example, not restart_cause() related to int_RDA.
all these method could cause weak up at the same time, can i check which one caused wake up? like
Code: |
switch (restart_cause())
{
case NORMAL_POWER_UP:
printf("Normal power up!\r\n");
break;
case WDT_FROM_SLEEP:
break;
}
|
in the above code, NORMAL_POWER_UP and WDT_FROM_SLEEP tell which one is in function |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Fri Nov 12, 2004 2:09 pm |
|
|
restart_cause
Quote: | A value indicating the cause of the last processor reset. The actual values are device dependent. |
Quote: | there is no restart_cause result related to 3.interrupt from INT pin,
,RB port change or perpherial interrupt. for example, not restart_cause() related to int_RDA.
|
None of these cause a processor "reset". They will "wake" a processor from sleep but this is NOT a reset. Thus the reason why they are not in the restart_cause. |
|
|
young
Joined: 24 Jun 2004 Posts: 285
|
|
Posted: Fri Nov 12, 2004 2:25 pm |
|
|
Do you mean that if the processor is in sleep, anything, like interrupt, RB pin will weak up the sleep mode right?
I have following code.
Code: |
#if defined(__PCM__)
#include <16F76.h>
#fuses XT,WDT,NOPROTECT
//#device ADC=10
#use delay(clock=4000000)
#use rs232(baud=9600, parity=N, xmit=PIN_C6, rcv=PIN_C7)
void RDA_isr()
{
}
void main()
{
enable_interrupts(INT_RDA);
enable_interrupts(global);
while(1)
{
sleep();
output_high(PIN_A2);
delay_ms(100);
output_low(PIN_A2);
delay_ms(100);
}
when I run the program, the PIN_A2 is alway blinking, and it is not in sleep, and When the send a inturrupt, PIN_A2 stop blink, I feel kinds of weired, shoud be opposite, right? please help me out |
|
|
|
young
Joined: 24 Jun 2004 Posts: 285
|
|
Posted: Fri Nov 12, 2004 2:51 pm |
|
|
I think I used the wrong fuse
#fuses XT,WDT,NOPROTECT should be
#fuses XT,NOWDT,NOPROTECT
but by this way, the int_rda does nor weak up the sleep mode? how to setup to use ther external int_RDA correctly? |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Fri Nov 12, 2004 3:13 pm |
|
|
We have already told you in the other post that you CAN'T wake up through the rda int. If the device has the EUSART then yes. Furthermore, you could use the external int to wake up the processor. Also, you aren't handling the uart data so you will get a buffer overrun and the receive will stop working. |
|
|
young
Joined: 24 Jun 2004 Posts: 285
|
|
Posted: Fri Nov 12, 2004 3:25 pm |
|
|
what is EUSART?
Thank you |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
|
|
|
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
|