How to program a 12F508

Thread Starter

q12x

Joined Sep 25, 2015
1,688
haha, I overlook it. It remained from the 'for' loop. Actually I like how you implemented the for loop with the exterior declared variable i. I erase it. Indeed the RAM show 32% with that variable and now is 28% without it. Im not that used to PIC's , I use them rarely. That's why I wonder to every new sh..bit I encounter. Haha
 

Thread Starter

q12x

Joined Sep 25, 2015
1,688
I made another blinky circuit. It's the same circuit and effect as before, but this time is "official". The last one was a test, but this one is for good.
 

Thread Starter

q12x

Joined Sep 25, 2015
1,688
Hello again.
I received an Arduino UNO. Actually is a clone that has on it only "UNO" text, without 'arduino' and is having only smd IC's on the board. The original, from what i've researched so far, has a BIG 40 pin DIP atmega IC on it.
My UNO full name:
UNO R3 Development Board ATmega328P CH340 CH340G For Arduino UNO R3 With Straight Pin Header
click on the image to enlarge: 1621244754356.png
Ok. So what i've done so far: I downloaded the Arduino 1.8.15 software and run some example code from it + web examples tutorials from its website. Very helpful to me as a beginner to get the point.
I am brand new, totally rookie, to arduino in general !!!!! Ive watched some tutorials on youtube to get an idea and i have an idea but very limited so far.

NOW... I still want to program my PIC's but with this arduino UNO thing. That's the number 1 reason why I bought it in the first place.
From my limited knowledge I can see it has an ICSP (in circuit serial programmer) (that is actually misspelled on the board itself- ISCP) which I believe, but not totally sure, is the gate to happiness, meaning, from this I can link it to the PIC Pins. But where and how to do it... is a bit over my head at this moment. I mean I will stay and dig in, until i will find the solution but I ask of you, if you know the thing better than me and faster resolve with your help.
Demo Board(the green board) with pickit2:working pic 12F508 program.jpg
- I will reverse engineer my Demo Board from my pickit2, those 6 pins input plug-in it has on it and hopefully adapt it to this ICSP from UNO. I think it is possible to program a PIC through a couple of wires ,well placed, and not only from this ISCP. Is my impression this ISCP is redundant, to help you find those pins faster. Which I will use it, but i say my thought about it.
- This Demo Board is just wires/tracks and some test leds, a potentiometer and a button ready on the board itself for testing your program. It does not contain anything more advanced that that. Its a testing board, with the tracks going in the right place. That is all to it. If I will use this demo board or build another one from scratch,specific for programming 12f508, is irrelevant. I will probably do both.
- Another reason I buy this UNO is because I did program PIC's, like a couple versions of them, in the year 2000's directly from my serial output of my PC. That was the way back then. And I hope it will be the same deal with this UNO as well. I mean is my greatest hope it is like that.
- I hope it is possible to program a PIC through this UNO board. "A dude" told me some years ago, it is possible and i believe him. But without any specifications. Now I will put it to the test.

- Also, from what i read, ICSP... is for programming it's on board atmega chip? Like upgrading it? Or is suitable to program other PICs like my plan is? I am a bit confused about it's function, sincerely. I will not touch it until you can confirm what it really is.
Thank you, and tell me your thoughts !
 
Last edited:

Thread Starter

q12x

Joined Sep 25, 2015
1,688
So, this is how far I could push it. I basically draw some wiring as logically I could think of and based on the image references I could find.
I am not completly sure what this ICSP does. If it is for programming it's own atmega chip on the arduino UNO board, then im screwed. But IF is for programming other PIC's, then winner = chicken + dinner.
You will really have to zoom and pan this image. I sugest to download the image on your pc and zoom and pan in there as you like. Also cut the image to fit some more good space than I am providing here.
q20210517 copy 1.jpg
 

LesJones

Joined Jan 8, 2017
4,188
My understanding is that the ICSP connector on an Arduino is for programming the ATmega328. (Or other chip used on that particular version of the Arduino.) This could be done with a programmer such as the USBASP and software such as Avrdude. This would normally be used to program a blank Atmega328 with the boot loader so it could then be programmed using the Arduino IDE. It is possible that someone has written code to run an the Arduino that would allow it to be used to program a PIC.

