|
|
View previous topic :: View next topic |
Author |
Message |
bgpartri Guest
|
Sleep on 18F452 |
Posted: Mon Aug 25, 2003 4:43 pm |
|
|
I am trying to set my 18F452 to sleep until it gets an interrupt on INT_EXT. While it is sleeping, I would like to update the time so I know the time when wake up. I tried the following code, but it doesn't go back to sleep:
void int_timer1_isr(void){
set_timer1(MS_250);
if (state == SLEEPING){
sleep();
} else {
......
I want to wake up with something like this:
void int_ext_isr(void)
{
if (state == SLEEPING){
state = MAINTAIN;
just_woke_up = TRUE;
} else {
disable_interrupts(INT_EXT);
button1_debounce_count = 1;
};
}
}
I am going to sleep with the following code:
state = SLEEPING;
//disable_interrupts(INT_TIMER1);
sleep();
If I disable the TIMER1 interrupt, it stays asleep, and even the INT_EXT won't wake it up.
It feels like I'm really missing something here.
___________________________
This message was ported from CCS's old forum
Original Post ID: 144517242 |
|
|
bgpartri Guest
|
Re: Sleep on 18F452 |
Posted: Mon Aug 25, 2003 5:50 pm |
|
|
:=I am trying to set my 18F452 to sleep until it gets an interrupt on INT_EXT. While it is sleeping, I would like to update the time so I know the time when wake up. I tried the following code, but it doesn't go back to sleep:
:=
:=void int_timer1_isr(void){
:= set_timer1(MS_250);
:= if (state == SLEEPING){
:= sleep();
:= } else {
:=......
:=
I managed to fix it myself. First, it doesn't like going to sleep in a ISR apparently. It really shouldn't matter, since sleep just stops the clock. But I moved the sleep to my mainline, and now it works.
INT_EXT not waking up was a logic error. I disable the interrupts to do a debounce, but didn't enable them after I used the same button to set the sleep state.
:=I want to wake up with something like this:
:=
:=void int_ext_isr(void)
:={
:=if (state == SLEEPING){
:= state = MAINTAIN;
:= just_woke_up = TRUE;
:= } else {
:= disable_interrupts(INT_EXT);
:= button1_debounce_count = 1;
:= };
:= }
:=}
:=
:=I am going to sleep with the following code:
:=
:=state = SLEEPING;
:=//disable_interrupts(INT_TIMER1);
:=sleep();
:=
:=If I disable the TIMER1 interrupt, it stays asleep, and even the INT_EXT won't wake it up.
:=
:=It feels like I'm really missing something here.
:=
___________________________
This message was ported from CCS's old forum
Original Post ID: 144517244 |
|
|
|
|
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
|