|
|
View previous topic :: View next topic |
Author |
Message |
simon630
Joined: 07 Sep 2003 Posts: 17
|
external interrupt problem |
Posted: Sun Dec 15, 2002 7:47 pm |
|
|
hi, all,
i am writing a program to wake up the processor which will normally in the sleep state. the processor will remain sleep until a change state occurs at the B0 pin.
i enable the int_ext in the main program, at the same time i disable the global interrupt so that the cpu will not be interrupted.
and then i will a loopcount to delay about 10s instead of using the timer in PCM. IE, the processor will sleep again 10s after it wakes up.
however it does not seem to work as there is an external interrupt to wake it up every time it goes to sleep. but i have made sure there is no external interrupt on pinB0. can anyone explain why?
// Since GIE disabled, the following ISR remain in case interrupt occurred
#int_rb
int_rb_isr() {}
#int_ext
void ext_isr() {}
main(){
...
ext_int_edge(l_to_h);
enable_interrupts(INT_EXT); //PBUS is interrupt to wakeup
enable_interrupts(INT_RB); //B4-B7 change interrupt (H->L)
disable_interrupts(GLOBAL); //Don't use interrupt
while(1){
.... //some switch case
sleep_count++;
if (sleep_count>100){
sleep_count=0; //Reset count before sleep
output_high(PIN_B4);
output_high(PIN_B6);
output_high(PIN_B7);
sleep(); #asm
NOP #endasm}
}}
___________________________
This message was ported from CCS's old forum
Original Post ID: 10060 |
|
|
kolio Guest
|
Re: external interrupt problem |
Posted: Mon Dec 16, 2002 2:35 am |
|
|
:=hi, all,
:=i am writing a program to wake up the processor which will normally in the sleep state. the processor will remain sleep until a change state occurs at the B0 pin.
:=i enable the int_ext in the main program, at the same time i disable the global interrupt so that the cpu will not be interrupted.
:=and then i will a loopcount to delay about 10s instead of using the timer in PCM. IE, the processor will sleep again 10s after it wakes up.
:=however it does not seem to work as there is an external interrupt to wake it up every time it goes to sleep. but i have made sure there is no external interrupt on pinB0. can anyone explain why?
:=
:=// Since GIE disabled, the following ISR remain in case interrupt occurred
:=
:=#int_rb
:=int_rb_isr() {}
:=
:=#int_ext
:=void ext_isr() {}
:=
:=main(){
:=...
:= ext_int_edge(l_to_h);
:= enable_interrupts(INT_EXT); //PBUS is interrupt to wakeup
:= enable_interrupts(INT_RB); //B4-B7 change interrupt (H->L)
:= disable_interrupts(GLOBAL); //Don't use interrupt
:=
:= while(1){
:=.... //some switch case
:= sleep_count++;
:= if (sleep_count>100){
:= sleep_count=0; //Reset count before sleep
:= output_high(PIN_B4);
:= output_high(PIN_B6);
:= output_high(PIN_B7);
:=
:= sleep(); #asm
:= NOP #endasm}
:=}}
Hi,
INTF and RBIF flags get set whenever RBIE and INTE are set, no matter if GIE is set. GIE only allows calling of ISRs. INTF should be cleared by s/w, otherwise it will cause reentering ISR, or if it is disabled - wake-up. The same is valid for RBIF.
I think that
while(1) {
...
...
...
bit_clear(INTCON,INTF);
bit_clear(INTCON,RBIF);
sleep();
}
would help. Good luck,
Kolio
___________________________
This message was ported from CCS's old forum
Original Post ID: 10063 |
|
|
Tomi Guest
|
Re: external interrupt problem |
Posted: Mon Dec 16, 2002 11:50 am |
|
|
Additionally you must read in portB just before you clear RBIT to make sure you have latched the current state of pin_b4 - pin_b7:
char inp;
inp = input_b();
bit_clear(INTCON,RBIF);
sleep();
Note that the IT on-portB-change is not edge-triggered.
Plus it would be better to use ITs as enabled with a correct IT handler.
___________________________
This message was ported from CCS's old forum
Original Post ID: 10069 |
|
|
simon630
Joined: 07 Sep 2003 Posts: 17
|
Re: external interrupt problem |
Posted: Wed Dec 18, 2002 7:37 am |
|
|
thx. it works.
___________________________
This message was ported from CCS's old forum
Original Post ID: 10115 |
|
|
|
|
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
|