Starting with PIC Microcontrollers - Page 1
Forum section: electronics / projects

author: jane will
author_rank: Newbie
timestamp: January 21, 2025, 06:27:21 pm
content: Hi everyone,I’m working on a simple automation project and plan to use a PIC microcontroller to control sensors and actuators. I found this excellent guide: Getting Started with PIC Microcontrollers (https://www.theengineeringprojects.com/2014/10/getting-started-with-pic-microcontrollers.html), which explains the basics really well.I’m looking for advice on which PIC microcontroller is best for beginners, especially for handling I/O and UART communication. Also, what common issues should I watch out for when programming or debugging? Any tips or tools you recommend for a smooth start would be super helpful.Thanks in advance for your help!

author: Gyro
author_rank: Super Contributor
timestamp: January 21, 2025, 06:43:42 pm
content: You might want to look at this very recent thread, which discusses some of your questions...https://www.eevblog.com/forum/beginners/program-pic-microcontrollers-and-coding-language/EDIT: (By very recent, I mean up to date. The page you referenced is from 2014)

author: MarkF
author_rank: Super Contributor
timestamp: January 21, 2025, 07:12:16 pm
content: Without knowing anything that you're planning on doing, I would stay away from the PIC32 and others with 'peripheral pin mapping'. Trying to get your head around being able to assign I/O peripherals to different pins is daunting.I think one of the PIC16 or PIC18 family would be a good place to start. One of the newer ones that you can use the internal oscillator instead of the need to mess with crystals. I have been using the PIC18F2525 and 4525 chips but there are other much cheaper PIC16 for $2 to $3 to get started.For development, download MPLAB X and the XC8 compiler. I use the built-in MPLAB configuration bit tool to setup the PIC. I stay away from all their other tools: harmony, etc. Just learn to talk directly to the PIC registers. And program in C. None of this assembly non-sense. I did enough assemble programming in the '80s to last a life time.Hardware wise you need to decide if you'll be doing 5V or 3.3V logic levels.You'll also need a programmer. I recommend one of the PICKit's 3 or 4. I use a PICKit 3 clone myself.Some will recommend the SNAP programmer but it's limited.I also bought thisUSB-to-TTL serial cablefor 3.3V operation with a PIC32MX. Look for the 5V version if you plan on doing 5V logic.I'm a bit old school and my projects have all required 5V logic. One thing I've noticed with the PIC(LF) 3.3V variants is that you can NOT run them at their full clock speed. Maybe I'm wrong here but that's my understanding. With 5V power levels and the built-in PLL you can expect typical master clock speeds of 32MHz from their internal clock. Which is plenty for most projects.

author: jpanhalt
author_rank: Super Contributor
timestamp: January 21, 2025, 07:29:38 pm
content: I have been using the PIC16F1xxx (enhanced midrange) series and Assembly with MPLab 8.92 for 20+ years in my hobbies. The only reason I haven't migrated to some newer versions is that I never needed to. Some questions are, how may I/O's do you need? Do you need IOC? Do you need OD (open drain outputs). Will you be reading a keyboard that is not serial (e.g., a 4x4 will use up 8 pins unless you have some other buffer to reduce it to SPI or other serial protocol. Do you need DIP or SOIC size for development? There are a lot of possibilities in that group, including some very small 10Fxxx devices.EDIT: I missed the UART question. Most of the range I mentioned have USART. It's simple to set up and uses a 1-wire interface to a character display.

author: woody
author_rank: Frequent Contributor
timestamp: January 21, 2025, 07:36:22 pm
content: Not sure about your budget, but take a look atwww.ccsinfo.comIde, c-compilers, programmers/debuggers, development kits. Their forum contains a lot of good info.Their compiler comes with a load of drivers and functions which makes blinking your first led a simple affair. Looking at the generated assembly code teaches a lot about how a pic and its peripherals work under the hood.

author: AussieBruce
author_rank: Regular Contributor
timestamp: January 21, 2025, 11:56:49 pm
content: I'd suggest you at least take a look at Arduino before getting going. The whole platform is designed for beginners and hobbyists, the programming language is simpler than C (although very similar), copious support plus a wide range of processor and interface boards available. I used to do things on PICs but after my first Arduino project would never go back.

author: fchk
author_rank: Frequent Contributor
timestamp: January 22, 2025, 09:04:19 am
content: Quote from: jane will on January 21, 2025, 06:27:21 pmThe easiest is PIC24/dsPIC33. These are 16 bit processors. Since the C language was designed for processors with at least 16 bit register width it's a better fit. And although this processor also has separate address spaces for code and data it is less visible here than on the 8 bit processors thanks to the PSW feature.Using any other series (PIC16, PIC18) is also perfectly fine. Peripherials are very similar across the product lines.Top Pitfalls:- Data Direction registers TRISx: On most platforms 0 is input 1 is output. On PIC 0=o as output and 1=I=i as input.- ANSELx: If a pin has got analog functions, the analog functions are enables by default. You must clear the corresponding bit in the ANSELx register first in order to make it a digital pin.

author: woody
author_rank: Frequent Contributor
timestamp: January 22, 2025, 09:45:50 am
content: Quote from: fchk on January 22, 2025, 09:04:19 amI fail to see why this would be a better fit, seen from the user perspective. Apart from that I think pic16/18 will give OP many more (and cheaper) devices to choose from with much more on-line material available to get the help they might need.

author: voltsandjolts
author_rank: Unknown
timestamp: January 22, 2025, 09:45:57 am
content: If it has to be PIC, then I would recommend PIC24.Nice arch and peripherals, quite capable range of devices, gcc compiler, datasheets very readable, not as overwhelming as some 32bit mcu datasheets.But also a great stepping stone to 32bit.

author: SteveThackery
author_rank: Super Contributor
timestamp: January 22, 2025, 09:59:19 am
content: I'm with @Aussie Bruce on this. Why start with PIC? Arduino is so much better for beginners. And cheap, too.

author: jpanhalt
author_rank: Super Contributor
timestamp: January 22, 2025, 10:01:21 am
content: The TS hasn't picked a device or responded yet. Along with what's been suggested for PICs, on some chips you need to turn off comparators, watch for input voltage levels (TTL or CMOS), turn off LVP (if present, default is on as you might expect), and decide on output (OD or push-pull). I don't see those as inconvenient, but rather as enhancements.

author: MarkF
author_rank: Super Contributor
timestamp: January 22, 2025, 01:22:34 pm
content: Quote from: jpanhalt on January 22, 2025, 10:01:21 amTurn off Low Voltage Programming (LVP) with caution.If I remember correctly, the SNAP programmer can ONLY do LVP. Turning off LVP will prevent the SNAP from programming the PIC. That's why I recommend one of the PICkit programmers.BTW: I always turn LVP off to have use of the extra I/O pin.

author: jpanhalt
author_rank: Super Contributor
timestamp: January 22, 2025, 01:35:10 pm
content: Sorry, I should have said to turn it off if you are not using it. That applies to all of the things I mentioned.

author: Geoff-AU
author_rank: Frequent Contributor
timestamp: January 23, 2025, 10:07:50 pm
content: Do you want top-down learning or bottom-up learning?If you're more interested in solving the problem (top-down) then Arduino 100%. It's easy, approachable, and fast to do basic things like twiddle IO and talk UART.If you're more interested in learning how microcontrollers work (bottom-up) then start with a basic 8-bit MCU (PIC or Atmel or maybe MSP430). Learn how to fiddle the right registers to make an IO pin twitch and build up from there.

author: djsb
author_rank: Super Contributor
timestamp: January 23, 2025, 11:32:44 pm
content: I help to teach PIC and Arduino MCU's on an embedded systems course. We use PIC16F819 (NO UART), PIC16F1827/47 (USART,SPI,I2C ADC etc). We use CCS C PCM compiler, and it is very easy to use with VERY good support on the official CCS info forum (but not in many other places. XC8 is well-supported on the official Microchip forum and here on EEVBLOG. It is, however, quite difficult to use for a beginner (which I still consider myself to be). I started out by using PIC assembly language on a PIC16F628A in 2014. We switched over to CCS C and have never looked back. Other compilers (Great cow Basic and Oshonsoft Basic) are available.Microchip has good support for DIP packages and is easy to use in a breadboard and on simple custom PCB's (using KiCad mainly) which is why we use them.Their programmers can be a bit more expensive for older chips, but the SNAP programmer at around £15 is good value (BUT can ONLY use LVP programming from the beginning (set in fuse config word/s) and newer chips with MPLABX 6.20+). There is one open source programmer available online and many cloned versions around.Arduino's are a separate topic I won't cover here in depth even though I also use the UNO, NANO and have started with the ESP32 platform recently.

author: zapta
author_rank: Super Contributor
timestamp: January 24, 2025, 06:13:46 pm
content: I wonder why you decided on a PIC rather than an Arduino, either original or from a third party.