reading I/O state of pic12f675...


Results 1 to 22 of 22

Threaded View

  1. #7
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: reading I/O state of pic12f675...

    I read the data sheet... but , to be sure : have you some sample to help in setting the register please ?
    The datasheet says: The ANSEL (9Fh) and CMCON (19h) registers (9Fh) must be initialized to configure an analog channel as a digital input.
    So lets start with ANSEL (page 44 in the datasheet)where the lower four bits determines if AN0-AN3 should be analog (which they are by default) or digital. These bits needs to zero for the pins to be digital and since you're not using the ADC the state of the other bits doesn't matter, therefor ANSEL = 0 will do just fine.

    Next. CMCON, figure 6-2 (page 37) in the datasheet shows the various configurations, you don't want to use the comparator so it should be off, therefor CMCON = 7

    Finally you say that you need three inputs and three outputs but not which pins should be what so I can't tell you more than that you need to set TRISIO up with a '1' for each input and a '0' for each output. Remember that the MCLR-pin (GP3) can not be configured as an output.

    Code:
    ANSEL = 0
    CMCON = 7
    TRISIO = %00111000 ' GP0-GP2 outputs, GP3-GP5 inputs.
    /Henrik.
    Last edited by HenrikOlsson; - 9th May 2017 at 10:10.

Similar Threads

  1. Knowledge of State Variable Filters
    By Lucy248 in forum General
    Replies: 1
    Last Post: - 9th September 2016, 08:56
  2. Changing output state after 2 minutes
    By carljbrooks in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 21st February 2014, 05:28
  3. DC - AC Solid State Relay
    By shahidali55 in forum General
    Replies: 6
    Last Post: - 10th November 2007, 16:01
  4. State machine programming
    By tjstevens in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 17th April 2007, 22:45
  5. Replies: 2
    Last Post: - 27th March 2007, 12:48

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