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

Question regarding INT_RB behaviour.
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
pipec



Joined: 21 May 2010
Posts: 1

View user's profile Send private message

PORTB Interrupt
PostPosted: Fri May 21, 2010 3:10 pm     Reply with quote

Hi!
I am new in programming PIC in C, but maybe my code will be usefull.
I have tested it with proteus. If you like to make interrupt both edge (H2L and L2H) just take off the variable "d". I hope you like it.
Code:

#include <16F877.h>
#include "F:\progik\Programozás\PIC\saját_c\Interrupt\PIC16F877_registers.h"
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)

BYTE blink = 0;
byte c,d;

#int_rb
void button_isr() {
   
   c=portb;
   d=~d;
   if (d!=0){
   if (!blink)
   blink=1;
   else
   blink=0;
   } 
   }

void main() {
   
   clear_interrupt(INT_RB);
   enable_interrupts(INT_RB);
   enable_interrupts(GLOBAL);
   d=0;
   trisd=0x00;
   portd=0x00;
   
     
   do {
         if(blink){
         output_high(PIN_D1);
         delay_ms(500);
         output_low(PIN_D1);
         delay_ms(500);
         }
   } while (TRUE);
}
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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