Electronic Circuits and Projects Forum


Simple debugging question

Results 1 to 2 of 2
Reply to Thread
  1. #1
    chris414
    chris414 is offline

    Default Simple debugging question

    I apologize in advance if I'm being an idiot, but would someone please put me out of my misery and tell me how to watch a variable while debugging in MPLAB?
    All I'm trying to do is watch the value of an integer variable which should be changing as I change the voltage applied to a pin. I've copied part of the code in below incase it's relavent to my question (I want to know the value of "result"):

    Code:
    	while(1)
    	{	
    	
    		OpenADC(ADC_FOSC_32 &
    					ADC_RIGHT_JUST &
    					ADC_12_TAD,
    					ADC_CH0 &  
    					ADC_INT_OFF &
                        ADC_REF_VDD_VSS, ADC_1ANA);
    		ConvertADC();         // Start conversion
      		while( BusyADC() );   // Wait for completion
    		result = ReadADC();   // Read result
      		CloseADC();           // Disable A/D converter
    		
    		
    		
    		if(result>50)
    		{
    			LEDPin = 1;
    		}
    		else
    		{
    			LEDPin = 0;
    		}
    	}
    I am using a PIC18F2550 with a PICKit2, the MPLAB IDE and MPLAB C18 Lite compiler.
    Last edited by chris414; 15th December 2009 at 04:01 PM.

  2. #2
    Wp100
    Wp100 is offline
    Hi,

    Build your project and open Debugger, before Runnning the code goto the View menu and open the File Registers (Down/restore that screen) and then you can also open a Watch Window where you can add in which system registers you may also want to see like ADRESL etc.

    Once you have organised all those windows on your desktop, press f7 to single step through your code and watch the registers change.

    If you have long delays etc, then use Breakpoints in your code, so you can F9 Run past the delay bit and then resume the single step.

Reply to Thread

Similar Threads

  1. 16F88 MPLAB debugging question
    By futz in Microcontrollers
    Replies: 4
    Latest: 1st March 2008, 05:40 AM
  2. Help debugging
    By fiveten in Electronic Projects Design/Ideas/Reviews
    Replies: 5
    Latest: 23rd March 2005, 10:07 PM
  3. debugging
    By TKS in Microcontrollers
    Replies: 11
    Latest: 14th May 2004, 10:18 PM
  4. very simple question
    By xjackal in General Electronics Chat
    Replies: 10
    Latest: 25th November 2003, 06:50 PM
  5. Just a simple question...
    By Appleon in Electronic Projects Design/Ideas/Reviews
    Replies: 1
    Latest: 15th September 2003, 04:47 AM