Beginner here: how to start with PIC micros? PICKIT 3 or 4 or Mplab snap? - Page 1
Forum section: electronics / beginners

author: iamericmin
author_rank: Contributor
timestamp: September 22, 2019, 05:09:45 pm
content: Hi y'all,I'm a teenager looking to start with PIC microcontrollers. I have absolutely no prior experience with them. I have fiddled with AVRs and the Arduino ecosystem a bit but I want to start actual embedded design without any layers of abstraction. The PIC seems a nice cheap starting point, and after a bit of googling I believe the PIC16f1829 is a great starter chip. However, I have a few specific questions.1) should I buy the PICKIT 4 or 3 or MPLab Snap? They all seem like solid choices and I believe the 4 is still in a developmental stage. I don't think it fully supports the 16F1829.2) Is the 16F1829 a good starting point? Everyone else seems to be recommending the 16F877a but I don't like the giant DIL-40 package and the 16F1829 has slightly better specs.Thank you all!

author: stoyanoff
author_rank: Contributor
timestamp: September 22, 2019, 06:45:27 pm
content: Hi! I have PICkit 3(original) and it works fine. They say PICkit 4 is much faster, but I haven`t tried it yet! For start you can buy a PICkit 3 clone form aliexpress if you like - it will perform as the original!I`m uploading a book for beginers! It`s used something called CCS compiler. It is fine for begginers because most of the functions are ready and you just have to use them - it is no neccessary to know exactly which bit of which register you have to set or how exactly to do it. The compiler will do it for you! You should know this compiler has a lot of bugs. I prefer XC8, XC16 and XC32 with MPLab. But I don`t have begginers book for them.About the controller - I don`t think it matters. There is so many info in internet so you can choose every controller you can put hands on! If I were you I would pic a PIC32 series! It`s almost the same as PIC16, but it has 32bit architecture, higher frequency, more momory and so on. And there are quite cheeper - for example there is one series PIC32MM!So take a look at the book, try to install multiple compilers - CCS and XC with MPlab. If you decide to go straight to XC i can assist with the first steps.Best regards!

author: rstofer
author_rank: Super Contributor
timestamp: September 22, 2019, 06:55:59 pm
content: You can certainly use the stuff you already have with the Arduino infrastucture to do bare metal programming on the ATmega328P and you will be using a vastly better chip. Look into avr-libc, avr-gcc and avr-dude. These tools and library are used by the infrastructure and kept out of the way of the Arduino programmer. But those are the basic tools. Then there is a layer of Arduino code over the top which does the actual abstraction.Nobody paws through the Arduino installation directory but everything you need for bare metal programming is hidden in there somewhere.You can Google for Arduino bare metal programming. It's being done by a lot of folks.Or, you can look at the Teensy 4.0 which is a blistering fast (600 MHz) ARM processor that uses the Arduino IDE and a different toolchain. Again, you don't have to use the Arduino-like libraries, you can write code targeting the chip using just the arm-gcc compiler and associated libraries. This ARM architecture is where all the big kids play. Did I mention that this thing is blistering FAST!In both cases, you can look at the Arduino-style library code and decide what to keep and what to rewrite. And discover how it works!Start simple: Write a program that sets up a periodic timer with an interrupt handler. Every 500 ms, toggle an LED. Do not use any of the Arduino code. Keep the setup() and loop() functions until you are certain you can break the umbilical cord.Mid-range PIC chips are a PITA. The architecture starts out ugly and just gets worse. OTOH, they are useful for volume production or they would have been obsoleted years ago.Or, you could pick any of the ARM MBED enabled boards and use the online toolchain for programming. This is pretty slick because all you need is a PC, a browser and an Internet connection. I particularly like the LPC1768 MBED board.https://os.mbed.com/platforms/?_ga=2.105169667.1246524837.1569178144-1675594917.1563899139You won't have a real-time debugger with the MBED approach. You would use printf() instead.https://os.mbed.com/platforms/mbed-LPC1768/You can have wired Ethernet by simply adding a MagJack. The networking library is provided and its based on lwIP.

