ppperez
Newbie level 5
Hello MASTERS.
Someone can tell me what I am doing wrong....
I am trying to understand the PIC18F452, I did a couple of programs, I am trying to understand the Digital input signal.
I connected a couple of push bottoms on RA0 & RA1 to simulate a digital signal, the output will be the PORTB, I am doing a counter. With RA0 add 1 and RA1 menus 1.
According to the Datasheet in order to get all inputs on PORTA as Digital PCFG3CFG0 011X and ADCON0 I understood it's not necessary.
This is my easy code and I don't have any output, I don't know if I need to read more or my PIC is damaged.
I hope that someone can give me some ideas.
Thanks in advance.
Someone can tell me what I am doing wrong....
I am trying to understand the PIC18F452, I did a couple of programs, I am trying to understand the Digital input signal.
I connected a couple of push bottoms on RA0 & RA1 to simulate a digital signal, the output will be the PORTB, I am doing a counter. With RA0 add 1 and RA1 menus 1.
According to the Datasheet in order to get all inputs on PORTA as Digital PCFG3CFG0 011X and ADCON0 I understood it's not necessary.
This is my easy code and I don't have any output, I don't know if I need to read more or my PIC is damaged.
Code:
char salida = 0;
void main(int argc, char** argv) {
TRISB = 0; //Puerto B output
TRISA = 1; //Puerto A input
ADCON1 = 0x10000111;
// 0x1------- Justificacion a la derecha
// 0x-0------ Fosc/2
// 0x--00---- No implemented
// 0x----0110 AN0 -> AN7 = Digitals
while(1)
{
if (PORTAbits.RA0 == 1)
{
salida = salida + 1;
while(PORTAbits.RA0 == 1)
{}
}
if (PORTAbits.RA1 == 1)
{
salida = salida - 1;
while(PORTAbits.RA1 == 1)
{}
}
PORTB = salida;
}
}
I hope that someone can give me some ideas.
Thanks in advance.