|
|
View previous topic :: View next topic |
Author |
Message |
chriss Guest
|
Interrupt on Port B |
Posted: Tue Jan 07, 2003 12:24 pm |
|
|
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 |
Posted: Tue Jan 07, 2003 3:52 pm |
|
|
:=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 |
|
|
|
|
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
|