author: mariush
author_rank: Super Contributor
timestamp: September 22, 2019, 08:43:35 pm
content: Back on topic.If you want to save some money, Snap will be a good programmer for more modern PIC devices.It can't program the controllers that require high voltage programming, if I remember correctly.... but for most of those you'll find modern equivalents that are supported. Majority of chips if not all made in the last 5 years or so should support low voltage programming.If you have the money, Pickit 3 is a good product - i have one. I don't know about chinese clones, but I don't see why clones wouldn't work.I'd suggest avoiding those older chips like PIC16F877 but not because they're in DIP package. Avoid simply but there's better modern versions with internal oscillator, higher maximum frequencies (for ex 32 Mhz vs 20 Mhz), better features (like built in voltage references, more ADCs/DACs etc). They can also work at lower voltages like 1.8v..2.5v (of course, at lower frequencies) ... those older chips may need at least 4v to operate.There's also versions in narrow DIP package, which uses less space but can still be used on breadboarsd to quickly set something up.For exercises, practice, etc ... I would suggest an all around versatile chip like PIC16F157x or PIC16LF157x (LF = low voltage) :http://ww1.microchip.com/downloads/en/DeviceDoc/40001782C.pdfYou have PIC16(L)F1574 , PIC16(L)F1575, PIC16(L)F1578, PIC16(L)F1579 .. difference is mostly pin count, memory and ram amount :You have internal oscillator, up to 32 Mhz, comparators, ADCs, you have a DAC, PWM, i2c, uart , Complementary Waveform Generator (CWG) for when you'd do more advanced stuff and you can also remap some pins to make circuits easier on prototyping boards/ breadboardsYou also have lots of program space, so you don't have to stress about writing unoptimized code.They're not expensive at around 1.1$ ...1.3$ ... here's the highest of the bunch :https://www.digikey.com/products/en?keywords=pic16f1579When you want to advance from PICs and Arduino, my advice would be to look into ARM Cortex M0 and M4.I would play with Silicon Labs Zero Gecko or Happy Gecko families for Cortex M0 for example : See the M0/M4/M4F series of theirs here:digikey linkBut, ask others when you decide to move on, which controllers have the easier to understand documentation and all that, what's more friendly for beginners.

author: ebclr
author_rank: Super Contributor
timestamp: September 23, 2019, 01:33:43 am
content: Do you want to know a much powerful ecosystem, try thishttps://www.cypress.com/documentation/development-kitsboards/cy8ckit-059-psoc-5lp-prototyping-kit-onboard-programmer-andIt's very cool especially for the new generation like you, don't waste your time with legacy processors like PIC

author: viperidae
author_rank: Frequent Contributor
timestamp: September 23, 2019, 08:20:12 am
content: I started with pic. I wouldn't choose it now though. I like the stm32 nucleo boards. They're cheap, powerful and include a built in debugger

author: NivagSwerdna
author_rank: Super Contributor
timestamp: September 23, 2019, 08:44:56 am
content: If the original poster is for real... Just get a Curiosity board which has PicKit on board. 24F or 32MZ perhaps.Alternatively look at STM32 ecosystem instead.(I remain sceptical of posters with such a low post count... Spam link next?)

author: wilfred
author_rank: Super Contributor
timestamp: September 23, 2019, 09:19:52 am
content: Don't worry about welcoming new posters in the beginners section by questioning their low post count. Let's take our chances and give them the benefit of the doubt.There is a list of devices supported by the SNAP programmer herehttp://ww1.microchip.com/downloads/en/DeviceDoc/Device_Support.pdfThe SNAP programmer is 50% for a few more days with a coupon code and Microchip are also offering free shipping until end of Sept. SO you can get a Snap for cheap US$7.50 delivered. Shipping coupon MCHPFREE and SNAP 50% off TP1973I have to scroll down to see the coupon entry section.https://www.microchipdirect.com/product/Cat18_SubCat1?MPLAB%20Programmers%2FDebuggers%2FEmulators&treeid=6https://www.microchipdirect.com/

