A rant about port configurations


Closed Thread
Results 1 to 24 of 24

Hybrid View

  1. #1
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: A rant about port configurations

    My wife and I have an agreement "I am always right - unless she's right"!
    My approach is a little different:
    She is always right, and I am always happy. It took me many years to realize the reason men work is to be right sometimes. At home - just happy
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  2. #2
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: A rant about port configurations

    I really like Darrel's idea...at least with everything off, you know that you have to turn whatever you need on! (whereas at the minute even the stuff you want to turn on, might conflict with something else that's already turned on!)

    Over time (& with starting to get a grip of this stuff), I find myself turning most stuff off at the top of my program anyway.

    Would it be quick (or even possible) to do a 'switch off everything' header?

  3. #3
    Join Date
    Sep 2008
    Location
    Maine, USA
    Posts
    81


    Did you find this post helpful? Yes | No

    Default Re: A rant about port configurations

    Quote Originally Posted by HankMcSpank View Post
    Would it be quick (or even possible) to do a 'switch off everything' header?
    Cool! I LIKE that. Darrell - does that sound feasible? Is it "just code"? I would totally value a header that disables ALL peripherals so I could knowingly start from a clean slate.
    "Do or do not, there is no try" Yoda

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: A rant about port configurations

    That's the point!
    Everything is already OFF.

    Except the comparators on old chips, which can be turned off easily with ...
    INCLUDE "AllDigital.pbp"
    But that also enables all Digital Inputs, so technically everything's not OFF anymore.

    Some REALLY OLD 12-bit chips made the T0CKI pin unable to control the TRIS bit while TMR0 was "OFF".
    So that's about the extent of the "Turn it all off" header wizard.

    ; if chip has a 12-bit core
    OPTION_REG.5 = 0 ; Free TRISIO.2 bit

    But then again, you're really turning something ON (TMR0).

    Don't worry about turning things OFF.
    Turn stuff ON if you want to use it.
    DT

  5. #5
    Join Date
    Sep 2008
    Location
    Maine, USA
    Posts
    81


    Did you find this post helpful? Yes | No

    Default Re: A rant about port configurations

    Thanks for that Darrell. Thing is I only need to learn a new PIC every 12-18 months, so I tend to forget how to set them up. I had really never seen it as "everything is already OFF". As I blunder around a new spec sheet I get distracted by all the registers and features and tend to lose sight of the basics.
    Sometimes it takes someone like you to make the obvious clear. Like Charles, I tend to start off in shotgun mode and try setting all the registers. I see now that I have to think of the PIC as a blank slate (except for the comparators).

    I guess I should re-word my rant to: "Why the heck do PIC chips all come with the blasted comparators enabled by default!" That has always tripped me up in the past. I don't see the reasoning behind it personally. Never used the comparator feature in all my years of PICing (15 and counting). But then I'm a simple soul...
    "Do or do not, there is no try" Yoda

  6. #6
    Join Date
    Mar 2005
    Location
    Cocoa, Florida
    Posts
    43


    Did you find this post helpful? Yes | No

    Default Re: A rant about port configurations

    Great timing as this exact problem has just consumed about 5 hours and I seem to hit a similar brick wall with every new PIC.

    18F27J53 ~ outputs OK, inputs always read 0.
    I know what the problem is, just can't fix it. Is there something else besides ADCON that needs setting?

    Datasheet: ADON: A/D On bit 1 = A/D Converter module is enabled 0 = A/D Converter module is disabled
    Tried ADCON0 = $0F, ADCON0 = %00000000 and all the individual bits such as ADCON0.0 = 0.

    Instead of a rant at Microchip, this should be a programming project or feature request for the IDE.
    Heck, if I knew how to set ADCON, I'd program it myself...

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


    Did you find this post helpful? Yes | No

    Default Re: A rant about port configurations

    Hi,
    The ADCON register controls the the actual converter, not the input buffers of the pins. For the 27J53, check the ANCON0 and ANCON1 registers, page 371 in the datasheet.
    The ANCON0 and ANCON1 registers are used to configure the operation of the I/O pin associated with each analog channel. Setting any one of the PCFG bits configures the corresponding pin to operate as a digital
    only I/O. Clearing a bit configures the pin to operate as an analog input for either the A/D Converter or the comparator module. All digital peripherals are disabled and digital inputs read as ‘0’. As a rule, I/O pins that are multiplexed with analog inputs default to analog operation on device Resets.
    Looking up ANCON0 and ANCON1 in table 5.1 (page 76) shows that they default to all zeros at POR meaning that when the chip powers up all analog pins are analog.

    /Henrik.

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