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

Input pins not working properly

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







Input pins not working properly
PostPosted: Sat Feb 23, 2008 2:24 am     Reply with quote

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
stefsun



Joined: 23 May 2007
Posts: 22

View user's profile Send private message

PostPosted: Sat Feb 23, 2008 2:46 am     Reply with quote

set_tris_a(0b10); ->set_tris_a(0x02);

int rf_pass; ->int1 rf_pass;
Guest








PostPosted: Sat Feb 23, 2008 4:07 am     Reply with quote

It is still not effective,could it be a bug in the compiler or limitation?
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