With high level languages/development suites we are too often removed from the need to understand what it really going on behind the scenes. I appreciate your covering the low level, gritty basics such as config settings. I'm very much looking forward to the continuation of this series. Thanks!
i concur, the basics are important and as hobbyists fundamental to a wider understanding of how it all works. Almost anyone can slap a breakout board onto an Arduino and get a result - this takes us back to the bits, bytes and registers, which are a common feature of all micro controllers and microprocessors from PIC to Intel i7 and beyond.
Thanks! This series is one of the most instructive that you can find on youtube :) The things I love the most about your videos are that you make little steps towards the end, explain everything and even gasp of surprise once in a while, making your curiosity contagious, and that you show that you can build a hobbist electronic lab with a little money without the need of fancy instrumentation.
Thanks for doing this. I must say I was skeptical at first ("what's the point of learning PIC assembly!") but you're making it more interesting than I thought it could be.
I know Microchip .. in their infinite wisdom .. changed the assembler language with the new ide since this video, but Im going to watch this whole playlist anyway. I like seeing how the older way worked, Im learning a lot, and I like your presentation style. Thanks for these videos.
Enjoyed this intro, thank you. I'm a high level language guy, trying to learn more about electronics, but I followed along just fine. Just waiting on my stuff from Alice to be able to follow along fully.
Outstanding. I think this is what will help me move beyond the Arduino environment. I do OEM sales work with stepper motor driven pumps and am constantly searching for ways to help direct mechanical engineers towards a low cost path for pump control.
Good start to the tutorial series thanks for posting. For those using PICkit3 programmers to switch on Power Target circuit - click on > Programmer > Settings > Power and check the box. Hope this helps
thank you so much for doing these videos Julian! As a mechanical engineering student that has had a good bit of success with arduinos in my free time I have always wanted to see how electrical engineers and embedded developers do that black magic that is machine code. Keep the PIC tutorials coming! I'm going to have to get on ebay here real soon and find a pickit and development board to follow along.
Been trying to get into Pic Assembly for years and this really made sense for the first time, nice one Julian ! PS: now we know why Arduino became so popular, Microchip never made it easy to get started :)
Nice video Julian, the spec PDF can be a mine field.... That was easy to follow. The pitfalls too was a goldmine of info. Looking forward to more programming instructables.
Great video Julian. Taking the fundamentals of PIC and making them interesting (even to someone who's been doing this stuff for years.) I caved in eventually and ordered one of the boards. My curiosity got the better of me. In the meantime it'll be interesting for me to see how much stray capacitance can be found on a breadboard.
(I hope I can post this here Julian) I'm new at programming PICs and have looked forward to this tutorial. I tried to follow Julian's tutorial as close as I could today but I can't any of the "clocks" to run on the PIC. I am using the PICKIT2 and the PIC12F675 Development Board modified as per Julian's earlier video. I am using the MPLAB version he recommends running on a WIN 10 PC. All seems to work as outlined and I get no error messages. The only different from what Julian shows on his video and what I get is when he programming the Target. I seem to be missing a line of text - all else is the same. I am missing the second to last line showing "Setting MCLR 3-State". It ends as his does with "PICkit 2 Ready". ========His output file shows this======== Programming Target (11/02/2017 13:21:41) PIC12F675 found (Rev 0xB) Erasing Target Programming Configuration Memory Verifying Configuration Memory Setting MCLR 3-State PICkit 2 Ready ================= ========Here is a copy of my output file showing the programming and verifying of the Target====== Programming Target (2/13/2017 5:53:59 PM) PIC12F675 found (Rev 0xB) Erasing Target Programming Configuration Memory Verifying Configuration Memory PICkit 2 Ready Verifying Target PIC12F675 found (Rev 0xB) Verifying Program Memory (0x0 - 0x3FF) Verifying EEPROM Memory (0x0 - 0x7F) Verifying User ID Memory Verifying Configuration Memory PICkit 2 Ready ================== I have checked all connections and retried a number of times programming from the beginning of the Video with no signal showing up on GP4 using either the external RC clock or the internal clock. I am checking GP4 with a scope as well as a frequency counter (not the one he uses) with nothing showing on the GP4 pin. I have tried Googling "Setting MCLR 3-State" with no results. Anyone have any ideas how I can fix the problem or what I am doing wrong?
Sounds like the Pickit is holding the chip in reset. "Programmer - settings - 3state on release from reset" may give you the "Setting MCLR 3-State" message back.
Hi Julian I tried checking off the "3state on release from reset" option under the settings menu but unfortunately that did not help. I did get it working by clicking on the "Release from Reset" option under "Programmer" option. I have to do this manually every time I program the chip but at least it works and I was able to follow your tutorial all the way through with everything working. It would be nice to have that done automatically when you program the chip so if you or any other viewer have any other ideas please let me know. I am using a clone PICkit2 ( looks the same as yours) and that maybe the issue.
Great first tutorial!!.. Did you know the Pickit2 standalone GUI avaliable on microchip download archive allows you to calibrate the lost OSCCAL calibration data.
That's good news. It is easy to delete the calibration value though, especially with a full erase of the pic, I know from past experience. :-/ If using the internal clock I always use the code in "example 9-1" on page 54 of the datasheet to call up the calibration value.
This a really interesting tutorial. Help if possible - when I try and write to the PIC I get the same output at 6:37 but without the Setting MCLR 3-State line. Not sure what I have missed or done wrong.
Brilliant! That's my kind of tutorial :-) I'm still waiting for the proto board to arrive but in the meantime, I think I'll try and breadboard it. Many thanks Julian, looking forward to #2 Viva Assembly Code!
Thanks Steve. This may help when wiring the 6-pin programmer connector to the chip pins: ww1.microchip.com/downloads/en/DeviceDoc/31028a.pdf It's quite easy really - it's just 5 wires :)
for internal oscillator chips I read it first and then write the value on a piece of tape and stick it on the chip in case I accidentally blow it away programming
Something I'm wondering is whether there's a programmer in the MPLab list which is compatible with the MiniPro TL866A? It's possible to import the HEX file to that device's control program, but it would be nicer if it was possible to eliminate that step and just program directly from MPLab. (For anyone who doesn't know, the MiniPro TL866A is a universal programmer which will program just about anything programmable, including PICs, EPROMs, EEPROMs and lots more)
As I'm just getting started on a PIC project, I was looking forward to this series of videos. But I've just learned Microchip has replaced the older MPASM Assembler with a new PIC AS Assembler. Does that make this obsolete?
In the desperate hope that you, Julian, or someone else might help.... My mate has just built a scope kit that looks like yours. Sig in is via a voltage follower op amp (output linked to neg input). Pos in is zero, out is minus 1.3V which seems way too high for an an op amp offset. Chip blown?
Hi Julian thanks for your hard work in making these videos. I'm watching/following them all meticulously but not making them myself as I'm more of an AVR guy but I DO learn from your PIC tutorial anyways
Hello Julian. Thank you for your videos. Is there a way to 'read' the program off of a microprocessor and decompile it into an assembly language for a simple electronic device like, let's say a room air humidifier or a modern kitchen stove?
I've had fingers for ages and never used them for an RC circuit before... makes me wonder about the money I have wasted on ceramic resonators in the past. The OSCCAL stuff is really confusing... seems there is an instruction at the end of program memory? Looking forward to you investigating that.
Hi Julian, Because I am a Mac user, I thought - no problem - use MPLab X. However, having just watched this video , I think that Im going to revert to your version of the IDE - I'll find a way possibly using a VM. My main reason is that the new X version of the IDE has lots of additional facilities such a a window to set the configuration bits, which means one doesn't have to use the data sheet much. I think that will take something away from the learning process. Regards Alan
I've been playing with Arduino for a long time and have been meaning to play with PICs for a while and ordered the bits and pieces from your last video straight away. They're still on their way! However, I think this video raises more questions than it answers. I understand about the RC clock. Seeing a crystal/resonator clock in action would have been useful (including what are the minimum/maximum values that work), but the thing which has me lost is the internal clock. You briefly explained that the correction factor is stored in the PIC and that all we had to do was read it. Some more information on this would be helpful - why do we have to read it and do we have to read (and write?) it every time we reprogram the PIC? If so, how? I understand that the clock time is the speed instructions are executed in, but what does this mean in PIC terms - i.e. what are the pros and cons of using different clock speeds (and, indeed, what are the pros and cons of using RC/crystal/resonator/internal clocks?). Keep up the good work!
Maybe I can provide some brief answers here. Julian's videos will explain more comprehensively of course. The main advantage of using the internal clock is a reduced parts count since you don't need any external clock components. The main disadvantages are that the internal clock can't run as fast, nor be as accurate as a crystal clock. Since the components which determine the internal clock speed are never totally identical from one chip to the next, a calibration value is determined after manufacture in order to adjust the speed to be as accurate as possible. This calibration value is stored in the last program memory location, along with a "return with value in accumulator" instruction which allows you to do a "call 3FFh" (last memory address) instruction to retrieve the calibration value. It's then a simple matter to load that value into the calibration register. The PIC12F675 can use up to a 20Mhz crystal oscillator which will produce an instruction cycle speed of 5Mhz since instruction cycle time is always one-quarter of the clock cycle time.
Having mostly dealt with Atmel products so far, is there a cheaper alternative to the PicKit? I have bought the Atmel ICE, but I doubt that would help here at all. I also own a BusPirate 3 if that would help.
There are non genuine pickiits (like the ones he is using here) available. almost garanteed to work with the setup in these tutorials. The genuine ones have the microchip logo and a different font on the pickit device.
Hi Julian, I liked the assembly lesson, but could you do me a favour and show a MPLabX project from scratch with your little board. I don't seem to be able to work my Pickit 3 with it. How about clean install the mplabx and the necessary other files then show the settings which make it work, then type the small file required and then build and run it. That would help a lot. Barry
Is there a chance the OSCCAL value is still in 12F675 flash memory at address 03FF? When the PIC12F675 comes out of reset it executes the instruction at 03FF (a "movlw xx" instruction which contains the factory calibration value) and then the program counter rolls over to 0000 where your first program instruction should be a "movwf OSCCAL" instruction. The PICKIT2 "program" function is supposed to preserve that factory calibration instruction at location 03FF in program memory during programming.
Yeah, interestingly, the cal value is still in the program memory at 03FF. So I erased the chip - and it's still there. I think the IDE is protecting that memory location for this particular chip. I'll mention this in part 2.
I may have to buy one of the Ebay boards in order to duplicate these experiments as my home made board is not laid out the same and I cannot duplicate board capacitance in the RC capacitance experiment
I ran into an issue where the clock would be very intermittently working (clock runs then drops to 0 at random times) in all the different clock types. Found that you may need to put IN the Reset/GP3 jumper during tests. I left it off during programming but didn't think to put it back. I assume the chip might be randomly held reset because the pin was left floating?
If anyone is having issues with the Pickit 3 and getting "Failed to get Device Id." try changing the voltage down to around 4v in the "Programmer->Settings->Power" menu. Took me hours of playing to get this working. No idea why it doesn't like 5v. Both the Pickit 3 and dev board were purchased from Alice.
I did, i'll double check it though. Programming does seem to randomly fail, so it does seem like it could be to do with that. If all else fails, i'll make up my own dev board. Thanks for the great tutorial.
Julian, enjoyable though your videos are it's not a good introduction to use external RC oscillator mode, and then depend on the stray capacitance for it to work. This is going to confuse or mislead a lot of novices out there. Much better to start with the internal RC oscillator.
Its now well polished video. Thank you for skipping those part where you made all those physical connections and other stuffs. Hope you will produce this ASM tutorial very often because the flow control mechanism in the mind should stay alerted and doesnt get washed away. After almost 21 years I am starting to have interests in assembly language again. programming 8085 was not that interesting that long ago and so far C programming did all my requirement. Would like to see how you handle interrupt calls and context saving. Because thats where all my interests lies in. Double thumbs up!
If you reinstall the PICkit3 software and set the install location to the 'c' directory folder, you should be able to quit the application properly. With the normal set up, it is installed in your c/Program File (x86) where it is protected in a manner of speaking. It seems that the PIKkit3 app sends a call-back to the parent folder when it is exiting. This is denied by Windows and causes the application to hang up.
Another thing to look out for is that the chip is a Harvard Architecture.... the data and program paths are different. In a PIC the program memory is only 14 bits wide.with a 13-bit program counter, registers on the other hand are multiples of 8-bits. CONFIG is a special value and is stored in a reserved area of PROGRAM space (2007h for this device) and therefore it is 14 bits wide.
NivagSwerdna Thanks, just reading up on it. Quite a lot to take in! When I've looked at assembly before it's been 8 16 32 bit stuff, so the 14 bits caught me out!
MPLAB-X will make your life so much easier. As will the free C compiler. And yes, you can go as "low level" as you like, armed with your chips datasheet. Just avoid the code-generation tools.
No, it won't "defeat the whole purpose of these tutorials". That's just ill-considered, unsubstantiated nonsense. MPLAB-X is extremely easy to install and use. MUCH EASIER than hacking around like this. You can see, and play around with ALL the config parameters for your chosen chip very simply. You can match them up with what you read in the datasheet. That's vastly simpler and much more productive for new users. The C Language header files already contain definitions for the vast majority of the ports, registers, bit masks, etc., for the items you see in the datasheets. That saves you all the hassle of having to bit-bang every damn register together yourself. That's very important when you want to use functionality that requires multiple registers - most of which are multi-purpose - set up correctly. SPI, I2C, PWM, Timers, etc., especially on the higher-end PIC devices - PIC18 upwards - are good examples. Ah, hacking around with primitive tools in assembler... Been there, done that, bought the tee-shirt. 30 years ago... And yes, I did it for many years professionally too in the 1980s-90s. But these days, when high-quality optimising C compilers are available for free? Lunacy. And yes, you can "inline" and "asm" small sections of code if they need specific access or performance (it's rare these days you need to do this, especially if you are using the hardware available correctly - i.e. using on-board hardware timers, pwm, spi, i2c, etc. - rather than trying to bit-bang it all in asm like we did in the old days when the hardware couldn't do it..) Whatever, let's just agree to disagree. My comments are for those folks whole will watch this and want to consider a - vastly more productive - alternative. Hint: ask yourself why Arduino with it's great little IDE, C compilers and C libraries has become so successful for those who "want to learn to walk before learning to run", as you phrased it.
I agree, I do disagree and your response shows you do miss the purpose of these tutorials. The Arduino IDE produces bloated binaries and encourages bad programming habits (there are a plethora of such examples to be found on this very site.) With that in mind I often ask myself "why the Arduino IDE?" (Actually I don't as I stopped using it long ago after it grew into a monstrous bloatfest.) Given the number of people who've expressed interest in following Julian's series on PIC my original comment is substantiated by that and suggests to me that people want to get back to the basics and not be concerned about what is considered "fashionable." Clearly you are an MPLAB-X fanboy and you can be clear that I am not!
"Fanboy"? "Fashionable"? Exclamation marks!!!! Come on, Nick, show a little professionalism. This isn't the place for such childishness. Your own comment talked about getting people to "walk before they could run"... As I said, C on PIC or Arduino achieves that; not PIC in asm. That's what I responded to. Julian has the right to do any tutorial he sees fit; and we all have a right to comment on it. Your comments aren't "substantiated" by a one video that takes a certain approach. Your replies, begrudgingly, seem to appreciate that.. MPLAB-X. You chose to ignore all the points I made about how much easier the tools within the product make things for beginners, especially the daunting task of configuration bit setting - probably the hardest thing beginners face on PICs (and most other M/Cs.) Multiple configurations - different OCSs, clock speeds, etc., etc. can be excercised very simply. Ditto many other operations. Don't like MPLAB-X, then use the older MPLAB. Or use Mikroelectronica's smaller, simpler IDE. Arduino "bloat"? Most beginners don't care about that, they just want to see something work. Remember, that "walking" bit you raised.. And, back on the topic of PIC, the Microchip C compiler has progressively enabled more of the optimiser for free; the latest - free - version of the compiler produces excellent quality code. And, as I said, you can "inline" and "asm" to your hearts content if you wish - although most of the times that's completely pointless if you use the onboard hardware resources of the chip effectively (and PIC18, etc. and very cheap and very capable these days..)
hello men i have pic kit 3 and it’s not working my pc don’t ditected it and the status is always red can you help me with that and thank you in advance Georges
Anyone else that is using the pic board Julian is using and getting Target Detected Target Device ID (00000000) does not match expected Device ID (00000fc0). Is my board damaged?
Answering my own question. I ordered a real microchip pickit3 and hooked it up to the board. It immediately recognized it and I was able to program it. Getting a frequency now and can continue with the tutorial.
Ian Colquhoun it's an old DSO138 made by JYEtech. It doesn't really compare to a proper bench scope, but handy for hobby stuff, low frequency, pwm, etc. They have newer versions now, but this is still around cause it's probably the cheapest scope you can buy. You can find clones all over eBay as kit form or preassembled.
If you use standalone programmer, then PICKit2 and PICKit3 will do the same job. There is no difference at all. The PK2 can read PK3 device file as well so no difference supported parts as well. Its not difficult task either to add a new part in the device list. Yes, PK3 is more polished hardware to adjust to 3.3V parts but PK2 does that well enough too. I always prefer to use stand alone programming app, its mainly because I compile my programs via command line (Notepad++ is my editor) and in PK2/PK3 programming app, there is an option for you to upload automatically as soon as a new HEX file is generated. This saves lot of time and easy to use when you are programming difficult task where you need to code and upload many times.
Lawrence L MPLAB X has its issues I guess, bit it's still a very nice IDE to use. For one, you don't need to build and program as two distinct steps, one button does both. Perhaps a useful feature that would have been very relevant to this video is the configuration word builder. It presents you with a list of all of the configuration bits and drop down lists for all of the applicable options. That then generates the appropriate code to place in your source file. Super simple. Having said that, I do enjoy the challenge of figuring stuff out and writing assembly. There's a lot to be said for productivity with high level languages, but some of the fun is lost. :)
I have no idea why would one mess with the old PIC technology since there are now Ardruinos and even better, the ESP8266 and ESP32. I know what I'm talking about. I've been programming the PICs since 20 years.
Maybe it's stupid but it's the sort of mistake a beginner might make from lack of understanding. So it is good to point out the possible pitfall to the newbies.
Pic is dead dude. Atmel is the king of the hill now, thanks to Arduino. Good thing too. Microchip is a horrible company. They used to be awesome. Before success went to their heads, and screwed up royally, with the Pic32. If you don't need a JTAG to debug hardware, then you don't need a silly programmer that they keep obsoleting. ICD1, then ICD2, then ICD3, PicKit BS ... Fuck of Microchip...
With high level languages/development suites we are too often removed from the need to understand what it really going on behind the scenes. I appreciate your covering the low level, gritty basics such as config settings. I'm very much looking forward to the continuation of this series. Thanks!
Thanks John :)
i concur, the basics are important and as hobbyists fundamental to a wider understanding of how it all works. Almost anyone can slap a breakout board onto an Arduino and get a result - this takes us back to the bits, bytes and registers, which are a common feature of all micro controllers and microprocessors from PIC to Intel i7 and beyond.
I must admit this is fucking most informative tutorial I've ever watched. Finally!!!!!!!
Julian, you are natural born teacher. Thank you!
Thanks! This series is one of the most instructive that you can find on youtube :)
The things I love the most about your videos are that you make little steps towards the end, explain everything and even gasp of surprise once in a while, making your curiosity contagious, and that you show that you can build a hobbist electronic lab with a little money without the need of fancy instrumentation.
Thanks Francesco - you have summed up what I'm trying to do perfectly :)
Thanks for doing this. I must say I was skeptical at first ("what's the point of learning PIC assembly!") but you're making it more interesting than I thought it could be.
I know Microchip .. in their infinite wisdom .. changed the assembler language with the new ide since this video, but Im going to watch this whole playlist anyway. I like seeing how the older way worked, Im learning a lot, and I like your presentation style. Thanks for these videos.
Enjoyed this intro, thank you. I'm a high level language guy, trying to learn more about electronics, but I followed along just fine. Just waiting on my stuff from Alice to be able to follow along fully.
Thanks Terry :)
Outstanding. I think this is what will help me move beyond the Arduino environment. I do OEM sales work with stepper motor driven pumps and am constantly searching for ways to help direct mechanical engineers towards a low cost path for pump control.
Good start to the tutorial series thanks for posting.
For those using PICkit3 programmers to switch on Power Target circuit - click on > Programmer > Settings > Power and check the box. Hope this helps
Brilliant stuff Julian. I'm looking forward to the next one. Thanks.
It's funny that I understand only half of it and still it was pure joy to watch...
thank you so much for doing these videos Julian! As a mechanical engineering student that has had a good bit of success with arduinos in my free time I have always wanted to see how electrical engineers and embedded developers do that black magic that is machine code. Keep the PIC tutorials coming! I'm going to have to get on ebay here real soon and find a pickit and development board to follow along.
Cheers James :)
So glad I found this. Awesome job, hats off!
Excellent work and very detailed and informative. Perfectly balanced presentation. Thank you Sir.
You're welcome :)
Been trying to get into Pic Assembly for years and this really made sense for the first time, nice one Julian !
PS: now we know why Arduino became so popular, Microchip never made it easy to get started :)
Just watched the 9v led 'amazing life hack'. Cheers Julian, it's ages since I had a good ol fashioned belly laugh!!
I discovered I had a GQ-4x4 and must have forgot I purchased it. Works well with many chips including the PIC.
Nice video Julian, the spec PDF can be a mine field.... That was easy to follow. The pitfalls too was a goldmine of info.
Looking forward to more programming instructables.
Thanks Michael, more soon :)
finally found a channel of unboxing and invetions love it subscribed
Extremely Informative Video. Thank You Sir. 😊😊
Great video Julian. Taking the fundamentals of PIC and making them interesting (even to someone who's been doing this stuff for years.)
I caved in eventually and ordered one of the boards. My curiosity got the better of me. In the meantime it'll be interesting for me to see how much stray capacitance can be found on a breadboard.
Great tutorial Julian, looking forward to the next ones!
brilliant lecture. Can´t wait to see more!
Nicely explained!
Chips and Beans. Pip, Pip, Cheerio! Love your videos, Julian!
(I hope I can post this here Julian)
I'm new at programming PICs and have looked forward to this tutorial. I tried to follow Julian's tutorial as close as I could today but I can't any of the "clocks" to run on the PIC.
I am using the PICKIT2 and the PIC12F675 Development Board modified as per Julian's earlier video.
I am using the MPLAB version he recommends running on a WIN 10 PC. All seems to work as outlined and I get no error messages. The only different from what Julian shows on his video and what I get is when he programming the Target. I seem to be missing a line of text - all else is the same.
I am missing the second to last line showing "Setting MCLR 3-State". It ends as his does with "PICkit 2 Ready".
========His output file shows this========
Programming Target (11/02/2017 13:21:41)
PIC12F675 found (Rev 0xB)
Erasing Target
Programming Configuration Memory
Verifying Configuration Memory
Setting MCLR 3-State
PICkit 2 Ready
=================
========Here is a copy of my output file showing the programming and verifying of the Target======
Programming Target (2/13/2017 5:53:59 PM)
PIC12F675 found (Rev 0xB)
Erasing Target
Programming Configuration Memory
Verifying Configuration Memory
PICkit 2 Ready
Verifying Target
PIC12F675 found (Rev 0xB)
Verifying Program Memory (0x0 - 0x3FF)
Verifying EEPROM Memory (0x0 - 0x7F)
Verifying User ID Memory
Verifying Configuration Memory
PICkit 2 Ready
==================
I have checked all connections and retried a number of times programming from the beginning of the Video with no signal showing up on GP4 using either the external RC clock or the internal clock.
I am checking GP4 with a scope as well as a frequency counter (not the one he uses) with nothing showing on the GP4 pin.
I have tried Googling "Setting MCLR 3-State" with no results.
Anyone have any ideas how I can fix the problem or what I am doing wrong?
Sounds like the Pickit is holding the chip in reset. "Programmer - settings - 3state on release from reset" may give you the "Setting MCLR 3-State" message back.
Hi Julian
I tried checking off the "3state on release from reset" option under the settings menu but unfortunately that did not help.
I did get it working by clicking on the "Release from Reset" option under "Programmer" option. I have to do this manually every time I program the chip but at least it works and I was able to follow your tutorial all the way through with everything working.
It would be nice to have that done automatically when you program the chip so if you or any other viewer have any other ideas please let me know. I am using a clone PICkit2 ( looks the same as yours) and that maybe the issue.
fantastic, I'm gonna have to dig out some chips and have another crack at learning this
I'm working on the HCS12 in Assembly right now for school :). Have my PIC sitting beside it though!
Great first tutorial!!.. Did you know the Pickit2 standalone GUI avaliable on microchip download archive allows you to calibrate the lost OSCCAL calibration data.
Oh cool - gotta try that :)
Yes PICKit2 and PICKit3 can calibrate the OSCCAL automatically.
Actually, I've just read the chip contents and the calibration value is still in the last location of flash memory. I'll mention this in part 2.
That's good news. It is easy to delete the calibration value though, especially with a full erase of the pic, I know from past experience. :-/ If using the internal clock I always use the code in "example 9-1" on page 54 of the datasheet to call up the calibration value.
This a really interesting tutorial. Help if possible - when I try and write to the PIC I get the same output at 6:37 but without the Setting MCLR 3-State line. Not sure what I have missed or done wrong.
Someone else said the same thing - are you using PICkit 2 or 3?
Picket 2
Hmm, not sure. I'll investigate :)
Thanks very much. The video is excellent.
A lot more PIC videos please!
Excellent tutorial Julian thanks.
Great info. Any plans to use MPLAB-X in the future? I am kind of a PIC novice but like some of the feature of the newer IDE / IPE.
Excellent video, Thanks for your time and efforts.
Brilliant! That's my kind of tutorial :-) I'm still waiting for the proto board to arrive but in the meantime, I think I'll try and breadboard it. Many thanks Julian, looking forward to #2 Viva Assembly Code!
Thanks Steve. This may help when wiring the 6-pin programmer connector to the chip pins: ww1.microchip.com/downloads/en/DeviceDoc/31028a.pdf
It's quite easy really - it's just 5 wires :)
Thank you Jiulian. Unfortunately busy this evening but that will be my Sunday Morning project :-)
for internal oscillator chips I read it first and then write the value on a piece of tape and stick it on the chip in case I accidentally blow it away programming
Something I'm wondering is whether there's a programmer in the MPLab list which is compatible with the MiniPro TL866A?
It's possible to import the HEX file to that device's control program, but it would be nicer if it was possible to eliminate that step and just program directly from MPLab.
(For anyone who doesn't know, the MiniPro TL866A is a universal programmer which will program just about anything programmable, including PICs, EPROMs, EEPROMs and lots more)
As I'm just getting started on a PIC project, I was looking forward to this series of videos. But I've just learned Microchip has replaced the older MPASM Assembler with a new PIC AS Assembler. Does that make this obsolete?
In the desperate hope that you, Julian, or someone else might help.... My mate has just built a scope kit that looks like yours. Sig in is via a voltage follower op amp (output linked to neg input). Pos in is zero, out is minus 1.3V which seems way too high for an an op amp offset. Chip blown?
Hi Julian thanks for your hard work in making these videos. I'm watching/following them all meticulously but not making them myself as I'm more of an AVR guy but I DO learn from your PIC tutorial anyways
Hello Julian. Thank you for your videos. Is there a way to 'read' the program off of a microprocessor and decompile it into an assembly language for a simple electronic device like, let's say a room air humidifier or a modern kitchen stove?
Yes, you can read the contents of a microcontroller (unless it has been copy protected) and disassemble it into assembly code.
I've had fingers for ages and never used them for an RC circuit before... makes me wonder about the money I have wasted on ceramic resonators in the past. The OSCCAL stuff is really confusing... seems there is an instruction at the end of program memory? Looking forward to you investigating that.
Hi Julian,
Because I am a Mac user, I thought - no problem - use MPLab X. However, having just watched this video , I think that Im going to revert to your version of the IDE - I'll find a way possibly using a VM.
My main reason is that the new X version of the IDE has lots of additional facilities such a a window to set the configuration bits, which means one doesn't have to use the data sheet much. I think that will take something away from the learning process.
Regards
Alan
I've been playing with Arduino for a long time and have been meaning to play with PICs for a while and ordered the bits and pieces from your last video straight away. They're still on their way!
However, I think this video raises more questions than it answers. I understand about the RC clock. Seeing a crystal/resonator clock in action would have been useful (including what are the minimum/maximum values that work), but the thing which has me lost is the internal clock. You briefly explained that the correction factor is stored in the PIC and that all we had to do was read it. Some more information on this would be helpful - why do we have to read it and do we have to read (and write?) it every time we reprogram the PIC? If so, how? I understand that the clock time is the speed instructions are executed in, but what does this mean in PIC terms - i.e. what are the pros and cons of using different clock speeds (and, indeed, what are the pros and cons of using RC/crystal/resonator/internal clocks?).
Keep up the good work!
+Nicholas Barnes I'll address some of these points in a supplementary video
Maybe I can provide some brief answers here. Julian's videos will explain more comprehensively of course.
The main advantage of using the internal clock is a reduced parts count since you don't need any external clock components. The main disadvantages are that the internal clock can't run as fast, nor be as accurate as a crystal clock.
Since the components which determine the internal clock speed are never totally identical from one chip to the next, a calibration value is determined after manufacture in order to adjust the speed to be as accurate as possible.
This calibration value is stored in the last program memory location, along with a "return with value in accumulator" instruction which allows you to do a "call 3FFh" (last memory address) instruction to retrieve the calibration value. It's then a simple matter to load that value into the calibration register.
The PIC12F675 can use up to a 20Mhz crystal oscillator which will produce an instruction cycle speed of 5Mhz since instruction cycle time is always one-quarter of the clock cycle time.
Excellent pace to learn and think and learn.
If only it was for the ATMEGA's.
Having mostly dealt with Atmel products so far, is there a cheaper alternative to the PicKit? I have bought the Atmel ICE, but I doubt that would help here at all. I also own a BusPirate 3 if that would help.
There are non genuine pickiits (like the ones he is using here) available. almost garanteed to work with the setup in these tutorials.
The genuine ones have the microchip logo and a different font on the pickit device.
Great series, keep it up!
Hi Julian, I liked the assembly lesson, but could you do me a favour and show a MPLabX project from scratch with your little board. I don't seem to be able to work my Pickit 3 with it. How about clean install the mplabx and the necessary other files then show the settings which make it work, then type the small file required and then build and run it. That would help a lot.
Barry
Is there a chance the OSCCAL value is still in 12F675 flash memory at address 03FF? When the PIC12F675 comes out of reset it executes the instruction at 03FF (a "movlw xx" instruction which contains the factory calibration value) and then the program counter rolls over to 0000 where your first program instruction should be a "movwf OSCCAL" instruction.
The PICKIT2 "program" function is supposed to preserve that factory calibration instruction at location 03FF in program memory during programming.
Yeah, interestingly, the cal value is still in the program memory at 03FF. So I erased the chip - and it's still there. I think the IDE is protecting that memory location for this particular chip. I'll mention this in part 2.
I may have to buy one of the Ebay boards in order to duplicate these experiments as my home made board is not laid out the same and I cannot duplicate board capacitance in the RC capacitance experiment
You'll get some amount of board capacitance however you lay it out - even zero capacitance should still cause oscillation.
if you push on the pic or heat it up the internal osc will change slightly
I ran into an issue where the clock would be very intermittently working (clock runs then drops to 0 at random times) in all the different clock types. Found that you may need to put IN the Reset/GP3 jumper during tests. I left it off during programming but didn't think to put it back. I assume the chip might be randomly held reset because the pin was left floating?
+Mike Moniz yes, this CMOS input does need to be pulled up for reliable operation.
Hi Julien. Do you see any issue following along just using breadboard. I have programmed a pic this way using my pic kit 3 in the past.
I'll try to make that easier in part 2 - I'll provide a schematic.
any reason for covering the older MPLAB IDE rather than the newer MPLABX IDE/IPE ?
If anyone is having issues with the Pickit 3 and getting "Failed to get Device Id." try changing the voltage down to around 4v in the "Programmer->Settings->Power" menu. Took me hours of playing to get this working. No idea why it doesn't like 5v. Both the Pickit 3 and dev board were purchased from Alice.
Did you do the wire mod (to separate Vpp from the reset resistor and capacitor)?
I did, i'll double check it though. Programming does seem to randomly fail, so it does seem like it could be to do with that.
If all else fails, i'll make up my own dev board.
Thanks for the great tutorial.
Julian, enjoyable though your videos are it's not a good introduction to use external RC oscillator mode, and then depend on the stray capacitance for it to work. This is going to confuse or mislead a lot of novices out there. Much better to start with the internal RC oscillator.
It'll only confuse the high level language guys. Electronics enthusiasts will understand what's going on just fine.
Hey Julian,
is there any schematic fir the Pic Board? I dont want to wait 4 weeks so i want to build one myself.
Its now well polished video. Thank you for skipping those part where you made all those physical connections and other stuffs. Hope you will produce this ASM tutorial very often because the flow control mechanism in the mind should stay alerted and doesnt get washed away. After almost 21 years I am starting to have interests in assembly language again. programming 8085 was not that interesting that long ago and so far C programming did all my requirement. Would like to see how you handle interrupt calls and context saving. Because thats where all my interests lies in. Double thumbs up!
If you reinstall the PICkit3 software and set the install location to the 'c' directory folder, you should be able to quit the application properly. With the normal set up, it is installed in your c/Program File (x86) where it is protected in a manner of speaking. It seems that the PIKkit3 app sends a call-back to the parent folder when it is exiting. This is denied by Windows and causes the application to hang up.
This might be a silly question, but isn't FFFF all ones?
Is there a reason you used 3FFF instead?
Yes, it's a 14-bit word (not 16-bit)
it's 3FFF because there are only 14 configuration bits.
3FFF = 0011 1111 1111 1111
FFFF = 1111 1111 1111 1111
Ahh, makes sense, thanks.
Another thing to look out for is that the chip is a Harvard Architecture.... the data and program paths are different. In a PIC the program memory is only 14 bits wide.with a 13-bit program counter, registers on the other hand are multiples of 8-bits. CONFIG is a special value and is stored in a reserved area of PROGRAM space (2007h for this device) and therefore it is 14 bits wide.
NivagSwerdna Thanks, just reading up on it. Quite a lot to take in!
When I've looked at assembly before it's been 8 16 32 bit stuff, so the 14 bits caught me out!
hi , i need some help , can i take some of your time?I have a code written in the assembly language and need a simple modification!!?
MPLAB-X will make your life so much easier.
As will the free C compiler.
And yes, you can go as "low level" as you like, armed with your chips datasheet.
Just avoid the code-generation tools.
Yes and it will completely defeat the whole purpose of these tutorials. Learning to walk before learning to run is always the best way.
No, it won't "defeat the whole purpose of these tutorials". That's just ill-considered, unsubstantiated nonsense.
MPLAB-X is extremely easy to install and use. MUCH EASIER than hacking around like this. You can see, and play around with ALL the config parameters for your chosen chip very simply. You can match them up with what you read in the datasheet. That's vastly simpler and much more productive for new users.
The C Language header files already contain definitions for the vast majority of the ports, registers, bit masks, etc., for the items you see in the datasheets. That saves you all the hassle of having to bit-bang every damn register together yourself. That's very important when you want to use functionality that requires multiple registers - most of which are multi-purpose - set up correctly. SPI, I2C, PWM, Timers, etc., especially on the higher-end PIC devices - PIC18 upwards - are good examples.
Ah, hacking around with primitive tools in assembler... Been there, done that, bought the tee-shirt. 30 years ago... And yes, I did it for many years professionally too in the 1980s-90s. But these days, when high-quality optimising C compilers are available for free? Lunacy. And yes, you can "inline" and "asm" small sections of code if they need specific access or performance (it's rare these days you need to do this, especially if you are using the hardware available correctly - i.e. using on-board hardware timers, pwm, spi, i2c, etc. - rather than trying to bit-bang it all in asm like we did in the old days when the hardware couldn't do it..)
Whatever, let's just agree to disagree. My comments are for those folks whole will watch this and want to consider a - vastly more productive - alternative.
Hint: ask yourself why Arduino with it's great little IDE, C compilers and C libraries has become so successful for those who "want to learn to walk before learning to run", as you phrased it.
I agree, I do disagree and your response shows you do miss the purpose of these tutorials.
The Arduino IDE produces bloated binaries and encourages bad programming habits (there are a plethora of such examples to be found on this very site.) With that in mind I often ask myself "why the Arduino IDE?" (Actually I don't as I stopped using it long ago after it grew into a monstrous bloatfest.)
Given the number of people who've expressed interest in following Julian's series on PIC my original comment is substantiated by that and suggests to me that people want to get back to the basics and not be concerned about what is considered "fashionable."
Clearly you are an MPLAB-X fanboy and you can be clear that I am not!
"Fanboy"? "Fashionable"? Exclamation marks!!!! Come on, Nick, show a little professionalism. This isn't the place for such childishness.
Your own comment talked about getting people to "walk before they could run"... As I said, C on PIC or Arduino achieves that; not PIC in asm. That's what I responded to.
Julian has the right to do any tutorial he sees fit; and we all have a right to comment on it. Your comments aren't "substantiated" by a one video that takes a certain approach. Your replies, begrudgingly, seem to appreciate that..
MPLAB-X. You chose to ignore all the points I made about how much easier the tools within the product make things for beginners, especially the daunting task of configuration bit setting - probably the hardest thing beginners face on PICs (and most other M/Cs.) Multiple configurations - different OCSs, clock speeds, etc., etc. can be excercised very simply. Ditto many other operations. Don't like MPLAB-X, then use the older MPLAB. Or use Mikroelectronica's smaller, simpler IDE.
Arduino "bloat"? Most beginners don't care about that, they just want to see something work. Remember, that "walking" bit you raised..
And, back on the topic of PIC, the Microchip C compiler has progressively enabled more of the optimiser for free; the latest - free - version of the compiler produces excellent quality code. And, as I said, you can "inline" and "asm" to your hearts content if you wish - although most of the times that's completely pointless if you use the onboard hardware resources of the chip effectively (and PIC18, etc. and very cheap and very capable these days..)
Hi Julian,
Is it possible to replace the PIC12F675 on the development board with say a PIC12F683? or any other 8 pin PIC
Yes, I'll mention that in a later tutorial.
You should find another chip to read the cal off just for kicks, actually my curiosity.
Actually, just discovered the cal value is still in the PIC chip - I'll mention that in part 2
Data sheet says the bg bits are factory set and should be read and replaced when programming??
Please let me/us know how to get/set the config for the internal osc.
I'll cover that in part 1.1
Perfect tutorial!
Thanks : )
Very Very Important Video.
Ok so you can hear and see it...but at what frequency can you smell it?
hello men i have pic kit 3 and it’s not working my pc don’t ditected it and the status is always red can you help me with that and thank you in advance
Georges
Anyone else that is using the pic board Julian is using and getting
Target Detected
Target Device ID (00000000) does not match expected Device
ID (00000fc0).
Is my board damaged?
Answering my own question. I ordered a real microchip pickit3 and hooked it up to the board. It immediately recognized it and I was able to program it. Getting a frequency now and can continue with the tutorial.
Link to that scope kit? Ebay usa if you have an affiliate....
Ian Colquhoun it's an old DSO138 made by JYEtech. It doesn't really compare to a proper bench scope, but handy for hobby stuff, low frequency, pwm, etc.
They have newer versions now, but this is still around cause it's probably the cheapest scope you can buy.
You can find clones all over eBay as kit form or preassembled.
love this video. pls more :)
Great tutorial
Sometimes I see words and pages mentioned in microcontroller data sheets. Can anyone explain what they mean?
Brainstorm4300 Well, give type the words and I'll try and do my best to explain them.
Not possible for pic16f886 my lord....!!!!
please give me some suggestion about it...
whats the diffrence beteen pickit2 and 3
RC MAD it is explained in part 0
Basically just newer and supports more PIC chips. But requires different IDE that is said to suck!
If you use standalone programmer, then PICKit2 and PICKit3 will do the same job. There is no difference at all. The PK2 can read PK3 device file as well so no difference supported parts as well. Its not difficult task either to add a new part in the device list. Yes, PK3 is more polished hardware to adjust to 3.3V parts but PK2 does that well enough too. I always prefer to use stand alone programming app, its mainly because I compile my programs via command line (Notepad++ is my editor) and in PK2/PK3 programming app, there is an option for you to upload automatically as soon as a new HEX file is generated. This saves lot of time and easy to use when you are programming difficult task where you need to code and upload many times.
Lawrence L MPLAB X has its issues I guess, bit it's still a very nice IDE to use. For one, you don't need to build and program as two distinct steps, one button does both.
Perhaps a useful feature that would have been very relevant to this video is the configuration word builder. It presents you with a list of all of the configuration bits and drop down lists for all of the applicable options. That then generates the appropriate code to place in your source file. Super simple.
Having said that, I do enjoy the challenge of figuring stuff out and writing assembly. There's a lot to be said for productivity with high level languages, but some of the fun is lost. :)
The pencil cursor got me laughing. I always wondered if you accidentally poked your screen with them from time to time.
great job
I have no idea why would one mess with the old PIC technology since there are now Ardruinos and even better, the ESP8266 and ESP32. I know what I'm talking about. I've been programming the PICs since 20 years.
hope ya still stuff for your fans who are mortals !
Great stuff!
So far I would rather you had used an 8 pin AVR chip. Default WDT enabled is stupid. But still learning is going on!
Maybe it's stupid but it's the sort of mistake a beginner might make from lack of understanding. So it is good to point out the possible pitfall to the newbies.
That's true Paul, and there are plenty more pitfalls like that to come :)
Great video! 1.2760 thumbs up! :)
Next: Show us how to read that calibration data and write it back in again every time we reconfigure the chip.
Will do - in part 2
I liked this unconventional video.
That was cool
thanks
this is great
YES!
heeej slováák
Great !!
Thanks!
damnit Alice hasn't sent mine yet!
naughty her
If microchip only had a good C compiler.....
👍👍👍✌️👀👽💨💨💨
hi
Get down and dirty with the bits
That's it :)
Pic is dead dude. Atmel is the king of the hill now, thanks to Arduino.
Good thing too. Microchip is a horrible company.
They used to be awesome. Before success went to their heads, and screwed up royally, with the Pic32.
If you don't need a JTAG to debug hardware, then you don't need a silly programmer that they keep obsoleting.
ICD1, then ICD2, then ICD3, PicKit BS ... Fuck of Microchip...
I will NEVER forgive Microchip for the shit slow internal clock!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!