Making RA6 (OSC2) an output on a 18F2525


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2005
    Location
    Virginia
    Posts
    65

    Question Making RA6 (OSC2) an output on a 18F2525

    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?

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    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.

    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.
    Last edited by mister_e; - 17th August 2006 at 17:57.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Apr 2005
    Location
    Virginia
    Posts
    65


    Did you find this post helpful? Yes | No

    Talking Eureka!

    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!

  4. #4
    Join Date
    Jul 2005
    Posts
    78


    Did you find this post helpful? Yes | No

    Default

    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.

Similar Threads

  1. Help changing CCP3 output pin
    By ChrisHelvey in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 15th July 2008, 02:30
  2. Bit Banging input to output on PIC16F876A
    By Bronurstomp in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 26th June 2008, 19:50
  3. Serious Serial Situation Setbacks...
    By Dansdog in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 7th February 2007, 03:46
  4. Using LEDs as light sensors
    By skimask in forum Code Examples
    Replies: 3
    Last Post: - 30th December 2006, 22:19
  5. HSEROUT Newbie question/problem
    By Mark Scotford in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 11th July 2006, 14:44

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts