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 on Port B

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







Interrupt on Port B
PostPosted: Tue Jan 07, 2003 12:24 pm     Reply with quote

I have button on Port B
When i Push this button, the Pin is Low
Now I won't to count, how often this button is pushed and display the number on my 8 leds on port c.
The code oesn't work !!
Help me
-------------------------------------------------
#include <16f876.h>
#Device ICD=TRUE
#use delay(clock=4000000)

void main()
{
char newbit,in;
SET_TRIS_A(0xFF);
SET_TRIS_B(0xFF);
SET_TRIS_C(0x00);
while(1)
{
newbit=input(PIN_B0);
if(newbit==0)
{
in=in|newbit;
in=in*2;
output_c(in);
}

}
}
___________________________
This message was ported from CCS's old forum
Original Post ID: 10511
R.J.Hamlett
Guest







Re: Interrupt on Port B
PostPosted: Tue Jan 07, 2003 3:52 pm     Reply with quote

:=I have button on Port B
:=When i Push this button, the Pin is Low
:=Now I won't to count, how often this button is pushed and display the number on my 8 leds on port c.
:=The code oesn't work !!
:=Help me
:=-------------------------------------------------
:=#include <16f876.h>
:=#Device ICD=TRUE
:=#use delay(clock=4000000)
:=
:=void main()
:={
:= char newbit,in;
:= SET_TRIS_A(0xFF);
:= SET_TRIS_B(0xFF);
:= SET_TRIS_C(0x00);
:=while(1)
:={
:= newbit=input(PIN_B0);
:= if(newbit==0)
:= {
:= in=in|newbit;
:= in=in*2;
:= output_c(in);
:= }
:=
:=}
:=}
Try:

#include <16f876.h>
#Device ICD=TRUE
#use delay(clock=4000000)
#use fast_io(A)
#use fast_io(B)
#use fast_io(C)

void main()
{
char newbit,in,last;
SET_TRIS_A(0xFF);
SET_TRIS_B(0xFF);
SET_TRIS_C(0x00);
while(1)
{
newbit=input(PIN_B0);
if(newbit!=last)
{
//Here the input has changed
last=newbit
if (newbit==0)
{
output_c(++in);
}
}
}
}

___________________________
This message was ported from CCS's old forum
Original Post ID: 10518
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