• Home   /  
  • Archive by category "1"

Pic32 Compiler Homework

This is going to be a bit long as I wanted to cover all the obvious questions before they arise, give a rationale to some of my thinking, and prove I've done my groundwork! If time is short, skip down to the tl;dr section to get to the meat. The banner above also says this looks like a subjective post, so I'm going to expand the post a bit to narrow down exactly what it is I want to achieve.

I've had a really good look around stackexchange and there are similar-ish questions to mine, and I found the question Starting out PIC Programming useful but most were asked and answered before the new release of MPLAB X which is now based around the open source NetBeans IDE which is quite a change, so might tilt the balance.

Background: I bought an Arduino recently and having never done MCU fiddling before, and my programming knowledge limited to PHP, I was quite pleased with the results.

There's a few "fun" things I want to do to start with to get going before the “proper” stuff...

  • Make a kitchen countdown timer that rings a little handbell for a few seconds.
  • Make a chicken door opener.

Eventually I want to....

  • Build a data logger which will intercept and log the NIBE heat pump status and running time data from the external F2015 unit to the SMO 05 controller which runs on a CAT5 cable (once I’ve found out the data protocol!).

  • Interface with the IR interface “eye” of my electricity meter and log hourly readings of the actual energy usage (as opposed to the highly inaccurate but cheap clamp-the-wire monitors).

Looks like I have some choices here:

Arduino/Freeduino: Incredibly fast start - I had it speaking the words “ready”, then “button up” or “button down” (depending on state) using the PCM library, loudspeaker and the Uno within a few hours of opening the box and with 30 lines of code. But for each and every concurrent project, you need an Arduino.

**The Picaxe **- uses PicBasic and special pre-bootloaded PIC chips. The system is incredibly cheap and fast to get learning, allows the programmed chip to be taken out and used standalone in a breadboard, but at some point I’m going to need to expand beyond PICBasic.

Even I could cope with these first two options. Mainly because each has one high-level simplified language to learn, and one simple all-in-on IDE/compiler/programmer.

Standalone PIC: Then there’s the bog-standard £2 PIC chip and super-cheap K150 programmer allowing the programmed chip to be taken out and used standalone in a breadboard.

So when a K150, cable, CD with hex flashing software and a couple of PIC16F690 chips arrived yesterday morning, I was starting with a blank sheet. I can write php and understand the basics of object oriented languages, and did a little C at college, enough to get me started quicker on the Arduino than if I’d done none. But I also understand that Arduino’s ‘Wiring’ is an extremely simplified superset of C, so I’m going to have to get more down and dirty for programming the K150 of course. Maybe assembler one day, but for opening a chicken run door when it gets light, I’m fairly sure C will suffice to start!

The problem I have is.... so many options!

I hope I have proved to have done my homework with this 12 sheet spreadsheet with over 200 listings and links to different types of projects, reference and help sites etc. According to Chrome I looked at 118 related sites on the day I got the K150, and over 330 relevant sites in the last 4 days. So I’ve definitely done some groundwork!

Yes, I know I should buy the PicKit3 and that somehow having bought the K150 makes me the spawn of satan according to the replies other K150 owners have got on forums. One day I’m sure I’ll buy it, but right now I’m just getting going as a hobby. I’ve bought an official Arduino so I’ve salved my soul that way!

tl;dr - enough waffle, what’s the question?!

As I understand it, as long as I can compile hex, I can program a PIC chip with the K150 or pretty much any compatible programmer.

Unless I’m mistaken, I have the following choices:

MPLAB X and PIKlab are both free IDEs compatible with most Microchips PIC chips.

Hi-Tech C Compiler, Sourceboost, Codeblocks and SDCC are all Microchips compatible compilers, some free like SDCC, some free with limited functionality, some only free for one specific chip.

Then there’s PicBasic Pro, £99 for the full suite or £30 for the student edition of the compiler alone. Right now, £99 is a fairly high amount for “having a play” - anything to recommend Picbasic over C?

I’ve also been watching some of the official and unofficial training videos for some of the above.

At this point in time, my intention is not world domination or the next RaspberryPI, it’s to be able to blink an LED, maybe take keypad input, maybe even make a Charlieplexed LEDcube for Christmas.

I’m getting on in my years and am of limited brain and time; the obvious thing would be to have the time to try all of the above and see which suited me. Not really practical.

I need to pick one, learn it, and stick with it. Yes, Google has been my friend, but a lot of the reviews of these IDEs and compilers refer to quit old versions. I’ve even found links to sites at Demon Internet and Geocities - 1994-1996 seems to be the peak bubble of activity for discussion on burning your own PIC code. And a lot changes in 8 years.

So my question would be:

If YOU were starting out now, what IDE and compiler would you choose, and why?

Thanks, and sorry this was such a long post!


EE 310/310L: Microprocessors and System Design
Instructor: Dr. Farid Farahmand
Spring 2017

    Lecture/Lab:Tues. 9:00 am-11:40 am/ Thur. 8:00 am-10:40 am
    Office Hours:click here
    Office: Salazar 2010
    Phone: (707) 664-3491
    Email: farid dot farahmand at sonoma dot edu

Course Description: The primary goal of this course is to give you the fundamental skills needed to understand, use, and design microcontroller-based systems. This includes the following: (1) What is a microcontroller? (2) What can it do (and not do)? (3) How does one design (and program) a microcontroller-based system? The course focuses on 8-bit PIC architecture. You will be using PIC18F46J50 chip.


DayLectureReading MaterialAssignment/Activity Due
1/24Read the syllabus carefully Start Reading Chapter 1; 

