Pic mappable pins?

Discussion in 'Embedded Systems and Microcontrollers' started by spinnaker, Jan 29, 2012.

  1. spinnaker

    Thread Starter AAC Fanatic!

    Oct 29, 2009
    4,884
    1,005
    I have a Pic with mappable pins. Really cool concept in my opinion. I can imagine how useful this might be to be able to change the function of a pin with code.

    I have a couple of questions.

    Why do I need to unlock the configuration of these pins before I can configure their function? Why can't I just write to the control register just like any other control register? I would think that if your code is properly written the configuration won't accidentally be changed.

    To configure outputs, you write the function code to a control register. There is one control register for every mappable pin.

    But to configure inputs. there is one control register for every function. You write the number of the pin to the configuration register.

    Why on earth would you configure the function of the pin so differently between input and output?
     
  2. nigelwright7557

    Senior Member

    May 10, 2008
    487
    71
    The PICs have become quite complex over the years with lots of extra functions hence the complaicted I/O arrangement to program them.
     
  3. spinnaker

    Thread Starter AAC Fanatic!

    Oct 29, 2009
    4,884
    1,005
    I noticed that several of the peripherals have this "locking" function. I wonder if it has something to do with the intended application?

    But I just wonder why the output config is different from the input config.
     
  4. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    All pins can be outputs rather easily, low or high.

    To remap inputs, it takes a couple jumps of pointers, which is the closest word I can come up with, to make sure all the functions for an analog pin are available. ADC, comparator, Vref, etc. are still hardwired, but the rest of the silicon needs to check two lookup tables to get the right analog function to the pin.

    Think of it as a LATX buffer for inputs as there is for outputs, even though it's configured.
     
  5. atferrari

    AAC Fanatic!

    Jan 6, 2004
    2,648
    763
    18F family has them?
     
    Last edited: Jan 30, 2012
  6. spinnaker

    Thread Starter AAC Fanatic!

    Oct 29, 2009
    4,884
    1,005
    Yes 18F27J53 for one.
     
  7. spinnaker

    Thread Starter AAC Fanatic!

    Oct 29, 2009
    4,884
    1,005
    So they call it "Unlock" but really it is more of an initialization?
     
  8. nsaspook

    AAC Fanatic!

    Aug 27, 2009
    2,908
    2,168
  9. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    I understand it better looking at it that way, yes.
     
  10. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,387
    1,605
    It's called "unlock" as it is intentionally harder to change these things. That keeps crashing code from randomly resetting pin functions.

    I saw this back in '06 in some SiLabs products and have been waiting for Microchip to catch up ever since.
     
Loading...