Jump to content
Sign in to follow this  
Thermal Runaway

Target Only Runs When Progam Compiled In Debug Mode

Recommended Posts

Hi everyone,


I've started a new project, and as part of that I wanted to re-use some of my character LCD code that I developed for another project, under Hitech PICC. I ported the code over to BoostC earlier today, and I've been racking my brains trying to get it working ever since.


Eventually I found that when I step through my code using the Pickit 3 ICD, then my LCD display initialises properly and displays the required message. It also worked if I allowed the code to free-run in debug mode. For a while this sent me down the path of debugging my delay routines - I thought that perhaps the delays were not working properly and hence causing my issue.


As it happens I did find a problem with my delay routine but fixing it didn't resolve the problem. The LCD would not initialise or display any characters unless I ran it in the debugger.


Now for the really weird bit...


I've since found out (just now, actually) that if I select the Pickit3 ICD, then compile my program, then select the Pickit3 programmer and program my target device, the program works flawlessly. But if I immediately recompile (this time without first selecting ICD) and reprogram my target device, it returns to the original fault symptom. It seems as if my target device does not run when compiled in the normal manner, because I reduced my code to a simple "set all of porta ON" program and it couldn't even manage that.


Yet, if I first select the Pickit3 ICD, compile my code, then switch back to Pickit3 programmer mode and program my target device... works like a charm.


Has anyone else experienced this? I keep accusing myself of doing something stupid with my config words or something like that, but nope - I've checked it many times and it all seems fine to me. The target device is a PIC16F1936 and it's the first time I've used one of these so I guess it's possible I've done something silly with either the CONFIG words or one of the other registers. It must be something that isn't effected when the program is compiled in debug mode.


Bizarre. I'm going to meditate over the datasheet.



Edited by Thermal Runaway

Share this post

Link to post
Share on other sites

tut, I've found the problem. And yes, I was being stupid with my config words :(


This is the first time I've used in circuit debugging, and I didn't realise that by setting the config option "Debug" to ON, you were restricting the device to debug only. It sounds obvious now, especially when I put it like that, but at the time I just thought setting the debug option in the config word would effectively tie up the ICSPDAT and ICSPCLK pins for debug purposes only (i.e. not available for I/O). I didn't realise that you couldn't just use the device in the normal manner if you wanted to.


Not to worry, sorted now! I certainly won't be making that mistake again any time soon.



Share this post

Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Create New...