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

PIC 16F877A interrupt on B4 strange activity

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



Joined: 30 Nov 2007
Posts: 13

View user's profile Send private message

PIC 16F877A interrupt on B4 strange activity
PostPosted: Fri May 23, 2008 9:01 am     Reply with quote

Greetings programming gurus.

Im trying to interrupt when a change (hi/low) is detected on PIN B4 on my pic16f877a. My code in entirety is as follows;

Code:


#include <16F877a.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)

int8 value = 0;

#INT_RB
void portchange_isr ()
{
value = input(PIN_B4);
}

void main()
{
   output_low(pin_c5);
   enable_interrupts(GLOBAL);
   enable_interrupts(INT_RB);
   set_tris_B(0xF0);
 
 while(1)
      {
       if (value == 0)
              {
               output_low(pin_c5);
              }
              else
              {
               output_high(pin_c5);
              }
      } 
  }


//IDE VERSION 4.057
//PCM VERSION 4.057
//PCB VERSION 4.057



The issue I am having is as follows.

I know that the interrupt routine gets called and executed, however i have PIN_C5 connected to an LED. This LED seems to stay on all the time. I know the interrupt gets called, because when I toggle (with a wire) between 5v and zer0 volts at b4, the led brightens and dims accordingly.

It almost seems like I have a floating issue, but the only wires connected to my chip are grounds and the vcc. Might anyone be able to shed some light on this situation for me ?

Best Regards,
SerialGmr8
Ttelmah
Guest







PostPosted: Fri May 23, 2008 9:26 am     Reply with quote

As you have it setup, B4, B5, B6, and B7, will all trigger the interrupt. If these are not pulled to a rail, then you will get spurious triggers. Enable the portb pullups on the port, so these pins are all pulled high, before enabling the interrupt, to avoid this.

Best Wishes
SerialGmr8



Joined: 30 Nov 2007
Posts: 13

View user's profile Send private message

PostPosted: Fri May 23, 2008 9:48 am     Reply with quote

Thank you Ttelmah. All is well with my code Smile

Regards,
SerialGmr8
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