Electronic Products
Find us here:
  • Books
    • Embedded C Books >
      • cbookfiles
      • cbook2files
      • cbook3files
    • BASIC Books >
      • Programming PICs in BASIC_vol1
      • PICBasic Book Support
      • Basic Atom Book Support
    • Other Books >
      • Arduino Book
      • chipkitbookfiles
  • Chuck's Blog
    • Blog Posts Archive
    • Disclaimer
  • YouTube Channel
  • About Chuck
    • About Chuck
    • Stock Car Racing
  • 3D Printing
    • Fabrikator Mini
  • Getting Started with PICs
    • BASIC Programming
    • C Programming >
      • C Compilers
  • Build Your Own PICKit 2
    • PICkit 2 Starter Kit
  • CHIPINO
    • Shields
  • CHIPAXE Breadboard Modules
  • Understanding Hex Files
  • chipKIT
  • Newsletter Archive
  • Contact
  • Retired Designs
    • BasicBoard
    • Ultimate OEM
    • Maximite BasicBox
    • Maximino
  • Downloads
  • Kickstarter Projects
    • Demo-Shield
  • Great Cow Basic Site
  • Buy Hardware
  • Links I Recommend

Programming Microchip PICs Made Easy

9/11/2014

5 Comments

 
I've been doing a lot of 3D printing lately but in the background I'm working on new books. One of them is an update to my Beginner's Guide to Embedded C Programming series. In the first series, I used MPLAB, HI-TECH C Compiler, PICkit 2 programmer and a PIC16F690. All those have been replaced. MPLAB X, XC8 Compiler, PICkit 3 programmer and the PIC16F1xxx family of enhanced mid-range devices. Something else changed recently which has me delaying my book, MPLAB Code Configurator (MCC).
Picture
MCC was in beta for a while but is now released and already on version 2.1, and it is awesome. With a few clicks of the mouse you can build a whole project of code (see it in the video below). Each peripheral is reduced to a set of check boxes or drop down menus. I/O can be configured with a GUI version of the chip. Even the main.c file can be generated. And the best part.....
.....all the code generated includes a library of functions for each peripheral written in XC8 code. Even I/O has its own set of functions such as:

RB0_SetHigh() 
RB0_SetLow()   
RB0_Toggle()  
RB0_GetValue()
RB0_SetDigitalInput()  
RB0_SetDigitalOutput()   
RB0_SetPullup()    
RB0_ResetPullup()   
RB0_SetAnalogMode()   
RB0_SetDigitalMode()

And these are just the I/O functions for the RB0 pin. And the function code is open source so you can see how its done. Great for learning.
It does the same for SPI, I2C, Timers, etc. You could take a module like the CHIPINO with fixed pinouts, install a PIC16F1936 (instead of PIC16F886), setup all the peripherals and connections to the I/O and then build the code. You'll have a main.c file with configurations set and ready for your custom code along with a library of functions for all the peripherals in the device. 

You basically just created your own Arduino style module from a CHIPINO. And you have debug capability through the PICkit 3, full access to the configuration to run slower speeds or faster speeds. And when you are done, unplug the PIC16F1936 and do it again for some other blank 28 pin PIC with different features. And because you don't need a custom bootloader device, you can use any PIC supported by MCC. And that list is growing with each release.

So stay tuned for more as I work this into my new series of books. Writing C code for PICs just got so easy. I cannot say that enough.


5 Comments
Gerald
9/11/2014 02:35:33 am

Hi Chuck,
Is there any way to use the vast library available with the Arduino with the normal pics?

Reply
Mike Giles
1/16/2016 09:53:04 pm

Yes, if you use a compatible compiler like this:
http://circuitcellar.com/cc-blog/execute-open-source-arduino-code-in-a-pic-microcontroller-using-the-mplab-ide/

Reply
chuck hellebuyck link
1/17/2016 11:53:35 am

Thanks for the comment but as you can see, my response below contained that exact information. Thanks for helping though.

Chuck Hellebuyck link
9/11/2014 06:43:08 am

Are there non-normal PICs ;-)
What Arduino did was simplify coding down to one module, one chip, one compiler, one programmer (bootloader). And then copied the BasicStamp style of easy to use functions but in C and it was a hit.

So to truly deliver what you ask would also require one device, one module, one compiler and one programmer (bootloader) then have it compatible with the Arduino code. The chipKIT module based on powerful PIC32 delivers that. It's compatible with Arduino code and most of the libraries. My book Getting Started with chipKIT shows you how to get started.

There is also an article by Tom Kibalo where he shows you how to program a PIC32 from MPLABX using XC32 compiler and Microstick module.
http://circuitcellar.com/cc-blog/execute-open-source-arduino-code-in-a-pic-microcontroller-using-the-mplab-ide/

I wrote a library similar to the core Arduino code for my book Beginner's Guide to Embedded C - Vol 3 using a CHIPINO module.

But ultimately I assume you are probably looking for a compiler that takes Arduino format code and creates a .hex file to be programmed into any PIC directly. Since the pinouts are different and the internal structure of an Atmel/Arduino device is different than a PIC, that is a tall order. So no I don't know of anything like that.

I find though that there is so much PIC code out on the web that I can usually find an example application for PIC without having to deal with Arduino conversion. Most PIC compilers such as PICBASIC, GreatCowBasic, CCS compiler and others have the same style of built in functions and lots of examples for PIC devices.

Reply
Gerald Gardiner
1/24/2016 09:14:16 am

Hi Chuck, how are the new books coming? Will they be replacements for the current ones and will there be anything put in the errers and corrections to update use with the new microchip software?
Regards, Gerald.

Reply



Leave a Reply.


    Categories

    All
    3D Printer
    Chipaxe
    Chipino
    Chipkit
    CNC
    Copper Connection
    Dot Matrix
    Elproductsnews
    Expresspcb
    Graphic Lcd
    Great Cow Basic
    Kickstarter
    Lcd Shield
    Makefaire
    Makercase
    Maximite
    Microchip Pic
    Pickit 2
    Pickit 3
    Videos

    Visit previous blog posts in the archives below.

    Archives

    February 2018
    October 2017
    September 2017
    July 2017
    November 2016
    August 2016
    July 2016
    May 2016
    March 2016
    January 2016
    November 2015
    September 2015
    August 2015
    July 2015
    June 2015
    April 2015
    March 2015
    February 2015
    January 2015
    December 2014
    November 2014
    October 2014
    September 2014
    August 2014
    July 2014
    June 2014
    May 2014
    April 2014
    March 2014
    February 2014
    January 2014
    December 2013
    November 2013
    October 2013
    September 2013
    August 2013
    July 2013
    June 2013
    May 2013
    April 2013
    March 2013
    October 2012
    October 2011

    RSS Feed



    About Chuck

    Chuck has been programming with PIC Microcontrollers since there were only five devices. Now there are over 700 and growing. He also has a lot of fun 3D printing designs using his Davinci 3D printer and TinkerCad software. In this series of blog posts and occasional videos on his YouTube Channel he tries to help you get started with electronics and 3D printing.

    Disclaimer

Powered by Create your own unique website with customizable templates.