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

Interrupt by RB0

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



Joined: 21 Apr 2007
Posts: 44

View user's profile Send private message

Interrupt by RB0
PostPosted: Thu Jul 12, 2007 7:17 am     Reply with quote

I am having problem in dealing with the interrupt.
I wish to activate an interrupt on a switch press. This seemingly easy task has consumed my 0NE whole day and I am still no where.
The code is:

Code:
#include <18F452.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use fast_io(A)
#use fast_io(B)
#use fast_io(C)
#use fast_io(D)

int8 INT0_Flg;

#INT_EXT
void ext_RB0()
{
   INT0_Flg=0x01; // Turn the flag on to go for receiving the LAT/LON
}


void main()
{
   SET_TRIS_B(0x01);   // Direction of pin as input.
   INT0_Flg=0;

   enable_interrupts(INT_EXT);// turn on interrupts on RB0
   enable_interrupts(GLOBAL); // turn on global interrupts
   delay_ms(500); //let the system to stabilize
   
   while (TRUE)
   {
   IF (PORTB==1)
   PORTB=0xff;
   else
   PORTB=0;
delay_ms(200);
      if (INT0_Flg)
      {
      IF (PORTA==0)
      PORTA=0xff;
     else
     PORTA=0;
     delay_ms(200);
      }//end if
   }//end while
}

I have hardwired Pin_B0 to ground using a 10K resistor (normally off position) and am using a Normally open switch to connect the Pin to VCC.

The problem is that at the program start, there is no activity on any of the ports(A or B) but for as long as the switch is closed, the PortB keeps on flashing with no activity on PortA.
The program seems to get stuck some where (may be in the ISR).
.
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