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.
Which register I forgot?
What am I doing wrong?
Thanks
Kalle1
Problem with 18F14K22 write RB4 and RB5
- petar.timotijevic
- mikroElektronika team
- Posts: 1739
- Joined: 19 Feb 2014 13:46
- Location: Serbia
- Contact:
Re: Problem with 18F14K22 write RB4 and RB5
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:
Best regards,
Peter
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
}
Peter
Re: Problem with 18F14K22 write RB4 and RB5
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
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
- petar.timotijevic
- mikroElektronika team
- Posts: 1739
- Joined: 19 Feb 2014 13:46
- Location: Serbia
- Contact:
Re: Problem with 18F14K22 write RB4 and RB5
Hi,
In mikroBasic Pro is the same situation RB4, RB5 and all others pins work fine.
Best regards,
Peter
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.
Peter
- Attachments
-
- mikroBasic Pro.zip
- (15.87 KiB) Downloaded 109 times