author: rstofer
author_rank: Super Contributor
timestamp: September 23, 2019, 03:03:42 pm
content: Quote from: viperidae on September 23, 2019, 08:20:12 amMy experience exactly re: PICs. I have a bin drawer full of 16F627 and 16F628 plus the popular (at the time) 16F877. I will never use them.Due to the architecture of the mid-range PIC, C compilers generate crap code with most of the instructions performing banking and paging, not user required computation. Now, it's true that the more modern CPUs have a deeper stack so code generation may be better but the AVR series is generally a better CPU in my opinion.From the OP:QuoteThe Arduino is a very powerful concept and within the family, there are some pretty nice processors, the ATmega2550 among them. It's an easy infrastructure to set up and there's no requirement to use the Arduino libraries. It seems to me that the OP has not hit the limit of an Arduino. Yes, the ATmega328P is a pretty small device but it has been used for some pretty amazing projects. There's plenty to learn about embedded from this easy to use device.Cypress PSoC4 is an interesting family - I ran through the video tutorials (again) the other day. There's one with an error (FWIW) where the shared variable used in the main() function and manipulated in the interrupt handler is not declared volatile. Other than that, the tutorials work fine. The IDE generates all of the functions based on the hardware definition. It is up to the user to flesh out the code. Very interesting concept.The STM32F boards are fun and the toolchain works perfectly. There are complaints about the auto-generated code being bloated but there's generally a LOT of memory.Perhaps if the objective is learning assembly language programming, the PIC might be perfect. It doesn't have very many instructions and there are a lot of vagaries to code around. Still a steep climb but more approachable than an ARM chip at the assembly level.To the head of the list is the Teensy 4.0 using the Arduino IDE and an ARM toolchain (Teensyduino).So, should progression be PIC->AVR->PIC32->ARM->Teensy/PSoC/Mbed or just cut to the chase and move to the ARM devoces?Within the first three PSoC 4 videos, the tutorial contains an interrupt handler (don't forget to add 'volatile' to the shared variable). This is a topic that is critically important and never discussed in the Arduino projects.PSoC 6 - a dual core processor - VERY powerful and there is a tutorial program.I like the LPC1768 mbed but I'm more interested in the PSoC world. It's pretty cool to plunk down devices on a schematic, assign them pins and connections and let the IDE develop the skeleton code. IN fact, with the PSoC family, you can interconnect devices with no code whatsoever. A blinking LED is just a clock block feeding a timer block feeding an output pin with no code required. It's all done in hardware.There's no way I could get talked into using a mid-range PIC again. There are far better platforms.

author: rstofer
author_rank: Super Contributor
timestamp: September 23, 2019, 03:30:32 pm
content: Earlier I mentioned writing bare metal code to create a timer with an interrupt handler blinking an LED. Here's a project that does just that and mixes a minimum of Arduino library to bare metal code: If the goal was to eliminate the Arduino function calls, it wouldn't be very hard.https://www.teachmemicro.com/arduino-timer-interrupt-tutorial/Look at the code block about half way down the page. THIS is bare metal programming and requires spending a LOT of time with the datasheet. Of course, the author is summarizing the research steps but as things get more complex, more time is spent reading the datasheet.I think the LED is blinking too fast so maybe there should be a counter in the interrupt handler that changes the 'state' variable every 10 interrupts - exercise for the interested...Lots of room to grow with the ATmega328P and the given code actually works. The learning starts when the instructions are matched with the datasheet.It is worth spending some time at that site. There are tutorials for a number of platforms.There is so much the ATmega328P can do that I'm not sure I would be in a hurry to go elsewhere. There's a LOT to learn with this chip.

