• AVR Freaks

Hot!Can't see input on PORTA bit 14

Author
dbvanhorn
New Member
  • Total Posts : 20
  • Reward points : 0
  • Joined: 2019/08/13 07:03:40
  • Location: 0
  • Status: offline
2019/11/06 16:28:21 (permalink)
0

Can't see input on PORTA bit 14

Using a PicKit4 ICE, I have verified the register states commented below.
Using a DVM and a logic analyzer, I have verified that Port A bit 14 (pin 66) is indeed low, very close to 0V.
However, every time I check the pin in software it reads HIGH.
 
CPU is PIC32MX795F512L
Clock is 80 MHz, and peripheral clock is 10 MHz.
Discrete I/O outputs are working, and I'm running SPI correctly, on other pins of course.
I'm new to the PIC32, so I suspect something else is taking over this pin and preventing me from seeing the actual pin state, but I don't know what it would be.
 

int ADC_Check_Data() {
    int temp = 0;

    temp = PORTA; // Get the pin states
    // temp always reads as = 0x0000C0FF regardless of the state of the physical pin.
    temp &= (1 << 14); // mask off all but bit 14
    // Here I always get 0x00004000 Bit 14 is HIGH when the pin itself is LOW.
    // AT THIS MOMENT:
    // LATA = 0x0000C0FF
    // ODCA = 0x00000000
    // PORTA = 0x0000C0FF (shows bit 14 = HIGH)
    // TRISA = 0x0000C0FF (shows bit 14 as INPUT)
    if (0 == temp) {
        return 1;
    } else {
        return 0;
    }
}

 
#1

