PIC programming - how should I start (on Linux)? - Page 1
Forum section: electronics / general

author: miceuz
author_rank: Frequent Contributor
timestamp: January 19, 2014, 12:52:25 am
content: I've been programming AVR and ARM controllers for some time already, but the first page of Digikey sorted by price ascending makes PIC very tempting. As far as I know there are different programmers for different families of PICs and some compiler limitations. Can anyone shed some light what should I get to use bottom of the range microcontrollers?Should I get Pickit3? Are there any tools that work on Linux or at least under Wine? I'd preferably would like to program in C.

author: dannyf
author_rank: Super Contributor
timestamp: January 19, 2014, 02:19:15 am
content: Sounds like "programming" means two different things in your post.Programming 1 (as in burning code into a mcu): you need a programmer for that. pickits are cheap but less capable. ICDs more capable but more expensive too.Programming 2 (as in writing code to make mcu work for you): Sure you can do it in C.QuoteI tend to think it wiser that when you are trying to start, it pays to make your life easier. That means using Windows as much as you can.QuoteThen this whole thing will be super-easy for you.

author: Andy Watson
author_rank: Super Contributor
timestamp: January 19, 2014, 02:37:59 am
content: I use "gputils" and a text editor. To transfer the program to the PIC I use "PICdev"; this has several options for different programming hardware , e.g. from a few transistors hung on the serial port, or the Velleman K8048 kit, or even the PICkit II will plug-in without any hassle. All under Linux.

author: nctnico
author_rank: Super Contributor
timestamp: January 19, 2014, 11:07:57 am
content: Quote from: miceuz on January 19, 2014, 12:52:25 amYou will want the Hitech PIC compiler. That costs serious money so you'll have to use lots of PICs to save some money. And then you'll need to worry about in which memory bank to put a variable. I'd forget about Wine too. A lot of software doesn't work well. Better use Virtualbox to make a virtual machine.All in all you are probably better off looking at cheap MSP430 devices.

author: andersm
author_rank: Super Contributor
timestamp: January 19, 2014, 12:02:42 pm
content: Quote from: miceuz on January 19, 2014, 12:52:25 amMicrochip's MPLAB X IDE and XC8 compiler are available for (x86) Linux.

author: Maxlor
author_rank: Frequent Contributor
timestamp: January 19, 2014, 12:48:33 pm
content: PICkit3 as programmer, MPLABX as IDE, XC8 as compiler. The PICkit3 isn't that expensive, the software is free, it's supported by Microchip and it all works just fine on Linux. Try it first before evaluating 3rd party tools.

author: miceuz
author_rank: Frequent Contributor
timestamp: January 19, 2014, 03:47:19 pm
content: Quote from: Maxlor on January 19, 2014, 12:48:33 pmdough! Thanks! I've downloaded it and it works ok, at least it runs and compiles the code.Now is Pickit 3 THE programmer for all the MCU families?

author: miceuz
author_rank: Frequent Contributor
timestamp: January 19, 2014, 03:58:53 pm
content: Now I've read this thread and I'm totally confused...https://www.eevblog.com/forum/microcontrollers/pickit-3-still-seems-dodgyIs it really that bad?

author: dannyf
author_rank: Super Contributor
timestamp: January 19, 2014, 04:04:27 pm
content: xc8=picc/picc18 + (that dreaded) ocg.QuoteThat means the internet has fulfilled its promise,

author: AndyC_772
author_rank: Super Contributor
timestamp: January 19, 2014, 04:32:42 pm
content: I use MPLABX and my PICKIT3 on a daily basis.It just works. I have no complaints. No crashes, no random errors, no failures to connect, it's just a dependable tool which I can use to get the job done.For what it's worth, I wouldn't start on Linux, I'd start on Windows 7.

author: dannyf
author_rank: Super Contributor
timestamp: January 19, 2014, 04:43:30 pm
content: I always wondered about the need so many have to develop on Linux. I am not aware of any firm that officially supports it. The tool vendors don't support it - which totally makes sense given the lack of material demands. Yet, there are always people who insist on Linux - who are those people and what makes it so indispensible that they have to develop on Linux?If you make a living writing code, it seems to me that you want your tools, including the os to be reliable. Linux would be on bottom of that list for me.

author: Monkeh
author_rank: Super Contributor
timestamp: January 19, 2014, 05:03:42 pm
content: Quote from: dannyf on January 19, 2014, 04:43:30 pmLet's not start a great big OS debate, here, but.. As someone who's used Linux for many years in many applications, Linux is a reliable OS. It is used and officially supported by many companies, for many software applications, hardware tools, embedded devices, pieces of military hardware, and the very infrastructure in place to allow you to post on this forum relies on it heavily.I have always wondered about the need so many have to use a huge pile of legacy code with so little flexibility..

