lmichals80
New Member
Hello everyone again,
I am having a problem reading input pins. using the code listed below(but changing (1<<1), to (1<<0)), I am able to light an LED on RB2 when RA0 is driven high with a separate 5V input and ~1.6K pull down resistor(2 800ohms in series, it was all I had) when I attempt the same with any of the RA pins(specifically RA1) I cannot get the LED to light. The 5V input is a Radio controlled vehicle receiver, but connected to the constant on wire(when power is supplied, voltage is a constant 5v). The supply voltage from the receiver comes from a DC regulated power supply. I tried using the 1.6k as a pull up resistor instead(although this seemed backwards) and it still did not work. As far as I can see from the datasheet, I have turned off all peripherals that would contradict using digital I/O pins. Any help would be greatly appreciated!!!
Setup:
PIC: 16F886
Compiler: MikroC
Config: WDT off, MCLR off, LVP off
Code:
Thanks!!!
Luke
I am having a problem reading input pins. using the code listed below(but changing (1<<1), to (1<<0)), I am able to light an LED on RB2 when RA0 is driven high with a separate 5V input and ~1.6K pull down resistor(2 800ohms in series, it was all I had) when I attempt the same with any of the RA pins(specifically RA1) I cannot get the LED to light. The 5V input is a Radio controlled vehicle receiver, but connected to the constant on wire(when power is supplied, voltage is a constant 5v). The supply voltage from the receiver comes from a DC regulated power supply. I tried using the 1.6k as a pull up resistor instead(although this seemed backwards) and it still did not work. As far as I can see from the datasheet, I have turned off all peripherals that would contradict using digital I/O pins. Any help would be greatly appreciated!!!
Setup:
PIC: 16F886
Compiler: MikroC
Config: WDT off, MCLR off, LVP off
Code:
Code:
#define setbit(var,bitnum)(var) |=(1<<(bitnum))
void lighton(void){
while(porta&(1<<1) == 1)setbit(portb,2);
portb = 0x00;
}
void main(void){
cm1con0 = 0x00; //comparator 1 disabled
cm2con0 = 0x00; //comparator 2 disabled
adcon0 =0x00; //ADC disabled
osccon = 0x61; //set OSC freq 4mhz
ansel = 0x00; // set all pins digital
trisb = 0x00; // set PORTB as output
trisa = 0x03; //set PORTA pins 1 and 2 as input
portb = 0x00; //no output on PORTB
while (1) {
lighton();
}
}
Thanks!!!
Luke
Last edited: