hello everyone, i have a question. How to use switch with interrupts
I will tell you a detail in the below :
Using : PIC16F877
Program : CCS C
led : port d bit 0
sw1 (switch1) : port b bit 0
sw2 (switch2) : port b bit 1
Interrupt from : RS232
goal : want to turn on LED
condition : If press sw1 or sw2 , LED will not
work immediately but it must have a
external signal from rs232 (i am waiting to receive a
value from rs232) in to PIC16F877 too,
also led will work, and if have external signal into
PIC16F877 before press sw1 or sw2
led will not work
Please help me for a code
Thank you very much
vijay s
Joined: 20 Oct 2007 Posts: 17 Location: coimbatore,india
Posted: Tue Jul 22, 2008 12:44 am
it's simple.
Set a flag like switch = true in portb change interrupt when you press a switch. In uart interrupt routine check that a switch flag is true. If it is then turn on a LED, else turn off LED. _________________ with regards
vijay s
Wayne_
Joined: 10 Oct 2007 Posts: 681
Posted: Tue Jul 22, 2008 1:19 am
Don't use the word "switch" as a variable use something like int sw;
switch is a keyword in C and the compiler will most likely complain.
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