author: nctnico
author_rank: Super Contributor
timestamp: January 19, 2014, 05:09:42 pm
content: @dannyf: You are missing out on a lot of good stuff. I use Linux for software development almost exclusively. Even software intended to run on Windows. Linux makes life a whole lot easier.

author: dannyf
author_rank: Super Contributor
timestamp: January 19, 2014, 05:11:13 pm
content: The issue isn't linuxs own reliability but the combined reliability of Linux and tools running on top of it.as to companies that support officially development on Linux - they allow and support mcu software development on Linux, I would love to know a few as I have run into no one.

author: miceuz
author_rank: Frequent Contributor
timestamp: January 19, 2014, 05:13:11 pm
content: Quote from: dannyf on January 19, 2014, 04:43:30 pmWell, I'm a one band man and I use Linux. It's an OS of my choice after I've used windows and mac for quite a long time. That's where the need comes from. I don't want to have a separate machine (real or virtual) to only run some tools.Quote from: dannyf on January 19, 2014, 04:43:30 pmLinux is not that unreliable as you might think. Lot's of companies (at least software companies) are using Linux as a standard developement platform. But I get your point - if you need a tool, you use the OS the tool needs. It's more the question of convenience in my case. Opensource toolchains run smootly for AVR and ARM plaftorms on Linux.

author: poorchava
author_rank: Super Contributor
timestamp: January 19, 2014, 06:08:29 pm
content: How should you start? You should not.Pics are cheap for a reason, and the reason is that vast majority of them have truckloads of bugs. On top of that recent Microchip compilers are artificially crippled (output assembly is artificially bloated on purpose by insertion of Jin umps and nops) in free versions in order for them bo be able to brag about increased code efficiency of paid versions.Only thing good about Pics is that development tools are indeed great value for money and they are very affordable for pretty much everyone.If you are familiar with ARM, stick to them.

author: nctnico
author_rank: Super Contributor
timestamp: January 19, 2014, 06:22:37 pm
content: Quote from: dannyf on January 19, 2014, 05:11:13 pmNXP supports they LPCExpresso tools for Linux. Same for TI's Code Composer Studio. If you look you'll come up with a longer list.

author: Monkeh
author_rank: Super Contributor
timestamp: January 19, 2014, 06:27:37 pm
content: Quote from: dannyf on January 19, 2014, 05:11:13 pmhttp://www.ti.com/tool/ccstudiohttps://www.microchip.com/pagehandler/en-us/family/mplabx/Didn't look too hard, then..

author: AndyC_772
author_rank: Super Contributor
timestamp: January 19, 2014, 07:20:18 pm
content: Quote from: poorchava on January 19, 2014, 06:08:29 pmDon't start learning about one of the most widely used, versatile and inexpensive microcontroller families out there?Great advice there.QuoteThey're not that cheap. Compare and contrast like-for-like in terms of pin count and peripheral set, and you'll find that families like STM32 are actually cheaper as well as being much higher performance - but without the ease of use and some of the hardware capabilities that PICs tend to have. You'll struggle to find 5V operation or true EEPROM, for example.As for the bugs, there certainly are plenty of them, but they're clearly documented in readily available errata. Decide whether the bugs in any given device actually matter to your application, and work around them if necessary.QuoteTrue - but not an issue unless you're struggling for performance.

author: dannyf
author_rank: Super Contributor
timestamp: January 19, 2014, 08:12:47 pm
content: It looks like it will take a few tries to get people to understand the question: of those companies that develop applications on mcis, which supports the use if linux-based tools?hint: mcu OEMs shall not apply.

author: Monkeh
author_rank: Super Contributor
timestamp: January 19, 2014, 08:18:12 pm
content: Quote from: dannyf on January 19, 2014, 08:12:47 pmStill not understanding the question.Why would a third party company support your use of a tool?

author: andersm
author_rank: Super Contributor
timestamp: January 19, 2014, 09:30:15 pm
content: The irony being that Windows is a pretty bad development environment. Everyone ends up having to install a ton of Unix emulation tools just to make it bearable.

author: nctnico
author_rank: Super Contributor
timestamp: January 19, 2014, 10:14:41 pm
content: Quote from: dannyf on January 19, 2014, 08:12:47 pmMentor Graphics for starters:http://www.mentor.com/embedded-software/sourcery-tools/sourcery-codebench/editions/lite-edition/

author: dannyf
author_rank: Super Contributor
timestamp: January 19, 2014, 10:20:31 pm
content: QuoteOne more try:Of those companies that make a living developing code for mcus (an application shop), which one uses linux as official development environment?ie. this question is trying to get to the demand side of the equation: who uses linux development environment?

