EasyPic v7 Button PORTB

General discussion on mikroElektronika development boards.
Post Reply
Author
Message
oogi
Posts: 1
Joined: 16 Dec 2023 11:58

EasyPic v7 Button PORTB

#1 Post by oogi » 16 Dec 2023 12:08

Hello everyone,

i am new to world of microcontrollers, similar questions have been asked but i didn't find the solution for my problem.

void main() {

ADCON0 = 0x00;
ADCON1 = 0x0F;
TRISB = 0xFF;
TRISC.B0 = 0;
LATB = 0x00;

while(1) {
if (PORTB.B0 == 1) {
Delay_ms(10);
if(PORTB.B0 == 1) {
LATC.B0 = 1;
}
} else {
LATC.B0 = 0;
}
}

}

This code doesn't work for pins RB0-RB5, but it does work for pins RB6 and RB7. I understand that pins RB0-RB4 are initialy set to analog, but it is as if ADCON1 = 0xFF didn't changed them to digital. I don't understand what am i doing wrong. Microcontroller on my board is PIC18F45K22, and i have set dip switches to pull down position. Can someon help me?

Thanks

Post Reply

Return to “Development Boards”