• AVR Freaks

Hot!Pic32MZ2048 RG7 as input

Author
alcor777
New Member
  • Total Posts : 6
  • Reward points : 0
  • Joined: 2018/05/31 16:37:24
  • Location: 0
  • Status: offline
2019/04/23 08:40:34 (permalink)
0

Pic32MZ2048 RG7 as input

Dear all,
 
I spent a lot of time checking this, with a very simple code, but RG7 that I've set as input (as other I/O port) does not behave as it should, and does not input any data. I've check with a logicial analyzer and input is OK (signal tooges OK) but software wise I just read zeros.
Since this is a mutipurpose port, it needs to be iniatilized as it should, but I cannot find th issue. 
Simply I did ->
TRISGbits.TRISG7=1
like other I/O that works.
 
Help appreciated.
 
#1

7 Replies Related Threads

    mbrowning
    Just a Member
    • Total Posts : 1458
    • Reward points : 0
    • Joined: 2005/03/16 14:32:56
    • Location: Melbourne, FL
    • Status: online
    Re: Pic32MZ2048 RG7 as input 2019/04/23 09:09:11 (permalink)
    4 (1)
    Did you turn off the analog input buffer on that pin?
    Did you enable the digital input buffer on that pin?
     
    edit - forgot that ANSEL controls the digital buffer - the analog buffer is always on.
    post edited by mbrowning - 2019/04/23 10:13:05

    Oh well - there's always next year
    #2
    alcor777
    New Member
    • Total Posts : 6
    • Reward points : 0
    • Joined: 2018/05/31 16:37:24
    • Location: 0
    • Status: offline
    Re: Pic32MZ2048 RG7 as input 2019/04/23 09:18:25 (permalink)
    0
    No, and I do not know how to proceed sad: sad 
    I could find the 600 page datasheet the state of the I/O port on reset.
    I did a wire to RD0 and this is OK there. For sure a software init issue on RG7 but I cannot find why...
     
    post edited by alcor777 - 2019/04/23 09:36:44
    #3
    Mysil
    Super Member
    • Total Posts : 3326
    • Reward points : 0
    • Joined: 2012/07/01 04:19:50
    • Location: Norway
    • Status: offline
    Re: Pic32MZ2048 RG7 as input 2019/04/23 09:46:00 (permalink)
    4 (1)
    Hi,
    On the board I use, I have used RG7  for I2C SDA signal,
    both bitbanging as a general purpose I/O, and using the peripheral.
    It works for me: 
        TRISGbits.TRISG7 = 1;        /* This is same as reset default. */
        ANSELGbits.ANSG7 = 0;      /* This is needed to enable digital input buffer. */
     
    Pin RD0 is part of a Port that have all pins Digital-Only, so all pins on port D have digital input enabled always.
     
    Port G have some pins that may be used for Analog inputs, and some pins that are Digital-Only.
    There is ANSELG register that disable Digital input amplifiers, when analog input is used.
    Since the Pin may be connected to a analog input signal with any voltage within the power supply range,
    digital inputs must be disabled when the chip is Reset.
     
    Reset state of registers are documented in the datasheet.
    TABLE 12-15:    PORTG REGISTER MAP FOR 100-PIN, 124-PIN, AND 144-PIN DEVICES ONLY
    Reset values are in the very righthand column.
     
    Description is in chapter 12  I/O Ports,
    section 12.1.2    CONFIGURING ANALOG AND DIGITAL PORT PINS
     
        Mysil
    post edited by Mysil - 2019/04/23 10:08:32
    #4
    alcor777
    New Member
    • Total Posts : 6
    • Reward points : 0
    • Joined: 2018/05/31 16:37:24
    • Location: 0
    • Status: offline
    Re: Pic32MZ2048 RG7 as input 2019/04/23 10:30:16 (permalink)
    0
    Solved ! Awsome ...
    Do you know, where one can find all these tricks ?
    Many thanks. 
    #5
    Mysil
    Super Member
    • Total Posts : 3326
    • Reward points : 0
    • Joined: 2012/07/01 04:19:50
    • Location: Norway
    • Status: offline
    Re: Pic32MZ2048 RG7 as input 2019/04/23 13:28:25 (permalink)
    5 (2)
    Practice makes perfect.
     
    You cannot absorb everything at once, programming is an iterative activity:
    Read the manual, make code, try it out, read more, make changes, try again ... 
     
    People or plans that say to plan everything first, and then make it all in one go, are living in a dream.
     
        Mysil
    #6
    qhb
    Superb Member
    • Total Posts : 9998
    • Reward points : 0
    • Joined: 2016/06/05 14:55:32
    • Location: One step ahead...
    • Status: offline
    Re: Pic32MZ2048 RG7 as input 2019/04/23 14:16:31 (permalink)
    5 (1)
    alcor777
    Do you know, where one can find all these tricks ?

    It's not a trick, it is documented in the datasheet.
    If you go back now, and read the GPIO port section of your PIC's datasheet, you will find this information is there.

    Nearly there...
    #7
    Howard Long
    Super Member
    • Total Posts : 676
    • Reward points : 0
    • Joined: 2005/04/04 08:50:32
    • Status: online
    Re: Pic32MZ2048 RG7 as input 2019/04/23 14:56:50 (permalink)
    5 (1)
    While it might seem hard to take, sometimes learning from one’s own mistakes is often the best way to learn. You tend to be less likely to forget that way.

    FWIW, by default I frequently set all the ANSELs to digital as one of the first things I do.

    You see, once, sometimes many years ago, all of us have been there!
    #8
    Jump to:
    © 2019 APG vNext Commercial Version 4.5