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

Push-Button Interrupt

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



Joined: 06 Nov 2009
Posts: 4

View user's profile Send private message

Push-Button Interrupt
PostPosted: Thu Mar 25, 2010 6:16 am     Reply with quote

Hello

I work with the PIC16F883 and I have a problem. By the inputs RB5 and RB6 I have two pushbuttons with pull-down resistors. Now I want to have two interrupt routines, one for the input RB5 and one for the input RB6. I wrote the following code, but it doesn't work.
Code:

#fuses HS, NODEBUG, NOBROWNOUT, NOPROTECT, MCLR, NOPUT, NOFCMEN, WDT
#fuses NOLVP, NOWRT, NOIESO, NOCPD,

#use delay (clock=8000000)

//Funktions-Prototypen
void InitPorts (void);
void InitTimer0 (void);
void InitTasterInt (void);
void InitADC (void);
void ReadADC (void);

//Globale Variabeln
unsigned char Lautsprecher = 0;
                     

void main (void)
{
    
  InitPorts();
  InitTasterInt();


  while(1)
  {
 
  }//while(1) 
}


/****************************************************/
/* InitPorts
/****************************************************/
void InitPorts (void)
{
  SET_TRIS_A(0x2F); //Eingänge und Ausgänge definieren
  SET_TRIS_B(0x00);
  SET_TRIS_C(0xCF);
}


/****************************************************/
/* Interrupt vom RB5: Einlese-Taster
/****************************************************/
#INT_RB5
void InterruptTasterRB5 (void)
{
   while(1);
}

/***************************************************/
/* Interrupt vom RB6: Taster Neue Kiste
/***************************************************/
#INT_RB6
void InterruptTasterRB6 (void)
{
   while(1);
}


/*****************************************************/
/* InitTasterInt
/*****************************************************/
void InitTasterInt (void)
{
  ENABLE_INTERRUPTS(GLOBAL); 
  ENABLE_INTERRUPTS(INT_RB5);
  ENABLE_INTERRUPTS(INT_RB6);
}

Could somebody help me please.

PS: Sry for my english, I'm a young swiss student. :-D
turantus



Joined: 25 Mar 2010
Posts: 4

View user's profile Send private message

PostPosted: Thu Mar 25, 2010 11:41 am     Reply with quote

Maybe the watchdog resetting you all time?
mbge5amw



Joined: 13 Dec 2004
Posts: 15
Location: Yorkshire, UK

View user's profile Send private message MSN Messenger

PostPosted: Mon Mar 29, 2010 8:44 am     Reply with quote

Quote:
SET_TRIS_B(0x00);


TRIS needs to be set high on a pin for it to be read as an input.

I am also not sure if the way you have the switch wired would work,it may eb worth checking the voltage on the input pin.
Not sure if you can drive a low input with a weak pull down resistor, I've always been taught that TTL circuits should have a weak pull up and a strong pull down. i.e. your push button goes to ground and your resistor (1k to 10k would be fine) goes to VCC.

Andy
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