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 CCS Technical Support

External interrupt on PIN_B0

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



Joined: 16 Jun 2006
Posts: 3

View user's profile Send private message Send e-mail

External interrupt on PIN_B0
PostPosted: Tue Jul 11, 2006 3:59 pm     Reply with quote

I am trying to use a simple pushbutton switch to toggle between two modes, one is to display to the LCD, and the other is to use an RFID reader. Both work perfectly even together, but when I try to use an external interrupt, the PIC only responds when the button is pressed from high to low. There is a clean signal from the button and I have used a delay function to account for the debouncing. The complete interrupt does not work. Can someone please help me?

Code:

#include <16F877>
#fuses HS,NOWDT,NOPROTECT,NOLVP, NOBROWNOUT
#use delay(clock=20000000)
#USE RS232(BAUD=9600, XMIT=PIN_C6,RCV=PIN_C7, bits=8, PARITY=N)

#include <lcd>
#include <input>
#rom 0x2100={1,2,3,4}
//#use fast_io(B)
//#define IRX_B_TRIS 0b10000010
//#define DOOR_BUTTON PIN_B0

//#byte PORTD = 8
//#define ALL_OUT 0

// global flag to send processor into sleep mode
short sleep_mode;
short lcdon;
//char got_interrupt;
#bit INTF_BIT = 0x0B.1

// external interrupt when button pushed and released
#INT_EXT
void ext_isr() {

   if(lcdon){
   sleep_mode=TRUE;
   disable_interrupts(INT_EXT);
   ext_int_edge(H_TO_L);
   }
   else if(!lcdon){
   sleep_mode=FALSE;
   disable_interrupts(INT_EXT);   
   ext_int_edge(L_TO_H);
   }
}

int checkid();

void main() {
output_float(PIN_B0);

// Enable pullups on all port B pins.
port_b_pullups(TRUE);

// Wait for them to pull up.
delay_us(10);
lcdon=TRUE;
ext_int_edge(L_TO_H);      // init interrupt triggering for button press
INTF_BIT = 0;
enable_interrupts(INT_EXT);// turn on interrupts
enable_interrupts(GLOBAL);




do{
int m;
int startaddr;
int milkaddr = 0001;
int breadaddr = 0002;
int juiceaddr = 0003;
int endaddr = 0003;
int freq = 0001;

//sleep_mode=TRUE;


set_tris_b(IRX_B_TRIS);//QUESTIONABLE!!!!!!!!

if(sleep_mode==FALSE){
   lcdon=TRUE;
   delay_ms(50);
    INTF_BIT = 0;
    enable_interrupts(INT_EXT);
   while(sleep_mode==FALSE){
   
             **CODE**

      }
}

else if(sleep_mode==TRUE){
   lcdon=FALSE;
   delay_ms(50);
    INTF_BIT = 0;
    enable_interrupts(INT_EXT);
lcd_init();
while(sleep_mode==TRUE){
      delay_ms(500);
      lcd_putc(" Need to Buy: ");
      delay_ms(500);
      lcd_putc('\f');
   for(startaddr=0001;startaddr<endaddr+1;startaddr++){       
       
               **CODE**

   }
delay_ms(1000);
   }
   
}while(TRUE);//end of huge do while loop right after main begins


}
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