secretagent
New Member
Hi guys!
I'm using this PIC and for some reason I can output to RA0,RA1 etc. I cannot read from them though like this:
I have to do:
Which is obviously the last written bit...
Even with TRISA=0xFF, The input doesn't change, Even with debugging on I can't get an input, I can tell because the LED doesn't turn on when I hit the switch, and the variable doesn't change in the PIC.
Any help would be awesome! Thanks!
Code:
Code should be and wanted:
Thanks!
I'm using this PIC and for some reason I can output to RA0,RA1 etc. I cannot read from them though like this:
Code:
RA0=~RA0;
Code:
LATB0=~LATB0;
Even with TRISA=0xFF, The input doesn't change, Even with debugging on I can't get an input, I can tell because the LED doesn't turn on when I hit the switch, and the variable doesn't change in the PIC.
Any help would be awesome! Thanks!
Code:
Code:
#include <xc.h>
#pragma config PLLDIV = 12, CPUDIV = OSC1_PLL2, USBDIV = 2, FOSC = HS, FCMEN = OFF, IESO = OFF
#pragma config PWRT = ON, BOR = OFF, VREGEN = ON, WDT = OFF, PBADEN = OFF, LPT1OSC = OFF, MCLRE = OFF
#pragma config STVREN = OFF, LVP = OFF, DEBUG = ON
void main(void)
{
char x=0;//for debugging
ADCON0=0x0F;
CMCON=7;
PORTA=0;
PORTB=0;
TRISA=0xFF;
TRISB=0;
while(1)
{
x=RA0;
if(RA0==1)
{
LATB0=~LATB0;
while(RA0==1);
}
}
}
Code should be and wanted:
Code:
#include <xc.h>
#pragma config PLLDIV = 12, CPUDIV = OSC1_PLL2, USBDIV = 2, FOSC = HS, FCMEN = OFF, IESO = OFF
#pragma config PWRT = ON, BOR = OFF, VREGEN = ON, WDT = OFF, PBADEN = OFF, LPT1OSC = OFF, MCLRE = OFF
#pragma config STVREN = OFF, LVP = OFF, DEBUG = ON
void main(void)
{
ADCON0=0x0F;
CMCON=7;
PORTA=0;
PORTB=0;
TRISA=0xFF;
TRISB=0;
while(1)
{
if(RA0==1)
{
RA0=~RA0;
while(RA0==1);
}
}
}
Thanks!
Last edited: