PDA

View Full Version : Making RA6 (OSC2) an output on a 18F2525



elec_mech
- 17th August 2006, 16:06
Hi everyone! I've been flipping through the 390 page PIC 18F2525 manual for over an hour and I can't figure out how to make RA6 an output. I believe it is set as a second oscillator (OSC2) by default. Here is a simple test code I've been using to flash an LED:

' Setup
Trisa = %00000000 ' Set all port a pins as outputs
Trisb = %00000000 ' Set all port b pins as outputs
Porta = %00000000 ' Set all pins on port a as low
Portb = %00000000 ' Set all pins on port b as low
Adcon1 = $0F ' Disable the A/D converter

Start:

porta.6 = 1
portb.1 = 1
pause 500

porta.6 = 0
portb.1 = 0
pause 500

goto Start

The LED on portb.1 works fine, but not on porta.6.

The manual mentions setting the config1h register, but here I have 2 problems: 1) the default setting is said to be config1h = 00--0111 where the 0111 is an external RC Oscillator with port function on RA6 (which would imply, at least to me, that RA6 is already set to be a standard I/O and 2) the manual is very unclear on how to change the configuration register. I've searched many a post and all I find are sippets of assembly code (which I am utterly unfamiliar and want to avoid at all costs). Also, I don't know if changing the config1h register will actually enable me to use the RA6 pin as an output.

I am using the PICDEM 2 Plus demo board which has a external clock setup. I want to use the setup outlined on page 24 of the 18F2525 datasheet - ECIO on the bottom, right. Anyone have any advice?

mister_e
- 17th August 2006, 17:43
you'll have no other choice than alter config fuses using methods stated in the following thread...
http://www.picbasic.co.uk/forum/showthread.php?t=543

OR set them manually before programming your PIC. :eek:

Also, read the OSCCON section. page 30 table 2-2 to change the 1MHZ default speed in case you want to use the internal OSC instead.

elec_mech
- 28th September 2006, 15:18
Sorry for the late reply. I changed the original file as outlined in the link you sent and it worked like a charm!

Thanks Steve!

I will look into the internal oscillator capability. I have used that before in the 12F675 for hobby projects. If I may pick your vast background in PICs, are the internal oscillators as reliable as external crystals?

Thanks again!

ErnieM
- 28th September 2006, 17:51
I've never had a problem using the internal oscillator, just keep in mind that it's an RC oscillator, so it doesn't have the same accuracy as an external crystal will (even if you use the trim settings cause it will drift some over temp).

That said, it's a very good oscillator design, and unless my numbers show me I really need the higher accuracy, I go for the internal RC.