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

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



Joined: 26 Jan 2005
Posts: 13

View user's profile Send private message

Interrupt
PostPosted: Fri Feb 18, 2005 3:26 am     Reply with quote

Hi

I need some help with interrupts. I want a delay. I want to use an interrupt on pin change to break this delay - RB0.

Please can any one help me as i don't know how to use it. Thanks


#include <18F452.h>
#device ICD=TRUE
#device adc=8
#use delay(clock=4000000)
#fuses NOWDT, WDT128, HS, NOPROTECT, NOOSCSEN, BROWNOUT, BORV20, PUT, STVREN, DEBUG, LVP, NOWRT, NOWRTD, NOWRTB, NOWRTC, NOCPD, NOCPB, NOEBTR, NOEBTRB
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=9)

#include <STDLIB.H>


void main(){
/* **************************************************************/
/* INITIALISATION SECTION
/*
/* Part of Bootup Sequence. All peripherals
/* are configured and activated.
/*
/* ************************************************************* */


enable_interrupts(GLOBAL);





delay_ms(10000); //always do this




enable_interrupts(GLOBAL);

{
while(input(PIN_B0));
while(!input(PIN_B0));

while(TRUE)
{
output_high(PIN_B3); //clear
delay_ms(1000);
output_low(PIN_B3);
delay_ms(1000);
}

}






}
EdWaugh



Joined: 07 Dec 2004
Posts: 127
Location: Southampton, UK

View user's profile Send private message

hi
PostPosted: Fri Feb 18, 2005 5:14 am     Reply with quote

you perhaps want to rty something like this
Code:

short flag;

main()
{
disable_interrupts(GLOBAL);
enable_interrupts(INT_EXT);
enable_interrupts(GLOBAL);

flag=0;

while(!flag)                 // this means while flag=0 but is faster
{
    //do what ever you want here
    // this will delay until the rising edge
}

}

#int_ext1                   // this is for 18f252 check your valid interrupt labels
isr()
{
 flag = 1;
}



this should give you the idea

ed
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