Oops. I made a mistake. I have done my best to correct it. HI-TECH isn’t that bad of a free compiler. I’m going to do my best to showcase it by showing what you can do with it and how you can do it. The first source file is to turn on PORTC5 (Pin 5) of the PIC16F690.
In 2008 I started a project, and I never finished it for those who visit this site. I had a working project, but never did good documentation. I have finally pulled through with the final product! In this post you should be able to find: both schematics, both programs, and some pictures. What you won’t find is the circuit boards. I made them using the old fashioned way with Ferric Chloride and some Radidio* Shack press on etching strips. (*intentional misspelling)
In my quest to study microcontrollers, I wanted to give Atmel a shot. I did some digging to find that Atmel has some great stuff out there that is free. They have a great studio (AVR Studio 4/5) that allows you to write Assembly or C programs. Once you install AVR Studio and write a C program, trying to compile it won’t work right out of the box, but it directs you to WinAVR. It needs that to compile C programs.
I wrote a small program to test the simulator. Yes, a sim!!! Totally cool. While I won’t be using Atmel any time soon, I wanted to be sure that it gets some light. I think that I would choose to use Atmel if my plate weren’t already full with school obligations.
Check out how easy it can be by looking at this sample program: avr-libc: A simple project
There is plenty of help at the avr-libc location. I believe that even beginners can get up to speed quickly with the online manual.
You can find programmers for purchase at Atmel.com.
Lately, I have had my eyes opened some in the microcontroller field. C compilers for Microchip: HI-TECH or CCS? Free or pay? The article pretty much blasts Hi-Tech for being expensive and for creating code that is less than optimal. I really had a “come to Jesus” moment recently when I realized that not everyone wants to pay $150 or $200 dollars for a compiler. This is especially true if the hobby is planned to be short lived.
I did a little research to find the compiler listing for Microchip. Both MPLAB C and HI-TECH have lite versions for programming Microchip’s microcontrollers. Microchip C Compilers…HI-TECH User Manual…There are several MPLAB C user Manuals depending on the chip structure.
The Pickit 3 programmer is less than $50 usd. You don’t even need special programmer hardware since you can build a header in your circuit to program any chip. The PDF user’s manual describes how to program the ICs. See page 24. Pickit3 User Guide
I have had to learn C for Freescale microcontrollers for school. I can’t say that using Freescale is easy, but I have enjoyed learning. I had to buy this book for school, and it has helped some. The downside is the price. The HCS12/ 9S12 by Han-Way Huang
Freescale has offered a great compiler for free. The other cool thing about Codewarrior is that it is supported in Linux (IDE!!!). Codewarrior…Codewarrior specs
I could not find a tutorial or user manual for Codewarrior, but I can tell you that programming Freescale is a labor intensive process that involves an intimate involvement with the register names. Example, in CCS, to make an output high you simply say ‘output_high(PIN_A1);’. This is not the case for Freescale. ‘DDRA=0×01; PORTA=0×01;’. DDRA sets the direction of port a, pin 0 as output. PORTA sets that pin high.
I hope that this information is helpful. 2.5 years ago when I wrote the original article about Hi-tech and CCS, I was looking for a “get rich quick” scheme to programming in C. I found the book and used the compiler from that book. Yes, I have gained much knowledge from it, but now I share with you that the same can be done with any of these products for less money. The code may not be optimised with the lite versions and there may be some tiny limitations, but for beginners that isn’t going to make a difference. Even for the more advanced users, these limitations are not that bad.
I was messing around with a parallel LCD earlier, and I could not figure out how to display variables to it. I was becoming agitated when an idea came to mind. When I programmed clocks, I remember breaking the time down into four segments. The same thing applies here. Bingo. Below is my test code in C++ to emulate C. The only difference is the integers on a computer are 4 BYTES in length. In the test code for a negative numbers in a microcontroller, there will need to be an overloaded function to send signed integers to since an unsigned integer might be misinterpreted as signed. There will be more challenges ahead. There will need to be other approaches for floating numbers.
There is no error checking in the code below. Be sure that you do not exceed the length of the character array. They will always need one more place to account for the null character.