Circuit schematic for a PIC12F508 hardware-debugging board

Thread Starter

q12x

Joined Sep 25, 2015
747
Hello to everyone, I have a very special project to make and I very much like your assistance on it.
- I know, I know it SOUNDS fancy and problematic. But I thought on the principle of operation of such device and is NOT that BAD as it sounds. So please Read my IDEA and I KNOW we can make it !
The history and context:
- I am coming right now from PIC forums, and there, I discussed a lot of things, and between them was the subject of "How to debug" a PIC12F508? And I got the typical nope, its too complex and unreachable for you. They will not easily give away some very important tool like a hardwae-debugger circuit anyway. In the same time I was intrigued by how Well one user there, was able to code the PICs, especially my old PIC, especially on some very delicate code problems like Very precise timing calculation.
q12: "- How do you debug your code lines?" Answer:" I have a prototype board made and connected to an emulator or a debugger. Usually I know what my code will do when I wrote them; so the board and emulator/debugger are just to test, debug and modify the code as needed. I don't use test LEDs much, as I prefer to use an oscilloscope; for digital signals, a logic analyzer will help." He said is making the code in his head first, or with pen and paper, and I really admire such skill, but for a dude like me, I think is easier using a serious debugger, hardware type, not software. Their software debugger is too advanced and too cryptic !!! Thats another reason why I have to "invent" such a hardware device myself. They actually told me to: "be ingenious and find a way", and in a sense, I totally agree with them.
This is one of their official recommendation: "... In-Circuit-Debug tool for the PIC12F508 the AC162059 debug adapter is required"...
1637371759832.png1637371809064.png
These are some pictures of the AC162059 device from internet.
Another of their comments that made me think on a different solution: "Microchip has disconnected the AC162059 product. Some old stock may be available but it is expensive."
So this is how this device works: "When choose "debugging" and start a debug session your program is "programmed" to the PIC alongside some extra code, known as the "debug executive". Is this "debug executive" that works with the hardware special debug resources and "talks" with MPLAB software to allow the debugging operations. The presence of this extra code means your own program cannot run by itself. Is also this "debug executive" that uses the "reserved resources" listed for each PIC and debugging tool." I dont like it this way, at all.

Step1:
- I did think on this problem some time and I believe I find a solution, at least the logical dots I can connect and create my own Universal Hardware Debugging Board for PICs !!!
Some time ago, I build this Programer Test Board. It is mostly composed of many wires!!! Really, that's all there is to it. that are hooked to the pickit2 programmer (the BLACK box), and to the actual PIC12F508 there in the image with a green paper on it. I also added smd leds and a button to test the programmed PIC. This little circuit I made and already used very successfully, is a very nice alternative for the original test board that I used as reference, it's official name, google for "PIC Demo Board" (is this big green board)
1637371661337.png 1637371716064.png1637374931189.png

Step2:
Usually, my 12F508 runs from it's internal 4Mhz RC oscillator option, but it can be connected from an external clock with different frequency. I know for certain, that we can use PICs at very low clock cycle ! What it means, is PIC can run it's program one instruction per 1 second if I hook it to a 1second pulse beating circuit.
In other words, I have to set the PIC to an external oscilator from it's internal registers code, and literally link its pins to this external oscilator that happens to variate its frequency from a potentiometer.

Step3:
I believe the guys on MIcrochip are VERY smart. I also believe their hardware debugger AC162059 is -one possible variant- of debugging a PIC. I think there are easier ways of debugging a PIC and more universal and more intuitive.
My plan is to make a similar board like my"test board", but with some extra hardware around it. That hardware will BASICALLY slow down the beating cycles of the chip code, in other words, the chip will run its code at a lower speed.
I believe it all comes down to a potentiometer on that board that will delay the pulses to as much as 1 pulse per 1 second. That's my plan.
This is the whole idea of this Universal Hardware Debugging Board for PICs.

Technical problems to resolve:
1- a pulse generator that can be adjusted by a potentiometer to pulse up to 4Mhz.
2- a step by step button that is linked to the pulse generator, and when I press the button, the pulse generator pulses 1 time and waits for another button press. The button is not linked to the PIC, but to the pulse generator. Ok?
3- a reset button to reset the entire chip program to start over again, and I think this is as simple as cutting the power of the PIC and power it again, and its code will be reset to Start. This might be a simple task like that. I'm not completely sure...
4- I also want the pulse generator to be switched to 8Mhz and 12Mhz. I believe every PIC is "safely" set to 4Mhz but in reality it can run at much more higher speed than it's official specifications. It's a personal impression, so I have to test this theory.
5- Im open to any other debug suggestions you may have.

