![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
crukid Guest
|
Input pins not working properly |
Posted: Sat Feb 23, 2008 2:24 am |
|
|
Hello to all!!!
I am having a problem on getting the state of my input pins. below is the code.
Code: |
#use rs232(baud=2400,xmit=pin_b1,rcv=pin_b2)
#use fast_io(A)
void printID(char *ID);
void alarm();
void main()
{
int rs_state;
int rf_pass;
char rf_id[11];
set_tris_a(0b10);
while(1)
{
rf_pass = input(PIN_A1);
if(!rf_pass)
{
output_low(pin_b5);
output_low(pin_b6);
gets(rf_id);
if(rf_id != "" && rf_id != " ")
{
printID(rf_id);
}
}
}
}
void printID(char *ID)
{
int i;
if(ID[1] != 'F' && ID[1] != 'C' && ID != "")
{
for(i=1;i<150;i++)
{
if(i < 11)
{
putc(ID[i]);
}
OUTPUT_HIGH(PIN_A0);
Delay_us(100);
OUTPUT_LOW(PIN_A0);
Delay_us(100);
};
output_high(pin_b5);
output_high(pin_b6);
delay_ms( 750 );
}
}
void alarm()
{
int i;
for(i=0; i<150; ++i)
{
OUTPUT_HIGH(PIN_A0);
Delay_us(80);
OUTPUT_LOW(PIN_A0);
Delay_us(80);
}
}
|
How this code suppose to work is that when pin A1,assigned to rf_pass, is low the statement inside the IF condtion ,if(!rf_pass),should inside it will execute then will loop after but I am not getting the right response,it seems the pin is not being updated everytime the code loops..hope someone could advice |
|
![](templates/subSilver/images/spacer.gif) |
stefsun
Joined: 23 May 2007 Posts: 22
|
|
Posted: Sat Feb 23, 2008 2:46 am |
|
|
set_tris_a(0b10); ->set_tris_a(0x02);
int rf_pass; ->int1 rf_pass; |
|
![](templates/subSilver/images/spacer.gif) |
Guest
|
|
Posted: Sat Feb 23, 2008 4:07 am |
|
|
It is still not effective,could it be a bug in the compiler or limitation? |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|