Problem with Output Pins PORTB

General discussion on mikroC.
Post Reply
Author
Message
Nihel01
Posts: 3
Joined: 08 Apr 2012 17:32

Problem with Output Pins PORTB

#1 Post by Nihel01 » 08 Apr 2012 17:46

Hi, i'am new to PIC and i'am trying to do a very simple project to flash 8 LEDs in PORTB in sequence with the following code, on a PIC16F887:

void main(){


PORTB = 0;
TRISB = 0;
ANSELH = 0;
ANSEL = 0;

do {

PORTB = 128;
Delay_ms(500);
PORTB = 64;
Delay_ms(500);
PORTB = 32;
Delay_ms(500);
PORTB = 16;
Delay_ms(500);
PORTB = 8;
Delay_ms(500);
PORTB = 4;
Delay_ms(500);
PORTB = 2;
Delay_ms(500);
PORTB = 1;
Delay_ms(500);

}

while(1);

}


But only the LEDs on RB7,6 and 5 are working the others are not. In MikroC,In the Edit Project window, I used de Dafault settings, LVP OFF, HS Enabled and WDT disable. I tried other ports and the problem persists, with only 3 LEDs flashing. One thing I noticed is that when I open the .hex file on WinPIC800 and go to the CONFIG tab the LVP is On.

Help would really be appreciated cause i've tried everything and can't find why is this not working

User avatar
janko.kaljevic
Posts: 3565
Joined: 16 Jun 2011 13:48

Re: Problem with Output Pins PORTB

#2 Post by janko.kaljevic » 09 Apr 2012 16:23

Hello,

I have tested your code and it works just fine.
Please notice that if the low voltage programming is ON, you could experience this behavior.

Please try to disable it manually and program your controller again.

Best regards.

Post Reply

Return to “mikroC General”