- Can you assist me with it?
As always, thank you !
 
Last edited:

BobTPH

Joined Jun 5, 2013
4,236
12f508 is an ancient, obsolete chip with no hardware debug capabilities and very limited memory. For less money you can get a newer chip like the 16F15313 that runs 8 times faster, has nearly 5 times the program memory, 10 times the ram, way more peripherals, and built in hardware debugging.

So, no, I think is a waste of time.

Bob
 

ErnieM

Joined Apr 24, 2011
8,213
Back in the day I think I used that exact chip in some application, perhaps even having the AC162059 debugger. I had one of them anyway.

The PIC12F508 has but 8 pins. Two for power and ground, and to debug you need to use the ICSPDAT and ICSPCLK lines, PLUS the VPP line. That's fine as long as your application can work with them remaining 3 pins, which thankfully are bidirectional I/O pins. However, I don't see any debug capability in that chip.

So take a look at the official, unavailable debug chip again. Notice anything, like how many pins it has? Your route to a cost effective debug platform is paved with a similar Microchip part with the same baseline 33 instructions. Write and debug your code on the different/similar chip, then rewrite it and compile for the '508.

(As far as these being ancient and obsolete ask yourself why MC is still keeping these in production? Perhaps an eighty four cent device provides all the drive necessary for some product. I know of two designs I did early this century that use the '508 or something very similar that are still in production, one being the first featured product on their website.)
 

Thread Starter

q12x

Joined Sep 25, 2015
747
A bit of progress:
Screenshot_5.jpg
What I did here, is exactly what I thought in so many words in the beginning. That big red box is the 12F508 PIC inside Proteus.
Beside loading the hex file in the chip, I also changed it's frequency to 1Hz that means 1 beat per 1 second. And indeed, I get a 12seconds until the leds are first time opening. (You have a timer inside proteus as well).
Here is my TEST03.ASM code :
I only wanted a very simple loop to toggle. And it does.
1637424153074.png
Success so far, but its not all.
I have to make now an external circuit to step by step into the code, and the asm code that runs with an external oscilator.

Update:
I manage to find the instruction [ _OSC_ExtRC] for running an external oscilator:
__config _MCLRE_OFF & _CP_OFF & _WDT_OFF & _OSC_ExtRC
but inside Proteus, the PIC chip does not have a way of running it with an external oscillator ! It only has that setting where you set up its 4Mhz and is highly dependent by it.
In other words I can not simulate an external oscillator for PIC using Proteus. I dont know how, if there is a way.
 
Last edited:

BobTPH

Joined Jun 5, 2013
4,236
(As far as these being ancient and obsolete ask yourself why MC is still keeping these in production? Perhaps an eighty four cent device provides all the drive necessary for some product. I know of two designs I did early this century that use the '508 or something very similar that are still in production, one being the first featured product on their website.)
The suggested replacement chip is .71 in quantity 1, why is an .84 chip that with far less performance better?

Microchip will produce it as long as big customers keep buying it, which they will as long as the product they use it in is still selling and does not need an update.

Bob
 

Thread Starter

q12x

Joined Sep 25, 2015
747
Yes ! I done something !
So the simulator does not support external oscillator. I built myself one, following datasheet instructions:
Screenshot_6.jpg
Only _OSC_LP configuration worked for this circuit. The initial _OSC_ExtRC didn't work.
I've also changed the code to switch one led or the other.
movlw b'001010'
movwf GPIO
movlw b'001001'
movwf GPIO
Im still using Proteus to show the circuit I built, but is not actively doing anything. Its just for the circuit.
Screenshot_7.jpg
The manual oscillator works. But not good enough, because the leds are switching at random button contact. I need an electronic debounce button circuit. I think the button is bouncing and ringing and the chip counts those as well. I need an electronic way to debounce this button that is the manual oscillator for this pic.
- How can I debounce this button, using only electronic components ?
20211120_214133.jpg
.
 
Last edited:

nsaspook

Joined Aug 27, 2009
9,046
The suggested replacement chip is .71 in quantity 1, why is an .84 chip that with far less performance better?

Microchip will produce it as long as big customers keep buying it, which they will as long as the product they use it in is still selling and does not need an update.

Bob
One day the photo-mask litho set is going to get dropped by a new operator and that will be the EOL for that product. ;)
 

Thread Starter

q12x

Joined Sep 25, 2015
747
I believe I find a solution, a bit complicated for a button but, is the best I could think.
I didnt test it yet in reality, but this is the plan.
Great support so far, guys. Haha.
Button debounce Circuit by Ben Eater 2.jpg
So this will be my manual oscillator for the 12F508 PIC.
 

BobTPH

Joined Jun 5, 2013
4,236
Yes, your design for a buggy whip is great! I hope it makes you rich.

Maybe for your next project you could nake a phone that you don’t have to spin a wheel to dial or a camera that can take multiple pictures without changing the film.

Bob
 

boostbuck

Joined Oct 5, 2017
88
Well, the TS might be misguided, and perhaps his project will not go anywhere in the end analysis, but sarcastic uninformative putdowns seem out of place and unnecessary. We all started at the bottom of the learning curve with great aspirations, and having reality knock us around a bit is part of the journey.
 

Thread Starter

q12x

Joined Sep 25, 2015
747
It works but still I get some random bumps, its a bit better than previous but not there yet. I have to modify the capacitors some more.
20211121_181939.jpg 20211121_182017.jpg
 

Thread Starter

q12x

Joined Sep 25, 2015
747
I managed to make it work ok now, but I have to press rarely. If I press fast, it has a bit of a delay that is messing up my counting and it appear imprecise. So slow is the way. At least with this 555 circuit. I plan to make it with another PIC and also integrate a couple of bursts - GP0 btn press = 1cycle, then GP1 btn press = 4cycles, then GP2 btn press = 255 cycles, then GP3 btn press = 1second... and finally on GP5 = Output. Im not very sure yet about all this , but is the best I could think of a manual hardware debugging tool. Give me your ideas about this subject please, brain storm it. How you will improve it or add more to it?
 
Last edited:

Thread Starter

q12x

Joined Sep 25, 2015
747
Dont throw with rocks on mister BobTPH here, I believe he is childish about it because he doesnt quite understand what im doing, or doesnt believe in my little very simple project. And is ok.
All im doing here, I am trying to find a way to debug a PIC microcontroller program inside it, but from a hardware perspective. I will not be able to watch it's internal registers change, that's a big disadvantage but I will be able to count its cycles, again, manually. Well, semi-automatic, because I plan to introduce some bursts of signals in the next version of this circuit. I have no possibility to debug a PIC microcontroler !!! The software it has, doesnt really help me debug anything in it. Even the guys on the microchip dont really know about debugging their own PICs. Haha. I asked them but I got no response, so they dont really know. This is my way of finding a way of debugging a PIC and Im trying my best. I am posting my progress here because I hope someone will jump in and give me a better idea on how to do things. Like mister @BobTPH here, he is full of ideas, haha.
 
Last edited:

BobTPH

Joined Jun 5, 2013
4,236
All im doing here, I am trying to find a way to debug a PIC microcontroller program inside it,but from a hardware perspective. I will not be able to watch it's internal registers change, that's a big disadvantage but I will be able to count its cycles, again, manually.
Microchip’s debugger does all of this and my ch more, too bad you are too lazy to learn it.

I have been programming PICs for 15 years, and I have complaints about their debugger, but it has never stopped me. So let me give you some more suggestions, since you asked.

1. Use the simulator. Often, it is better than the hardware debugger. For example it allows you to drive the pins with a predictable stimulus.

2. Use a newer chip that supports the hardware debugger.

3. If you need the two pins required nby the hardware debugger, use a pic from the same family with more pins, which is basically what their debugging board us.

4. Use a serial line to output debug messages.

5. Use an LED to help you trace the program

I have not suggested any techniques here that I have not used..

Bob
 

Thread Starter

q12x

Joined Sep 25, 2015
747
Microchip’s debugger does all of this and my ch more, too bad you are too lazy to learn it.
I do not have any kind of debugger from microchip. I never had. I just recently learned they have this AC162059 debug adapter which is very rare and very expensive. You are the lucky one who has a debugger. I am not lucky. I am also quite poor to test things that might work. It has nothing to do with being lazy, but with how much money you can spent and hope for the best results.

I have been programming PICs for 15 years, and I have complaints about their debugger, but it has never stopped me. So let me give you some more suggestions, since you asked.
I did learned PICs some 15 years ago myself as well, but life stopped me continuing with them. Now I take the things back again, and I am re-learning them, remembering as much as I can from 15 years ago. The difference between me and you, is that you did all of this --every day-- for 15 years. I am not doing it every day. Also my specialization is way different from electronics or programming or PICs. I do these things because I have a nostalgic inclination towards them, not from necessity or my job or profit. I am also unable to make profit from anything I know or do, because the capitalism we live in is so great. Haha.
I do appreciate any advice from you if you truly use these things daily.

1. Use the simulator. Often, it is better than the hardware debugger. For example it allows you to drive the pins with a predictable stimulus.
Please name your simulator you are working with. If you are referring to Proteus, I am using it from time to time, but sometime I find reality is more problematic than simulators, so I use them for simple tasks, not complex.
And what hardware debugger are you referring? I am just trying to build one myself here. Haha.
Or you are comparing a simulator to a hardware debugger to be a better option? Well, I believe in multiple options to have. Every option will have its good and bad. My hardware debugger I am creating right now, I best hope will be good at something, and for sure not for everything. The same goes for simulator. So please allow me to build my hardware debugger as weird as it sounds to you, who knows, maybe will be good at something that a simulator will not know how to do or see.


2. Use a newer chip that supports the hardware debugger.
3. If you need the two pins required nby the hardware debugger, use a pic from the same family with more pins, which is basically what their debugging board us.
4. Use a serial line to output debug messages.
These are advanced debugging techniques that I have no idea they exist. I also have no idea how to implement them.
I do not have that much money to invest in a 'new' chip just to use it as a debugger chip, as good as an idea it is for you, but for me is a mystery what you are saying there. Try to believe my word, I really don't have your experience, man. i have 'some' experience, but not the full pack like you do. Good for you that you know all these things, but I don't. I have to invent these ways because they are not openly told and teached even in these modern days. And also I can do a limited set of tasks in my life. I can not do everything. If you know these things, you are a very lucky guy. Good for you. You also had access to some open doors in your life that helped you understand all of this a bit more faster and better than the average guy like me(who does not do it every day).

5. Use an LED to help you trace the program
This is the ONLY debugging option I know how to use from 15 years ago, and still relying on it even today.

It is a good thing that you opened up. But still is too general what you are saying. You are not teaching anything. Just pointing some general ways of doing it. I am inclined to believe you, because I had much trouble with these things along the time. Remember this from me, one can not know everything. We are always learning, we are always evolving. Alone is the slowest way. Now I'm talking from my experience.
I want you to make a tutorial for me about debugging (my PIC 12F508 if possible) using all your knowledge about debugging and experience and all your ways that you summarily exposed. I know I ask a lot from you. I know is not easy. But good things never are (easy).
I am doing my best with what I can and what I know. I want to see your best.
Thank you for your comments.
 

boostbuck

Joined Oct 5, 2017
88
For the work I do in assembler on the mid-range chips, the free MPLAB8 IDE (now obsolete, but I use it as do many others) is still available from Microchip, and it allows full code debugging with simulation. This is what I use to validate my code, and I have built some large scale projects using that, and have so far avoided the need to run debugging on the hardware itself.

I agree with Bob that what you will likely achieve (trying to single step the clock and blind-debug code from the outside of a chip that doesn't support integral hardware debugging) might be effort better spent learning the capabilities of the MPLAB environment. Even without the hardware debugging addons, the emulator and simulator Microchip make available for free have allowed me to create extensive code for the mid-range chips and have a high level of confidence in it.

But please prove me wrong.
 

boostbuck

Joined Oct 5, 2017
88
To clarify Bob's comments, the later ranges of chips have assigned several pins as a communication path between the internal debugging supervisor and the MPLAB IDE, allowing real-time debugging of code executing on the hardware. I think the Pickit2 you are using supports this. Chips with this facility are now cheaper than the older ones without it.
 

BobTPH

Joined Jun 5, 2013
4,236
I apologize, your original post led me to assume that you knew about the Microchip tools since you talked about engaging in the Microchip forum. And now I understand why you think pic12f508 is a chip that should still be used! Things have changed in the last 15 years.

The free MPLABX IDE has everything you need to debug. It has hardware debugging support , as well as a software simulator with extensive debugging capabilities.

MPLABX says the debug header is optional, so I think it can still do hardware debugging on that chip. But you lose 2 pins on a chip that has all of 6 I/O pins. The debug header allows you to debug while using those other two pins, it replaces the chip with a little board that has a bigger chip on it with extra pins. I had one of these, which I never used, and I went to see if it was the right one with the intention of sending it to you, but alas, it was the wrong one.

That said, I would still update to a new chip at basically the same cost and 5 to 10 times the performance and features.

But hardware debugging is not all that is cracked up to me. I do most of my debugging on the software simulator, which is actually a much better experience.

I suggest you get MPLABX and learn how to use it. It will give you far more debug capability than you will ever get by your method.

Bob
 
Top