PIC C - Hitech C compiler - Page 1
Forum section: electronics / general

author: Drirr
author_rank: Regular Contributor
timestamp: June 14, 2011, 08:11:58 am
content: Hi,I would like to learn to program PIC 16F877A in C, using Hitech C compiler (implemented in MPlab).My knowledge is very weak. I only programmed some console applications in C and PIC ASM.Do you have any advices? How to begin or some literature?Thanks a lot!

author: scrat
author_rank: Frequent Contributor
timestamp: June 14, 2011, 08:43:57 am
content: There are lots of tutorials and examples, some of them comprising a workspace file, that allows you to just open and compile.Besides this, you need a programmer/debugger, the one that is usually advised is the PicKit2.

author: Drirr
author_rank: Regular Contributor
timestamp: June 14, 2011, 11:57:05 am
content: I found some examples of code in "Getting started with HI.TECH C compiler for 10/12/16 MCUs". But other examples were diferent, they were using 16F877A.h header file, but not htc.h

author: reeraslan
author_rank: Newbie
timestamp: June 21, 2011, 12:22:08 pm
content: i am looking on this too , please if you find some tutorials could you tell me ?

author: ivan747
author_rank: Super Contributor
timestamp: June 21, 2011, 05:33:33 pm
content: Yeah, I want to move from CCS to Hi-tech. Hi-tech is free and if I ever found myself making 5000 units I would definitely buy it and use the code compression tool and get a cheaper PIC.

author: A-sic Enginerd
author_rank: Regular Contributor
timestamp: June 21, 2011, 09:43:06 pm
content: These are always loaded questions to me.Are you asking for advice on learning C?orlearning on how to program the specific microcontroller (and using the cross compiler)?I'm guessing that a lot of the times that I see this in the eevblog forums the answer would be: "both"My opinion: wrong answer.My suggestion: learn even just the fundamentals of C first. Even more desirable would be to learn some basic programming methodologies first, but I'm guessing the odds of that ever happening are just about non-existent.Once you understand C and are comfortable with it, learning the specifics of how to deal with the microcontroller as well as the nuances of any of the cross-compiler quirks becomes much much more manageable. At that point, walking through the tutorials that come with the specific tools and you'll be board with twiddling LEDs in no time.Off the top of my head I don't recall which compiler is installed on my system for PIC right now. Might even be the Hi-tech one. But I do know that it came with a tutorial and after having the tools installed I had a handle on things in just one short evening. Trying to learn microcontrollers, a new programming language, and the specifics of the tools in hand is a pretty daunting task. Grossly inefficient way to learn, ESPECIALLY if you're lacking knowledge in more than just one of those areas. Need to break it down and get a decent handle on the parts you can first before trying to combine everything in one pot.

author: VK3DRB
author_rank: Super Contributor
timestamp: March 03, 2012, 04:56:13 am
content: The Hitech C compiler is OK for the free version. But the user manual provided is atrocious. Full of typos, missing key information, editing problems - very amateurish manual looks like it came on a diskette as freeware.The other issue is always check identifiers in the header files for each chip. Microchip have a habit of changing names of definitions, so something that compiles well for one chip type fails on another unless it is edited - a trap for new players. There does not seem to be information as to what changes.... you just have to do a search in the chip's header file (eg: 16F1937.h) on what you think it should be. Some definitions have moved into a structure.Even so, the compiler itself is good, and integrates well into MPLAB and the PICkit2 or PICkit 3 quite well.

author: kaz911
author_rank: Super Contributor
timestamp: March 03, 2012, 12:11:43 pm
content: if you wait for another month the "merge" of Hitec C and C18 is done in a new compiler called XC that covers from small PIC to PIC18 in one version.I find Hitec and C18 lacking in current documentation - and as mentioned before - Labels change between processors. In MPLAB X it is really bad since neither Hitec C or C18 are really made for MPLAB X. So lots of "hunting in manuals to get anything done.The easiest I have tried is MicroC from MicroElectronica. But the free version is limited to 2k program words. (Use any kind of floating math and 1/2 is gone on libs already) - but it is very easy to use - and easy to find libraries to include and documentation on the libraries. With both Hitec and C18 it is a PAIN... I have not tried CCS (yet)

author: mariush
author_rank: Super Contributor
timestamp: March 15, 2012, 10:29:52 pm
content: The installation folder for Hi-Tech C has a Samples folder with several decent examples.I've also found the examples on this page very useful to get an idea about how some things work :http://www.eagleairaust.com.au/sampcode.htmIt's not hard to understand, actually I quite like it. I tried MikroC but found it a bit confusing and I quite like how mplab-x integrates with the pickit3.There are some things that are annoying such as MPLAB-X not recognizing compiler macros like __delay_us() - you can compile once but the second time it doesn't understand them. I managed to avoid them by writing my own routines.There's also a well known bug where if you click something in mplab-x project properties, it writes a file incorrectly and it gets confused by paths with spaces in the name - you can solve this by installing the compiler in a folder without spaces in the path and by moving the projects somewhere without spaces in path.Or you have to edit some makefile to put the path between " " or delete the previously compiled files every time this happens.

author: gregariz
author_rank: Frequent Contributor
timestamp: March 15, 2012, 11:13:50 pm
content: Quote from: kaz911 on March 03, 2012, 12:11:43 pmI typically use CCS and Mikroe compilers for the pic. Both are very well documented I find. CCS has less in the way of libraries - but the forums are excellent so that has gotten me through. CCS seems very rock solid. My only complaint with the Mikroe compiler was that everynow and then I would see some funny stuff happen in the code when calling a number of different libraries within the same routines, however I've come to find out that some of the problems were me trying to break the rules for a particular PIC. CCS typically will give error feedback in those cases whereas MikroE won't necessarily flag it, however I agree that the MikroE is probably the easiest I have tried as well.I find microchips offerings to have improved with MPLAB-X however the documentation is still attrocious. I found I needed to rely on 3rd party documents, books and tutorials. There has/had been a long running series using C18 and Hitech in EPE magazine.

author: Black_Moons
author_rank: Newbie
timestamp: March 24, 2012, 04:16:32 pm
content: When I tried Hitec C18 a few years back it would compile the USB pic examples provided by microchip, but the result would not run correctly.It would produce insanely long interrupts (About 200 instructions overhead) where it would save/restore every single register on the entire pic, just because the interrupt code spanned more then one C file and it was not smart enough to check the other file to see what registers it used.It may of improved since then, but I was not impressed at all.