Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Why PIC didn't see 1 on the PORTA?

Status
Not open for further replies.

roberto.s

Newbie level 6
Joined
Feb 19, 2010
Messages
11
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Italy
Activity points
1,384
Hi,

I have e stupid problem, but I can't find the solution,

this is the program:

#include <p18f2520.h>

#pragma config OSC = HS
#pragma config WDT = OFF
#pragma config LVP = OFF
#pragma config PBADEN = OFF

void main (void){
// Imposto PORTA tutti ingressi
LATA = 0x00;
TRISA = 0b11111111;
// Imposto PORTB tutti ingressi
LATB = 0x00;
TRISB = 0x00;
// Imposto PORTC tutti ingressi
LATC = 0x00;
TRISC = 0xFF;
for (;;){
if (PORTAbits.RA2 == 0){
PORTBbits.RB2 = 1;
}else{
PORTBbits.RB2 = 0;
}
}
}

easy??? yes, but why the led is always on???
I can explain....

can someone else???

may be a problem of setting?

in the circuit I have a pull-up on the input and nothing else.......
 

I cant judge your circuit as I do not see your schematic.
I guess you need to add a delay between toggling actions to see the change with your eyes.
--
Amr Ali
 

yes, but if I don't change the value of the input, the output doesn't change.

my problem is that PIC see 0 but I put 1 on the pin; the circuit is a simple pull-up (R=100K) and a switch between R + PIN and GND.

Added after 19 minutes:

I just find the solution; I forgot tu set a register.

Thank you for your intresting.

Bye!
 

you are taking input on PORTA and by default PORTA is assigned to ADC you need to first configure PORTA as a digital port in ADCON1 register then proceed forward.
it will work
 

Yes that was the register I forgot to set...

thank!
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top