PIC 18F4685

Thread Starter

Anupam

Joined Dec 24, 2008
3
hi
I m working on PIC18F4685
Its 6 & 7 bits of port Ais used in main oscillator . can any one know how to use them as normal I/O pins.
I am using C compiler for programming..
 

Thread Starter

Anupam

Joined Dec 24, 2008
3
i define them as follows

void main()
{
PORTA = 0; // Initialize PORTC
TRISA = 0; // Configure PORTC as output

while(1) {
PORTA = ~PORTA; // toggle PORTC
Delay_ms(1000); // one second delay
}
}
All pins are working except 6th and 7th ...
plz let me know what i m missing ?
 

mik3

Joined Feb 4, 2008
4,846
Here is the datasheet of the PIC18F4685:

http://ww1.microchip.com/downloads/en/DeviceDoc/39761b.pdf

If you look at page 346 you will see this:

bit 3-0 FOSC3:FOSC0: Oscillator Selection bits

11xx = External RC oscillator, CLKO function on RA6
101x = External RC oscillator, CLKO function on RA6
1001 = Internal oscillator block, CLKO function on RA6, port function on RA7
1000 = Internal oscillator block, port function on RA6 and RA7
0111 = External RC oscillator, port function on RA6
0110 = HS oscillator, PLL enabled (Clock Frequency = 4 x FOSC1)
0101 = EC oscillator, port function on RA6
0100 = EC oscillator, CLKO function on RA6
0011 = External RC oscillator, CLKO function on RA6
0010 = HS oscillator
0001 = XT oscillator
0000 = LP oscillator


As you can see to use A6 and A7 as I/O you have to set the configuration bits to 1000. You can do it by setting the appropriate #FUSES or in the programmers software (some programmers require as you do it in their control software).
 
Top