Sign up for EE 310 in Piazza - Piazza app is available for smartphone / Bring a folder with your name on it! / Make sure you order the Textbooks / Submit Statement of Ethics / Review the web page!

Make sure you have the following:

  1. A Folder for all the assignments.
  2. Arrange to have your own LAPTOP; Apple owners may experience extra challanges!
  3. If you are using a MAC have a visrual-box
  • Chapter 2 - Architecture, Opcodes, Memory Structure, ALU, Stack and Pointers, PIC Controllers, IDE Simulator
  • Introducing Oshon Soft Simulator IDE
  • Review the Diigo Class Links
  • Read Appendix F (in Piazza)- up to F.1.5 - become familiar with how to blink an LED!
  • Answer these questions: Chapter 1- Questions
  • Read about RISC & CISC architectures and solve the last problem (videos are aviilable on Piazza)
  • Read the Syllabus carefully to learn how to submit your assignments / Review the Lab Template
  • In class (ICL-0) : Modify the program in Appendix F
  • Quiz 1B; If you did not do well in the first quiz do the quiz again on Moodle (Thursday 8-8 pm)/ read **sample questions**
  • Show your working ICL-0
  • Continue with PIC instrucitons.
  • Learn about MIPS - how useful is it? (see the MIPS Example)
  • In class(ICL-2) : Save CheckCarry code into your project directory - Find its errors (if any) and compile it. Add F1 + F1. Show the results.
  • In class(ICL-2) Write a program: Add 78 + F1. Show the results. Hex Calculator
  • Go over Lab 2 and make sure you know how to do the assisgnment. Pay attention to details!
  • Quiz 3 (Chapter 2 & 3 - see review questions - assembly commands, features of PIC, Status register, simple programs)
  • Submit: Lab 2
  • Article 2 is due - submit through Piazza
  • In class: Write a program to save your name in program memory starting 0x100 - Must show!
  • Division operation in assembly
  • Package Types
  • Chapter 6 - See notes
  • Quiz 4 (Directives / Logic & Math commands / MIPS / Indirect addressing / FSR / Program example)
  • In class (ICL-3): Taking the Min/Max & Average - Read the textbook for details. Pay attention to how we divide by 16!
  • Quiz (write a program in class)
  • Install Mouser Software!
  • In class (ICL-4): Do the program in the slides. Answer the questions.
3/14-16Spring BreakSpring BreakSpring Break
  • Submit and demostrate Lab 5
  • Quiz (Indirect addressing / Macro and subroutine . PC & Stack / Table Pointers / Programming Example)
  • In class: Read Program Example 9.5; Modify your LED Blinking program such that it stops blinking when the SW is pressed!
3/23Midterm Exam (Review Questions)Midterm Exam 
  • In class: Using the Online compiler write a C program to generate the following sequences: 0,2,0,4,0,8,..0,128,0,2,0,4,0... (Example C programs)
  • In class: Write a C program to blink number 1 on your 7 segment.
  • Submit Lab 7 - Must demonstrate in class.
4/6Chapter 10 - Interrupts in PICSummary of Interrupt Registers in PIC
4/11Chapter 12 - Analog to Digital Converters / Op-amps / Digital to Analog converters/
  • Submit Lab 8 - C Programing
4/13Cont. with Chapter 12 


  • Submit an abstract for your project Read Course Syllabus for more information about the abstract for final project.
  • Quiz - In class program / C - Book (Chapters 1-4 & 6) & Interrupts
4/20Chapter 13 ( USART Interface. See your notes) / A practical guide to USART
4/25Chapter 13 ( USART Interface. See your notes) / A practical guide to USART 
  • Submit Lab 9 - ADC and Random Number Generation
  • In class: Examine signal timing
  • Quiz / Opamps / ADC / LCD
5/4Chapter 11 / WDT/Clocks / Reset
  • Article 4 is due - submit through Moodle
  • EWork on your projects!
  • Quiz / Review questions for serial communication / In class program (LCD & USART)
5/11Project Presentation - Review/ Read the Course Syllabus Carefully for Project Guidelines - See Moodle for more informationPOST your slides on (something like) a tri-folding board. You can buy a hard board and turn it into a tri-folding board (buy one from Dollar Store for $1  
5/16Final Exam / Submit class evaluation form / / Submit your final CD / No late submisison is allowed. 

****Submit Lab 11 - TMR0 & CCP ****

In order to be able to take the final exam you are required to bring a snapshot of your Moodle indicating that you have completed the class evaluations.

Lecture Related ((supplementary material):)General

Chapter 1:

Chapter 2------------------------

C- Programing ------------------------




Tools & Software:

Important Resources


Link to previous versions of this class (ABET):

  1. Spring 2016 - A part list was provided to students. Students were required to purchase their own parts. This can improve the quality of final projects.
  2. Fall 2015 - Many students experienced difficulties with C programing. Several interactive programing tools were included in the course so the students can practice. A separate section on C programming was also added to the course; we also added an eBook for students to review.
  3. Spring 2015 - Using PIC DEMO Board / MPLAB & C18 Compiler / PicKit2 / Chip Kit / More advanced sensros were used
  4. Spring 2014 - Using PIC DEMO Board / MPLAB & C18 Compiler / PicKit2 / Chip Kit
  5. Spring 2012 - Using PIC DEMO Board / MPLAB & C18 Compiler / PicKit2
  6. Spring 2010 - Using PIC DEMO Board / MPLAB & C18 Compiler / PicKit2
  7. Spring 2009 - Using PIC DEMO Board / MPLAB & C18 Compiler ()/ PicKit2


One thought on “Pic32 Compiler Homework

Leave a comment

L'indirizzo email non verrà pubblicato. I campi obbligatori sono contrassegnati *