• AVR Freaks

Issues reading digital inputs in Debug

Author
Simone190788
New Member
  • Total Posts : 2
  • Reward points : 0
  • Joined: 2021/02/25 08:31:31
  • Location: 0
  • Status: offline
2021/02/26 04:42:22 (permalink)
0

Issues reading digital inputs in Debug

I am new with Microchip microcontrollers and I have some problem during debug of my program, and in particular I can't read the digital inputs.
 
I'm using the Evaluation Board with PIC16F18855 MCU, connected to my PC through the USB port.
 
I use MCC Code Configurator Plug In in MPLAB X IDE v5.45 just setting pin RA0 as digital output, and pin RA1 as digital input (see the attached image "Digital_IO.jpg").
 
Generating the code, I find the MCC generated files included in my project, just put a NOP operation in the while loop, and set a breakpoint to that line to stop the debug.
 

void main(void)
{
    while (1)
    {
        NOP(); /* breakpoint at this line */
    }
}

 
To force the digital input to 1, I connected the RA1 pin of the evaluation board to the 3.3V pin using a wire, and I see the D3 LED turn on correctly (see the attached image "EV_Board.jpg").
 
When I start the debug in MPLAB X IDE, the program halts at the NOP line, and I put the values of the register PORTA in the Watches window to see the values of that pins, but that register is always 0 (see the attached image "Watches.jpg").
 
How can I read that input? Am I missing something? Thanks all for reply, I hope someone can help me soon.
 
Best regards,
Simone.

Attached Image(s)

#1

1 Reply Related Threads

    RISC
    Super Member
    • Total Posts : 6056
    • Reward points : 0
    • Status: offline
    Re: Issues reading digital inputs in Debug 2021/02/26 08:06:17 (permalink)
    +2 (2)
    Hi,
    I suggest you read / follow this tutorial : https://microchip.wikidot.com/mcu1101:start
    You will better understand the different steps to properly setup GPIO.
    It is also better to have a vairable in your program to read out the GPIO status and stoping your software after that operation.
    In PICs GPIO which have also an analog function default as analog inputs....it is mandatory to set the pin as digital to have a proper behaviour.
    I also encourage you to look at the examples in MPLABXPRESS cloud version. There are some example for your board and PIC as far as I remember : https://mplabxpress.microchip.com/mplabcloud/ide
    Regards 

    For support make sure to check first here : http://microchipdeveloper.com
    There are hundreds of PIC, AVR, SAM...which one do YOU use ?
    #2
    Jump to:
    © 2021 APG vNext Commercial Version 4.5