11 Replies Related Threads

    ric
    Super Member
    • Total Posts : 24202
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Can't see input on PORTA bit 14 2019/11/06 16:40:52 (permalink)
    0
    Have you tried this in a minimal test program? i.e. with nothing else enabled.
    That way you could post the ENTIRE code here for others to verify.
     
    The first function listed on that pin is AETXCLK. Is the Ethernet interface enabled?
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #2
    dbvanhorn
    New Member
    • Total Posts : 20
    • Reward points : 0
    • Joined: 2019/08/13 07:03:40
    • Location: 0
    • Status: offline
    Re: Can't see input on PORTA bit 14 2019/11/07 06:30:19 (permalink)
    0
    Ethernet is disabled.
    // PIC32MX795F512L Configuration Bit Settings
    // 'C' source line config statements
    // DEVCFG3
    #pragma config USERID = 0xFFFF          // Enter Hexadecimal value (Enter Hexadecimal value)
    #pragma config FSRSSEL = PRIORITY_7     // SRS Select (SRS Priority 7)
    #pragma config FMIIEN = OFF             // Ethernet RMII/MII Enable (RMII Enabled)
    #pragma config FETHIO = OFF             // Ethernet I/O Pin Select (Alternate Ethernet I/O)
    #pragma config FCANIO = OFF             // CAN I/O Pin Select (Alternate CAN I/O)
    #pragma config FUSBIDIO = OFF           // USB USID Selection (Controlled by Port Function)
    #pragma config FVBUSONIO = ON           // USB VBUS ON Selection (Controlled by USB Module)

    // DEVCFG2
    #pragma config FPLLIDIV = DIV_2         // PLL Input Divider (2x Divider)
    #pragma config FPLLMUL = MUL_20         // PLL Multiplier (20x Multiplier)
    #pragma config UPLLIDIV = DIV_12        // USB PLL Input Divider (12x Divider)
    #pragma config UPLLEN = OFF             // USB PLL Enable (Disabled and Bypassed)
    #pragma config FPLLODIV = DIV_1         // System PLL Output Clock Divider (PLL Divide by 1)

    // DEVCFG1
    #pragma config FNOSC = PRIPLL           // Oscillator Selection Bits (Primary Osc w/PLL (XT+,HS+,EC+PLL))
    #pragma config FSOSCEN = OFF            // Secondary Oscillator Enable (Disabled)
    #pragma config IESO = OFF               // Internal/External Switch Over (Disabled)
    #pragma config POSCMOD = HS             // Primary Oscillator Configuration (HS osc mode)
    #pragma config OSCIOFNC = OFF           // CLKO Output Signal Active on the OSCO Pin (Disabled)
    #pragma config FPBDIV = DIV_8           // Peripheral Clock Divisor (Pb_Clk is Sys_Clk/2)
    // !!! NOTE SPI seems to break (always busy in 32 bit mode) if DIV_4 or
    // DIV_2 selected.

    #pragma config FCKSM = CSDCMD           // Clock Switching and Monitor Selection (Clock Switch Disable, FSCM Disabled)
    #pragma config WDTPS = PS1048576        // Watchdog Timer Postscaler (1:1048576)
    #pragma config FWDTEN = OFF             // Watchdog Timer Enable (WDT Disabled (SWDTEN Bit Controls))

    // DEVCFG0
    #pragma config DEBUG = OFF              // Background Debugger Enable (Debugger is disabled)
    #pragma config ICESEL = ICS_PGx2        // ICE/ICD Comm Channel Select (ICE EMUC2/EMUD2 pins shared with PGC2/PGD2)
    #pragma config PWP = OFF                // Program Flash Write Protect (Disable)
    #pragma config BWP = OFF                // Boot Flash Write Protect bit (Protection Disabled)
    #pragma config CP = OFF                 // Code Protect (Protection Disabled)


    #3
    dbvanhorn
    New Member
    • Total Posts : 20
    • Reward points : 0
    • Joined: 2019/08/13 07:03:40
    • Location: 0
    • Status: offline
    Re: Can't see input on PORTA bit 14 2019/11/07 10:24:50 (permalink)
    0
    I've also added a line to disable the I2C port that shares that pin, writing 0 to it's control register.
    It's supposed to be disabled by default anyway, but now I'm sure.
    Still no change, I can tie that pin hard low, and the processor continues to tell me that it's high.
     
    I also can't toggle that pin as an output, which further confirms it's been grabbed by some peripheral though I have no idea what.    (yeah, I know about port a toggle but I wanted to be sure my LA could see it.)
     

        TRISACLR = (1 << 14); //Make it an output
        while (1) {
            PORTACLR = (1 << 14); //low
            PORTASET = (1 << 14); //high
        } 

    post edited by dbvanhorn - 2019/11/07 13:39:34
    #4
    jg_ee
    Super Member
    • Total Posts : 172
    • Reward points : 0
    • Joined: 2015/04/30 10:54:52
    • Location: Colorado
    • Status: offline
    Re: Can't see input on PORTA bit 14 2019/11/07 13:50:53 (permalink)
    0
    I tried it quickly on a simple program on a development board and saw no issue with that pin by default.  Ric's suggestion is great for you to make a simple program to start and see if it still happens.  This will let you catch all kinds of issues with both your firmware or your test setup, things we can only guess at.
    #5
    dbvanhorn
    New Member
    • Total Posts : 20
    • Reward points : 0
    • Joined: 2019/08/13 07:03:40
    • Location: 0
    • Status: offline
    Re: Can't see input on PORTA bit 14 2019/11/07 14:28:45 (permalink)
    0
    Ok.. That got me exactly what I already have..
    Is it possible that the Ethernet peripheral is still on regardless of the pragmas?
    ALL the bits in all the registers under Ethernet Controller are "0"
     
     
     

    // 8 MHz Xtal, FPLLIDIV = DIV_2 sets 4 MHz into PLL
    // FPLLMUL = MUL_20 sets 80 MHz output from PLL
    // FPLLODIV = DIV_1 sets 80 MHz CPU clock.
    // Ideally, FPBDIV = 4 would set 20 MHz I/O clock for SPI but that
    // does not seem to work.  SPI reports busy always in 32 bit mode, but
    // ok in 8 bit mode.

    // PIC32MX795F512L Configuration Bit Settings
    // 'C' source line config statements
    // DEVCFG3
    #pragma config USERID = 0xFFFF          // Enter Hexadecimal value (Enter Hexadecimal value)
    #pragma config FSRSSEL = PRIORITY_7     // SRS Select (SRS Priority 7)
    #pragma config FMIIEN = OFF             // Ethernet RMII/MII Enable (RMII Enabled)
    #pragma config FETHIO = OFF             // Ethernet I/O Pin Select (Alternate Ethernet I/O)
    #pragma config FCANIO = OFF             // CAN I/O Pin Select (Alternate CAN I/O)
    #pragma config FUSBIDIO = OFF           // USB USID Selection (Controlled by Port Function)
    #pragma config FVBUSONIO = OFF           // USB VBUS ON Selection (Controlled by USB Module)

    // DEVCFG2
    #pragma config FPLLIDIV = DIV_2         // PLL Input Divider (2x Divider)
    #pragma config FPLLMUL = MUL_20         // PLL Multiplier (20x Multiplier)
    #pragma config UPLLIDIV = DIV_12        // USB PLL Input Divider (12x Divider)
    #pragma config UPLLEN = OFF             // USB PLL Enable (Disabled and Bypassed)
    #pragma config FPLLODIV = DIV_1         // System PLL Output Clock Divider (PLL Divide by 1)

    // DEVCFG1
    #pragma config FNOSC = PRIPLL           // Oscillator Selection Bits (Primary Osc w/PLL (XT+,HS+,EC+PLL))
    #pragma config FSOSCEN = OFF            // Secondary Oscillator Enable (Disabled)
    #pragma config IESO = OFF               // Internal/External Switch Over (Disabled)
    #pragma config POSCMOD = HS             // Primary Oscillator Configuration (HS osc mode)
    #pragma config OSCIOFNC = OFF           // CLKO Output Signal Active on the OSCO Pin (Disabled)
    #pragma config FPBDIV = DIV_8           // Peripheral Clock Divisor (Pb_Clk is Sys_Clk/2)

    #pragma config FCKSM = CSDCMD           // Clock Switching and Monitor Selection (Clock Switch Disable, FSCM Disabled)
    #pragma config WDTPS = PS1048576        // Watchdog Timer Postscaler (1:1048576)
    #pragma config FWDTEN = OFF             // Watchdog Timer Enable (WDT Disabled (SWDTEN Bit Controls))

    // DEVCFG0
    #pragma config DEBUG = OFF              // Background Debugger Enable (Debugger is disabled)
    #pragma config ICESEL = ICS_PGx2        // ICE/ICD Comm Channel Select (ICE EMUC2/EMUD2 pins shared with PGC2/PGD2)
    #pragma config PWP = OFF                // Program Flash Write Protect (Disable)
    #pragma config BWP = OFF                // Boot Flash Write Protect bit (Protection Disabled)
    #pragma config CP = OFF                 // Code Protect (Protection Disabled)

    // #pragma config statements should precede project file includes.
    // Use project enums instead of #define for ON and OFF.

    #include <xc.h>

    void main(void) {

        int temp;

        while (1) {
            //while (1) {
                TRISACLR = (1 << 14); // Output
                PORTASET = (1 << 14); // Toggle
                PORTACLR = (1 << 14); // <-- I/O pin is solidly low when this loop runs
            //}
            TRISASET = (1 << 14); // Input
            temp = PORTA;
            temp &= (1 << 14); //Mask off all but bit 14
            if (0 == temp) {
                while (1) {
                    temp++; // hang here if input is low <-- Never gets here even when RA14 is hard grounded.
                }
            } else {
                while (1) {
                    temp++; // hang here if input is  high <-- Hangs here
                }
            }
        }
    }



    #6
    jg_ee
    Super Member
    • Total Posts : 172
    • Reward points : 0
    • Joined: 2015/04/30 10:54:52
    • Location: Colorado
    • Status: offline
    Re: Can't see input on PORTA bit 14 2019/11/07 14:41:59 (permalink)
    0
    I just copied your code into a blank project and tried it with the pin both tied high and tied low, and it goes into the correct while(1) loops.  Not sure what is going on with your setup.
    #7
    jg_ee
    Super Member
    • Total Posts : 172
    • Reward points : 0
    • Joined: 2015/04/30 10:54:52
    • Location: Colorado
    • Status: offline
    Re: Can't see input on PORTA bit 14 2019/11/07 14:43:48 (permalink)
    0
    I would check very hard that you are looking at the correct pin on your PCB.
     
    #8
    dbvanhorn
    New Member
    • Total Posts : 20
    • Reward points : 0
    • Joined: 2019/08/13 07:03:40
    • Location: 0
    • Status: offline
    Re: Can't see input on PORTA bit 14 2019/11/07 14:45:22 (permalink)
    0
    I metered it, and I see continuity to that pin.
     
    I've now been on the phone with my uChip rep for about an hour, he has the same dev kit, and is hitting the same problem.
    Best both of us can tell, the schematic is correct, and we should be seeing that pin working, but it's not.
     
    The board is the ADM00583 with the provided PIM.
    J13 is on, and the ADC is configured for open collector output on its INT pin, which per schematic and meter ends up on pin 66 of the CPU, RA14.
     My LA is connected to J14, and is seeing the ADC sending periodic ints as it completes aquisition, but I can't see the INT pin (RA14) go low, so I never know it's time to read the data..
     
     
    post edited by dbvanhorn - 2019/11/07 15:42:03
    #9
    dbvanhorn
    New Member
    • Total Posts : 20
    • Reward points : 0
    • Joined: 2019/08/13 07:03:40
    • Location: 0
    • Status: offline
    Re: Can't see input on PORTA bit 14 2019/11/08 09:40:48 (permalink)
    0
    Found it.  The ADM00583 docs are not correct.   The /INT signal is wired to pin 66 of the PIM but that connects to RE8 not RA14!  I saw the signal on the PIM pin and assumed that the PIM was wired with pin 66 of the CPU to pin 66 of the PIM (like why would you do anything different?)
     
    It's all working now, on to the next task.
    #10
    jg_ee
    Super Member
    • Total Posts : 172
    • Reward points : 0
    • Joined: 2015/04/30 10:54:52
    • Location: Colorado
    • Status: offline
    Re: Can't see input on PORTA bit 14 2019/11/08 14:16:27 (permalink)
    0
    Glad you got it figured out.  Good reason to meter all of the way to the pins.
    #11
    ric
    Super Member
    • Total Posts : 24202
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Can't see input on PORTA bit 14 2019/11/08 14:17:29 (permalink)
    0
    .... all the way to the PIC pins. :)

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #12
    Jump to:
    © 2019 APG vNext Commercial Version 4.5