Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] MPLAB and PicKit 3 Debugging problem on PIC16F887

Status
Not open for further replies.

celegorn

Newbie level 5
Newbie level 5
Joined
Jul 31, 2012
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,384
Hello,

I just got my PicKit 3 and i tried to load a simple program to see how the debugging process is supposed to go. This is my rather simple program:
Code:
#include <16f887.h>
#use delay (clock=8000000)
unsigned int16 a;
#fuses HS,NOWDT,NOPROTECT,NOLVP

void main()
{
   SET_TRIS_B(0);

	a=10;
   output_low(PIN_B0);                   
   
   delay_us(20);
   
   while (1)
   {
	a=20;
      delay_ms(1000);       
      output_high(PIN_B0);
      a=35;
      delay_ms(1000);       
      output_low(PIN_B0);    
      
   }
   
}

I tried programming it and it was successful. I removed the PIC and placed it in an actual circuit on a protoboard and it worked (the LED blinked).

But, when i try to debug it, and i press Animate in MPLAB, the arrow pointer gets stuck on the #use delay (clock=8000000) line.

I suppose i am overlooking something basic, but i can't figure it out for the life of me.

Thanks
 

I guess, the debugger stays seemingly endless in the delay loop. Nothing that will work well in animated mode. I'm also not sure if step over will work here. You may need to set breakpoints after the delay_ms() instead.

Enjoy your hardware debugging experience!
 

That was my guess too, FvM. When i press the button Animate, the pointer goes from the top of the code all the way down to the bottom and then starts over again and stops at the #use... line.

Also, when i press the Run button and i look at the watch window with the variable a and the port B shown, they do not change i.e. their values stay the same. Only after i hit Halt their values change, and not in some understandable fashion. For instance, Port B becomes something like binary 00111110.

I put the variable a in the code only so i could monitor it through debugging, but its value doesn't change at all.

By inserting a break point after the delay_ms() lines, the code would stop there and i would be able to see the variable values. Is that your idea?

I saw a guy on youtube run/animate his code and his variables were changing all the time. I would like to be able to do this. I have had problems with a code for months now and i only bought the Pickit 3 for its debugging purposes. I'm hoping to find the error in my code by debugging, but i can't get to debug even this pea of a code.

Thanks, by the way.
 

Usually unexpected behaviour can be understood when switching to disassembly view.

I must confess that I never used animated mode in MPLAB, I'm not sure if it serves a purpose in serious debugging.
 

It's okay. I got the hang of it. The problem occurs when the code gets to the "delay_ms(1000)" line and then it goes into it, but instead of 1000ms, it takes it a lot more (more than 1-2 minutes at least) in "debug time". If i set the same line to "delay_us(10)" the debugger goes through it in 1-2 seconds and i get the same functionality. Then, before programming the pic, i set the delay back to 1000 ms.

Thanks for your input, that made me find my mistake.
 

hello,

the port B becommes 00111110 , is Normal
it's because ICP pins B7 & B6 are connected to pickit3 !
and you must see change on pin B0.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top