kein
Joined: 23 Jul 2007 Posts: 103
|
Is there a simple way of disabling an i/o pins? |
Posted: Fri May 09, 2008 9:45 pm |
|
|
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)
{
..........................
}
} |
|
|