author: dannyf
author_rank: Super Contributor
timestamp: January 19, 2014, 10:23:30 pm
content: QuoteThat I think is the case: Linux development tools are used mostly by individuals / small shops on smaller scales.That contributes to the observation that most IDE vendors don't sell Linux environments.I for one have never seeing a company utilizing Linux environments to develop mcus (officially). You will have individuals doing it on a one-off or off-work basis, however - and that makes total sense.

author: Mechatrommer
author_rank: Super Contributor
timestamp: January 19, 2014, 11:00:55 pm
content: Quote from: andersm on January 19, 2014, 09:30:15 pmwhat?! penguin strikes again.

author: Maxlor
author_rank: Frequent Contributor
timestamp: January 20, 2014, 01:02:17 am
content: Returning back to the actual topic: The PICkit3 hasn't been 100% reliable for me either. Sometimes, it needs a reset by unplugging/replugging the USB cable. But it's happening rarely, so it doesn't bother me too much. Whenever it has happened, the issue has always been communication being lost between MPLABX and the PICkit3, I've never encountered any kind of corruption or misprogramming.as for XC8: yeah, the code it generates is bad (using the free version). But... it doesn't really matter, imo. If you run against the constraints because your code runs too slowly or doesn't fit into the flash, you can usually just increase the clock speed or use a PIC with more flash. If you're already using the biggest and fastest PIC, well, ARM's probably going to work out better for you, because the next firmware revision will need to have even more features.As for the PIC downsides, realistically, they're true, but most of the time they don't matter. This little dev setup that Microchip built gives you a huge amount of flexibility, letting you work with everything from small 6-pin micros to 32bit chips, with no other investment than a PICkit3, which is cheap. The docs are excellent. The chips... well, most bugs are usually fixed by the 3rd or 4th silicon revision (I just wonder why I see the same old bugs all over again whenever they release a new chip...) And there are faster chips out there, and ones that are easier to program in ASM. But usually you don't have quite the same selection of different parts, which might lead to having to use a bigger package than you really need for example. And most other setups don't have quite the same ease of use (unless you wan't to step into Arduino-land.) What I'm saying is, there's tradeoffs at every corner, I haven't found the perfect ecosystem yet. PICs are pretty nice, not exactly the holy grail, but not rubbish either. I enjoy using them.

author: dannyf
author_rank: Super Contributor
timestamp: January 20, 2014, 02:42:20 am
content: As long as we are dealing with computers / software, there will always be bugs, Microchip or otherwise.I would say that Micorchip mcus are quite bug free, based on my experience. If you want to see buggy chips, pick the erratas for some of the Luminary chips.As to XC8, unless you have to (for newer chips for example), I would say stay with your older Hi-tech non-ocg compilers - they produce better code, even the standard version, than the xc8 in free mode.

author: Monkeh
author_rank: Super Contributor
timestamp: January 20, 2014, 06:10:00 am
content: Quote from: dannyf on January 19, 2014, 10:20:31 pmI'm sure there are many; I don't work for them. A random forum is not the place to ask.

author: nctnico
author_rank: Super Contributor
timestamp: January 20, 2014, 10:01:41 am
content: Quote from: dannyf on January 19, 2014, 10:20:31 pmOne of my former employers used Linux for all embedded development. The company (>200 employees) got sold for 60 million euro a couple of years ago. Is that good enough?

author: meerweten
author_rank: Contributor
timestamp: January 22, 2014, 08:16:46 pm
content: Starting with PIC's on linux isn't that easy, just tried it myself (due to problems with windows stability :BANG: )Microchip actualy has a command line interface for the pickit 2 (don't know about the pickit 3, i only have the pickit 2 so don't bother looking for the pickit 3 support on linux), there are gui's out there on the big internet that work, but for most you need to start (run) them un root mode, cuss the pk2cmd is (on my computer) is only usable as a root user. but it took me 2-3 hours after i got it working, (even following a working tutorial)the "handy" thing about the pickit 2 (and probably 3 to) is that you can just use it for all their chips (well support for the pickit 2 ended and no new devices are addad, but i don't need them)in the pickit 2 there is a simple logic analizer included and a serial communication (didn't try them on linux yet, but works fine under windows).i've tried working with the avr's but i always gone back to pic's, for the simple reason i can get them cheaper

author: BloodyCactus
author_rank: Frequent Contributor
timestamp: January 23, 2014, 03:39:05 pm
content: I have no problem running MPLABX and PICKit3 on linux at all. Also run chipkit MPIDE /avrdude for the 'arduino' style pic boards with no issues.. shrug.pic32prog works fine under linux, which supports pic32 chips using pickit2, which is nice if you have a pickit2 and not pickit3.