Les.
 

trebla

Joined Jun 29, 2019
542
As far as i know, you can use this ICSP header to program teh onboard chip or if you upload the Arduino programmer sketch to this board you can use this for programming another Atmel chip. I have used this method to program ATmega328 chips only.
 

Thread Starter

q12x

Joined Sep 25, 2015
1,688
ok, then my question still remain unanswered.
How to program a PIC with this UNO R3 device I have? That ISCP thing pop out the first option after reading carefully what is written on that board. So I will not touch the ISCP then.
I know there are "quick and dirty" electronic circuits that makes a programmer for a pic from a serial port. I know because I built one for a 16f84 in the 2000's. But I dont know how anymore. I used back then the "PASCAL" language and i think i had a special library for writing to pics using this language.
My greatest wish is to use c# and some library for serial. I'll have to dig in deep to find all this. But until then, I need to make this programmer a reality first. Or the Arduino language, but I have to learn it first, as I said, I am very new to arduino world.
 

trebla

Joined Jun 29, 2019
542
There is two different things in Arduino environment- one is the compiler which needs ported libraries for specific MCUs and the second is the programmer which can be written specifically for Arduino or the Arduino IDE will be launch some external programmer software, for example AVRdude (for Atmel chips) or ST-link/V2 (for STM32 chips).
 

LesJones

Joined Jan 8, 2017
4,188
The signals used for in circuit programming on a PIC are not the same as for in circuit programming of Atemel 8 bit processors.
Why don't you want to use the Pickit 2 to program your PIC ?

Les.
 

Thread Starter

q12x

Joined Sep 25, 2015
1,688
Why don't you want to use the Pickit 2 to program your PIC ?
Because long before pickit2 , it was possible to program a pic from a serial port and I did it. And I want to be able to make it again. I used Pascal language back then. I know there was the C alternative as well but I didn't try it.
 

Thread Starter

q12x

Joined Sep 25, 2015
1,688
Thank you mister @trebla, but i dont understand the Vpp_PUMP part . It is out of my level.
So.... it needs 13V on Vpp in other words. Thank you for checking it for me !
Are you able to conceive a UNO R3 serial programmer specific for 12f508 for me? A very "quick and dirty" one?
Or it is terrible complicated task ?
 

trebla

Joined Jun 29, 2019
542
Sorry, I believe it takes at least month for me, i have'nt much spare time for that :(
Firstly, this document must be studied and then all the algorithms must be coded. If it is afun-time project for someone then it will be OK, but for me is cheaper to buy a proper programmer than waste a month to cobble together something that is readily available.

For Vpp you can use an external power supply around 13V instead of charge pump (simple boost converter) .
 

Thread Starter

q12x

Joined Sep 25, 2015
1,688
I understand, and it is ok, thank you for your answers so far. I really appreciated. I know I push things too far sometimes. But I have to remember things I did before. I think I was more crazy back then, than I am today. Haha.
 

Thread Starter

q12x

Joined Sep 25, 2015
1,688
Here is another FUN problem to solve. If possible, of course.
I need to read a potentiometer value in my PIC12F508. (and later, to read a sensor from my big project "led wings")
But for that, the PIC should have an ADC register inside it.
ADC = analog to digital convertor.
I did a quick search in 12F508 datasheet for ADC keyword and nothing is find. So I conclude it does not having ADC.
I've also looked over internet and the most used command for any PIC to use it's internal ADC is:
ADCON1 = 0b11110000; (in Mplab) |OR| setup_adc_ports(AN0) (in CCS C)
I looked inside 16F690 Special Registers and I see how it's called. This PIC has 2 ADC in it called ADCON 0&1.
1623880190921.png
Now in my 12F508, it's special registers are:
1623880301382.png
and no sign of that ADCON0 like other PICs have.
So thats how I figure out I dont have ADC in my PIC.
My question to you is like this:
How to :
A - code an ADC ?
B - build an ADC from components ? (that I have)
Thank you !

(I will look now for electronic circuits that deal with ADC and soon post some updates)
Here is my current code I made using the POT from my prototyping board; but is only switching ON or OFF the led. Pretty much like a button.
1623880815072.png
 
Top