author: MarkF
author_rank: Super Contributor
timestamp: September 23, 2019, 03:53:58 pm
content: Getting started with PICs:- Get aPICKIT 3 clone. It will do all the new PICs and you do not need the JTAG in the PICKit 4. Do not get the SNAP. It is just a limited version of the others.- Unless you need all of the I/O pins of the PIC16F877A, get the smaller PIC16F876A. The PIC16F886 is a cheaper version of those and has internal oscillator. You can also try the PIC18F2550 (used in the PICKIT 2) to play with USB.- There are some interesting options in the: PIC16F145x and PIC16F178x series in small packages. Also, the PIC18F2620 if you need a lot of memory.- All you need for any of the PIC16's and PIC18's is MPLAB X and their XC8 compiler.Everyone has their pet micro-controller. Don't let them distract you. Try those that interest you and decide for yourself.

author: wilfred
author_rank: Super Contributor
timestamp: September 24, 2019, 12:29:09 am
content: Quote from: MarkF on September 23, 2019, 03:53:58 pmThat's very true, and it doesn't have the robustness of a fully enclosed Pickit nor does it come with a USB cable.But for right now it is really cheap. And someone getting started with PIC it might help to use a genuine Microchip product with MPLAB.

author: FreddieChopin
author_rank: Regular Contributor
timestamp: September 24, 2019, 06:07:35 am
content: Quote from: iamericmin on September 22, 2019, 05:09:45 pmUntil you want to buy a C compiler that doesn't suck in every possible way. Here's a tip: learn ARM micros, ST has those nice discovery boards, for example STM32F4-DISCOVERY. You can use a regular gcc and you'll get better support than abunch of old farts, who've decided to stick with the worst possible tool just because they don't want to learn anything better.

author: rstofer
author_rank: Super Contributor
timestamp: September 24, 2019, 06:16:25 am
content: Quote from: FreddieChopin on September 24, 2019, 06:07:35 amAnd, should the OP choose the Teensy 4.0, he will get an ARM Cortex M7 with floating point hardware and a Teensyduino library that duplicates the functionality of the Arduino library. So, for the most part, Arduino projects work - just a heck of a lot faster.Same IDE, different hidden toolchain but still capable of bare metal programming while retaining the Arduino programming style via the IDE.There are too many good choices to mess around with PICs.

author: iamericmin
author_rank: Contributor
timestamp: September 24, 2019, 01:42:21 pm
content: Hi rstofer,I know Paul's amazing work on the Teensy lineup, and I have messed a round with the Teensy 3.2. However, I think they are a bit overkill for most of my projects as I don't need DAC-quality audio or intense mathematical computation.The reason I like PIC micros(from what I see so far) is because they have everything AVR chips don't have. For example, Full-speed USB in a 28-pin DIP package just seems too good to be true for me. As a novice hobbyist I just "bounce around" here and there, discovering/trying out new things every now and then.

author: rstofer
author_rank: Super Contributor
timestamp: September 24, 2019, 04:35:49 pm
content: Some years back I used the Teensy RawHID code to add switches and readouts to Microsoft Flight Simulator via USB HID. It was pretty easy, as I recall. I'm pretty sure I used the Teensy 2.0 which was based on an ATmega32U4 This chip comes in a 44 pin TQFP but that is pretty easy to solder. Adapters are useful for breadboarding:http://www.proto-advantage.com/store/product_info.php?products_id=2200108Nevertheless, experiment with the PIC and see how it goes.

author: L_Euler
author_rank: Regular Contributor
timestamp: September 24, 2019, 05:34:37 pm
content: I have a PicKit 4 with a ZIF socket that accomodates up to 40 pin DIP. The combo works well for me, but you may also want to look at just getting the Curiosity board that includes a re programmable PICucontroller, IO board, and programmer in one package for about $20. It's foolproof when used with MPLAB X IDE and XC8 compiler.

