Having trouble with PORTB and A (need help)

Status
Not open for further replies.

qmriso

Member level 5
Joined
Nov 30, 2006
Messages
80
Helped
2
Reputation
4
Reaction score
1
Trophy points
1,288
Activity points
1,879
I am currently working on simple UART project, but when i recive a byte on portB ( i'm using PIC 18f2320) pin RB5 never gives an output
even if i send 0xFF.
So I thought to test the port by using this code

void main(void)
{
TRISB=0;
LATB=0;

while (1)
{
LATB=0xFF;
}
}

But no luck.(MPLAB said that this would work fine)
So i tried to use PORTA with this code:

void main(void)
{
ADCON1bits.PCFG3=1; //sets portA bit0-3 to digital I/O

TRISA=0;
LATA=0;

while (1)
{

LATA=0xFF;
}

}
Again MPLAB said that this would work fine, but on the chip i had nothing on pins RA7 and RA4 (i have configered the oscillator so that RA 6 and 7 are I/O)

Can anyone Help me?
 

Check the datasheet for that MCU that you are using. Usually PORTA.4 cannot be used as output, so check the PDF.

www.elektronika.ba
 

CONFIG1H: CONFIGURATION REGISTER 1 HIGH (BYTE ADDRESS 300001h)

OSC<3:0>: Oscillator Selection bits
bit 3-0 FOSC
0101 = EC oscillator, port function on RA6


You need set theese bits in CONFIG1H for correct work with RA6
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…