Problem with 18F14K22 write RB4 and RB5

General discussion on mikroBasic PRO for PIC.
Post Reply
Author
Message
Kalle1
Posts: 6
Joined: 01 Jan 2013 13:55

Problem with 18F14K22 write RB4 and RB5

#1 Post by Kalle1 » 19 Oct 2014 22:46

Hello community,

I have a problem with the ports RB4 and RB5 at the 18F14K22:
The port B is defined as Output (RB4-7), Prot C is defined as Output (RC0-7)

PORTB = 0
PORTC = 0
TRISB = 0
TRISC = 0
ANSELH = 0

When i set PortB and PortC = 255, all LED's on PotrC going on, LED on BR6 and RB7 going on, but LED on RB4 and RB5 remain dark. :shock:
Which register I forgot?
What am I doing wrong?

Thanks

Kalle1

User avatar
petar.timotijevic
mikroElektronika team
Posts: 1739
Joined: 19 Feb 2014 13:46
Location: Serbia
Contact:

Re: Problem with 18F14K22 write RB4 and RB5

#2 Post by petar.timotijevic » 21 Oct 2014 10:53

Hi,

PIC18F14K22 all I/O pins on all ports are ok, including RB4 and RB5. I tested MCU on EasyPIC v7 Connectivity and there is no problems.

Try this code:

Code: Select all

void main() {

  TRISA = 0;           // set direction to be output
  TRISB = 0;           // set direction to be output
  TRISC = 0;           // set direction to be output

  do {
    LATA = 0x00;       // Turn OFF LEDs on PORTA
    LATB = 0x00;       // Turn OFF LEDs on PORTB
    LATC = 0x00;       // Turn OFF LEDs on PORTC
    Delay_ms(500);    // 0.5 second delay

    LATA = 0xFF;       // Turn ON LEDs on PORTA
    LATB = 0xFF;       // Turn ON LEDs on PORTB
    LATC = 0xFF;       // Turn ON LEDs on PORTC
    Delay_ms(500);    // 0.5 second delay
  } while(1);          // Endless loop
}
Best regards,
Peter

Kalle1
Posts: 6
Joined: 01 Jan 2013 13:55

Re: Problem with 18F14K22 write RB4 and RB5

#3 Post by Kalle1 » 23 Oct 2014 16:59

Hi Peter,

i have test the program as Basic.
RB4 and RB5 remain dark. But wenn i load the Program on Chip, LED RB4 and RB5 gos on?
I just noticed that I have a hardware Problem. A Optocouppler pulling my signal on RB4/5 on Ground .
Thanks for your help

Kalle

User avatar
petar.timotijevic
mikroElektronika team
Posts: 1739
Joined: 19 Feb 2014 13:46
Location: Serbia
Contact:

Re: Problem with 18F14K22 write RB4 and RB5

#4 Post by petar.timotijevic » 24 Oct 2014 10:54

Hi,

In mikroBasic Pro is the same situation RB4, RB5 and all others pins work fine.

Code: Select all

program MyProject

main:
 
  TRISA = 0           ' set direction to be output
  TRISB = 0           ' set direction to be output
  TRISC = 0           ' set direction to be output

  while TRUE
    LATA = 0x00       ' Turn OFF LEDs on PORTA
    LATB = 0x00       ' Turn OFF LEDs on PORTB
    LATC = 0x00       ' Turn OFF LEDs on PORTC
    Delay_ms(2000)   ' 2 second delay

    LATA = 0xFF       ' Turn ON LEDs on PORTA
    LATB = 0xFF       ' Turn ON LEDs on PORTB
    LATC = 0xFF       ' Turn ON LEDs on PORTC
    Delay_ms(2000)   ' 2 second delay
  wend                ' Endless loop

end.
Best regards,
Peter
Attachments
mikroBasic Pro.zip
(15.87 KiB) Downloaded 109 times

Post Reply

Return to “mikroBasic PRO for PIC General”