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

Is there a simple way of disabling an i/o pins?

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



Joined: 23 Jul 2007
Posts: 103

View user's profile Send private message

Is there a simple way of disabling an i/o pins?
PostPosted: Fri May 09, 2008 9:45 pm     Reply with quote

I just wonder if an output or input pin can be disabled! I've a button connected to portB PIN_B4 and would like to disable it during adc reading since it control how adc is read.
When this button on portb is pressed, the adc interrupt is enabled and a buffer is filled. During this time, the button should not respond to it if someone presses it while the buffer is not full. I've tried to change to output while buffer is filling and back to an input But this does not work! any idea?
Code:
#int_AD
void  ADXL330AD_isr(void)
{     
  if(data.Indx < MAX_SIZE)
  {
    //ADXL330PIN_B4ASOUTPUT;
     set_tris_b(0x07);         // TRISB = 00000111; RB4,RB2,RB1 and RB0
    data.Buff [data.Indx] = (read_adc(ADC_READ_ONLY) - 0X266);
    data.Indx++;
  }
if(data.Indx == MAX_SIZE)
   {
    data.Storage_flg = 0;
    data.Analysis_flag = 1;   
    data.Indx = 0;   
    set_tris_b(0x17);         // TRISB = 00010111; RB4,RB2,RB1 and RB0
    disable_interrupts(INT_AD); // ADC OFF 
   }   
 
}


in the main function I've initialized portB pin_b4 as input.
Code:
void main()
{
  set_tris_b(0x17);         // TRISB = 00010111; RB4,RB2,RB1 and RB0

.....................
while(1)
{
..........................
}
}
kein



Joined: 23 Jul 2007
Posts: 103

View user's profile Send private message

Don't worry I got it
PostPosted: Fri May 09, 2008 11:18 pm     Reply with quote

Don't worry I got it! All I've to do is set the a flag and then check for the button and the flag.i.e.
Code:
int1 flag = 1;

......
newbutton = input(pin_B4);

if(newbutton !=oldbutton && flag)
{
 //to do....
flag = 0;
}
oldbutton =  newbutton;
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