CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

INT_EXT1_H2L

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
soonc



Joined: 03 Dec 2013
Posts: 215

View user's profile Send private message

INT_EXT1_H2L
PostPosted: Thu Jan 17, 2019 4:16 pm     Reply with quote

Signal at PIN_B4 is high and goes low to 10mS signal is clean no bounce.
Vdd is 3.3V
The chip does not wake up !
I'm a little confused about GLOBAL interrupt. Should it be disabled or enabled !
The #INT_EXT1 ISR is needed as the code locks without it.

Any help is welcomed.

Code:

#include <18F47K42.h>
#device ADC = 8
#use delay(clock = 12000000, crystal = 12000000) 
#FUSES NOWDT 
#FUSES HS // more fuses from a working project

///////////////////////////////////////////////////////
//
#pin_select INT1=PIN_B4
#INT_EXT1
void RTC_Alarm_isr(void)
{
   // do nothing
   // is this needed ?  clear_interrupt(INT_EXT1_H2L);

}
///////////////////////////////////////////////////////
//
void main()
{
   disable_interrupts(GLOBAL); // only want INT_EXT1_H2L to wake up the chip
I tried enable_interrupts(GLOBAL); // did not work either

   clear_interrupt(INT_EXT1_H2L);
   enable_interrupts(INT_EXT1_H2L);  // Hi to Lo
   
   sleep(SLEEP_FULL); // Wait for RTC Alarm pulse to wake up cpu
   delay_cycles(1);
   
   while(1)  // never gets here
   {
     output_toggle(PIN_C5);
   }
}
Ttelmah



Joined: 11 Mar 2010
Posts: 19215

View user's profile Send private message

PostPosted: Fri Jan 18, 2019 2:04 am     Reply with quote

GLOBAL needs to be enabled.
This is the 'master gate'. Allows _all_ enabled interrupts to be
turned on/off. To use an interrupt, it must be enabled, and GLOBAL
must also be enabled.
Then when an interrupt occurs, it's handler will be called. The handler
has to exist, or the code will go off into nowhere.
Then there is an issue.
With an interrupt, there is the 'event' that triggers it, and the flag
that gets set. Clearing an interrupt resets the flag, and this is done
automatically for you be the compiler, so you don't need an extra clear
in the routine. However this does not reset the 'event'. In this case
the 'event', is the act of PortB not matching what has last been
read from PortB. On and interrupt on change, the
handler _must_ read the port, to reset the event, or the flag cannot
be cleared (since the event is set, it'll keep resetting the flag). If this
is not done, the code can't actually leave the interrupt handler - it'll
be called for ever.
So, GLOBAL needs to be enabled.
Handler must exist.
Handler must read the input pin.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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