making ports outputs on a 12F629


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2004
    Location
    Saskatchewan Canada
    Posts
    189

    Question making ports outputs on a 12F629

    I don't think this is a required command since I am only using HIGH and LOW on the ports which I understand automatically set the port to input or output, but that doesn't stop me from wanting to understand doing this better.

    If I look at the chip data sheet I see that the gpio register starts at 5h and the trisio starts at 85h. <b>Physical</b> pins are as such:

    1 - +5v
    2 - port 5 I/O
    3 - port 4 I/O
    4 - port 3 / MCLR
    5 - port 2 I/O
    6 - port 1 I/O
    7 - port 0 I/O
    8 - ground

    So, I want to make ports 0,1,2,4 and 5 as outputs, port 3 either as MCLR or not used at all. Pins 1 and 8 obviously serve there own purpose. Here is a graphic of the registers:



    I believe I should be able to use POKE $85, <b>?</b> to set the I/O to output on the pins I need, but at the same time not interfere with the other ports. In my mind, since I want all but the MCLR to be outputs it would look like: <b>POKE $85,%0001000</b> or even <b>POKE $85,%00000000</b> since some are ignored and setting pin 3 to MCLR=ON in my programmer it will select the proper bit on it's own.

    Am I somewhat close on my logic? Using the PBC manual this seems reasonable.

    Thanks.

    Bart
    Last edited by bartman; - 12th November 2004 at 04:44.

  2. #2
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Poke $85,%00001000 is the way to go, which is equivallent to TRISIO=%00001000. You will also have to set CMCON to disable the comparators and ANSEL to disable the ADC's (where appropriate).

  3. #3
    Join Date
    Nov 2004
    Location
    Saskatchewan Canada
    Posts
    189


    Did you find this post helpful? Yes | No

    Default

    I used <b>Poke $85,%00000000</b> and it seemed to work. I didn't use <b>Poke $85,%00001000</b> because I wasn't sure if I considered voltage at MCLR an "input" so to speak and because the data sheet seemed to indicate setting MCLR poked that value properly itself. I'll have to go back and read it again.

    I did also figured out to use the poke command for the comparitor to turn it off and this chip doesn't have ADC so I didn't worry about that. It is still somwhat foggy on it all since usually only some of the 8 bits are used for any one register and I've been assuming to just fill the rest with 0. So far so good. No smoke anyway.

    Bart

Similar Threads

  1. Replies: 4
    Last Post: - 17th April 2009, 08:56
  2. Replies: 1
    Last Post: - 29th September 2007, 18:05
  3. Servo control with 12F629
    By achilles03 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 23rd June 2005, 23:34
  4. PIC16F62X outputs
    By Deadeye in forum General
    Replies: 6
    Last Post: - 31st May 2005, 21:20
  5. Making Array of two ports
    By John7 in forum General
    Replies: 3
    Last Post: - 5th March 2005, 02:20

Members who have read this thread : 1

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