author: FreddieChopin
author_rank: Regular Contributor
timestamp: September 24, 2019, 05:37:26 pm
content: Quote from: iamericmin on September 24, 2019, 01:42:21 pm"Overkill for hobby" is suchunless your hobby is to develop production-grade systems where cost is important. What you should be looking at is how efficiently the device will help you accomplish your goals of learning.PIC C compilers are either:ancient (that is - bugged) and expensivesomewhat modern but horribly expensivefree but crippledpirated with possibility of FUD (fully undetectable) crypter being used to hide malwareWriting PIC assembly is borderline S&M stuff.PIC architecture itself is also crap with memory banking, stupid design decisions (analogs ON by default anyone?) and cucked instruction setWith ARMs you'll learn far more than with PIC and you won't waste your time cocking about with half-assed development software. Don't count on Microchip for help - they won't care unless you are bringing them $$$.It's somewhat like with soldering irons - "Oh I'm new to electronics, that $10 iron looks good" but soon you realize how crap it is and you buy something decent anyway. You've wasted money and more important - time - on something that was obviously crap but marketed at "beginners".

author: stoyanoff
author_rank: Contributor
timestamp: September 24, 2019, 06:07:21 pm
content: Quote from: iamericmin on September 24, 2019, 01:42:21 pmYes! Check the PIC32MM series! For this price they are beasts! And the other manufacturers have no equivalent!You need to understand all the people who write to this theme are correct in some ways! Every manufacturer has advantages and disadvantages. It depends on many factors.Just read the book! It is not quite new (it`s for 8 bit controllers) but it`s perfect for beginners!Best regards!PP: These PICs 32MM are no joke! I`ve a device with uploaded a PPP stack+3 opened ports and transferring data through 2xRS485 simultaneously - no problem! I have more then 10k buf on every RS485. And this for 2$...

author: MarkF
author_rank: Super Contributor
timestamp: September 24, 2019, 06:10:50 pm
content: Quote from: FreddieChopin on September 24, 2019, 05:37:26 pmDeveloping "production-grade systems" no longer fits into the hobby category.I found working with PIC registers a beneficial learning experience. Although, my experience goes back to the paper-tape era.The newer FREE Microsoft XC8 compiler doesn't seemed to be as crippled as you put on.I have found it very capable for my projects (some quite involved) in both memory size and execution speed.Every MCU has its quirks. Getting hung up with what's under the hood if it gets the job done is just silly.Clearly you are an ARM FanBoy and nothing else will please you.

author: TomS_
author_rank: Frequent Contributor
timestamp: September 24, 2019, 07:01:23 pm
content: Ask 10 different people about microcontrollers and you might just about get 10 different answers. And on that note, heres mine.For #2, my advice would be stay away from the 877. Its old tech by now, replaced by the 887 if I am not mistaken. But I might even go so far as to say stay away from that one too. The 877 was perhaps a bit of a stalwart of hobby electronics because it had loads of IO for the time, so probably still pops up in old articles or from old hats. It might have even looked impressive, being such a large package.There are likely better options out there. Probably what I would recommend is, and since you are new to this it would be a good learning experience that you may need in a future potential career, go to the Microchip website and start playing around with their parametric search feature. The right PIC is afterall going to be the one that offers the features you need to accomplish your projects. Newer PICs, or PICs from a higher series (e.g. PIC24 or even PIC32) will have more and better peripherals than an old school PIC16.Things you might like to consider are:* Do you need to read analoge sensors - does your chosen PIC have the right resolution, or even enough channels?* Are you going to be communicating with other devices - does your chosen PIC have the right interfaces available, or enough of them? UART, SPI, I2C, CAN, etc* Do you need lots of GPIOs for reading switches or turning indicator LEDs on and off, or even interfacing with parallel interface LCDs* You mentioned that a DIP40 was too big, but there are smaller PICs packed full of features in small packages like DIP28 (although you will compromise GPIO pin count, but there are ways to get around this, e.g. using IO expanders)* What voltage range does it need to operate on, or be compatible with, does it have low power modes for battery operated applications?* Internal EEPROM required, and how much?* Do you need to be able to drive LCD segments directly, and how many?* Maximum operating frequency* Internal flash and RAM capacities* etc etc etcYou'll be able to search on all of these metrics on their website to find a PIC that is more suitable to your needs.And these kinds of questions are why there are sooooo many to choose from, because they all have differing quantities, features and capabilities making each of them more suited to one application than another. Will a 16F1829 be a good starting point? It will be if it has the features that youre going to need! Otherwise, perhaps you need to define some projects that you would like to accomplish and look for something that offers the features suitable for them.Me personally, PIC are my go to microcontroller. I "grew up" with them, know how to drive them, and I understand the Microchip datasheet format so I can find what I need quickly and understand it. Most importantly I can get done what I need to do. Are there better microcontrollers out there? Well, maybe, probably. STM32 are certainly popular, but my smoke alarms have PIC16's in them and I have seen PIC32's used in elevator controls, so they cant be too bad. Its all about suitability, and also what your staff are familiar with, or just what ever "shop" you happen to be part of if you end up doing this for a living.As with everything in life, its only a bad decision if it hasnt been thought through. You wouldnt wear a sweater to the arctic, and so you wouldnt try use a PIC16 to operate a self driving car. Ok, probably a bad analogy, but the point I'm trying to make is, define your requirements and then pick the right tool for the job - not the other way around.As for #1, dont buy a clone PicKit, buy a genuine article. I personally dont like the fact someone can simply rip off someone elses design and even have the cheek to stick the original manufacturers logo on it when it is not the genuine article. I dont support such practices, and I dont think anyone else should either. If it is sold as a generic "compatible" item without original manufacturer branding, maybe. But a genuine article is not really that expensive either, and you'll get support from Microchip if anything goes wrong.

author: rstofer
author_rank: Super Contributor
timestamp: September 24, 2019, 07:16:06 pm
content: Don't overlook the utility of a decent bootloader like the Arduino uses. Whether I write to bare metal or use the complete set of Arduino libraries, the bootloading process remains the same. It just works! Of course, it doesn't have any JTAG or SWD debugging but printf() works for me.Then there is mbed with drag and drop board programming. You literally copy/paste the .bin file to the device which shows up as a mass storage device (disk drive letter) and reset the device. I really like using the online toolchain but it isn't required. You can download the toolchain for local development. Now that ARM owns mbed, there is a lot of work going on to build credible libraries for the various peripherals.The STM boards usually have ST-Link adapters attached. They break off if necessary. This is a full debugger and works well with the ST toolchain.Having to use something like a PICkit seems archaic somehow. Those I have had always worked ok, no problem there. But the older 16F chips with high voltage programming were a PITA to design around. You had to be careful of what you hung on that Vpp pin as a peripheral. The circuit had to prevent damage to components from the programming voltage.Anybody like the #pragma's used for setting up the PIC 'fuses'? The AVRs have the same concept.I have never had a lot of success with OpenOCD so I would prefer to skip over JTAG dongles and JTAG debugging. I haven't used OpenOCD for more than 10 years. Things may have gotten better.https://os.mbed.com/platforms/ST-Discovery-F746NG/I haven't used the cc5x C compiler with a PIC in many years but I do remember gettings errors that said, in effect, "what you wrote is correct code but we can't implement it". There were, at the time, serious limitations to the language.It's a real plus when you can get into a micro that is supported by GCC. That has simply got to be the most used compiler in the world with millions of users testing it every day.The ARMs are just so much more 'grown up' compared to the mid-range PICs and ATmega chips. Once we got the Cortex chips, versus the ARM7TDMI's, we got rid of most, if not all, of the assembly language startup file 'crt0.S'. Everything including setting up the interrupt vectors is now done in C. Much better...So many choices