PIC16F1939 - problems with watches on mplab

Discussion in 'Embedded Systems and Microcontrollers' started by hunterage2000, Apr 29, 2016.

  1. hunterage2000

    Thread Starter Active Member

    May 2, 2010
    400
    0
    Hi, Im new to pic programming and started looking into debugging. I have ran the attached project in debug mode and set a watch on PORTA. I am stepping through the program line by line but the PORTA watch isnt changing from 0x00 to 0xFF. Any ideas why?
     
  2. dannyf

    Well-Known Member

    Sep 13, 2015
    1,825
    364
    set the pins to the gpio mode - datasheet has directions on how to do that.
     
  3. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,394
    1,606
    Ports have a TRIS gister to set them as either input or output. The default at power on is to be an input. So to use them as an output you need to set the TRIS register first as an initialization. each port pin has a bit to control it.

    Note to set as 1nput you set the bit to one. To set are an 0utput you set to zero.

    Additionally, if the pin shares an analog function the default is to be analog, so you also need to turn that off.

    The data sheet on the ports will define all the registers associated with that port so you need not guess which you need to change.
     
  4. hunterage2000

    Thread Starter Active Member

    May 2, 2010
    400
    0
    I noticed when opening up mplab there was a message saying "trace is disabled enable in project properties". I have enabled this and now it is working.

    The problem I have now is after finishing the debug session some device programming options are greyed out (see attached). Anyone know why?
     
  5. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,394
    1,606
    Those look like the buttons to program a physical device.

    Do you have your programmer attached to your PC?
     
  6. JohnInTX

    Moderator

    Jun 26, 2012
    2,347
    1,029
    For most devices, you have to rebuild in RELEASE mode to remove debugger hooks from the code. Make another configuration with no debugger specified and select that on the toolbar. As ErnieM indicated, you have to have the device connected and powered as well.
     
  7. hunterage2000

    Thread Starter Active Member

    May 2, 2010
    400
    0
    Right I see. I still had simulator selected in project properties so changed it back to pickit3
     
Loading...