PIC16F1939 - problems with watches on mplab

Thread Starter

hunterage2000

Joined May 2, 2010
487
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?
 

Attachments

ErnieM

Joined Apr 24, 2011
8,045
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.
 

Thread Starter

hunterage2000

Joined May 2, 2010
487
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?
 

Attachments

JohnInTX

Joined Jun 26, 2012
4,111
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.
 
Top