Author Topic: PIC C - Hitech C compiler  (Read 10479 times)

0 Members and 1 Guest are viewing this topic.

Offline DrirrTopic starter

  • Regular Contributor
  • *
  • Posts: 76
PIC C - Hitech C compiler
« on: June 14, 2011, 08:11:58 am »
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!


 

Offline scrat

  • Frequent Contributor
  • **
  • Posts: 608
  • Country: it
Re: PIC C - Hitech C compiler
« Reply #1 on: June 14, 2011, 08:43:57 am »
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.
One machine can do the work of fifty ordinary men. No machine can do the work of one extraordinary man. - Elbert Hubbard
 

Offline DrirrTopic starter

  • Regular Contributor
  • *
  • Posts: 76
Re: PIC C - Hitech C compiler
« Reply #2 on: June 14, 2011, 11:57:05 am »
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  :'(
 

Offline reeraslan

  • Newbie
  • Posts: 4
Re: PIC C - Hitech C compiler
« Reply #3 on: June 21, 2011, 12:22:08 pm »
i am looking on this too , please if you find some tutorials could you tell me ?
 

Offline ivan747

  • Super Contributor
  • ***
  • Posts: 2046
  • Country: us
Re: PIC C - Hitech C compiler
« Reply #4 on: June 21, 2011, 05:33:33 pm »
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.
 

Offline A-sic Enginerd

  • Regular Contributor
  • *
  • Posts: 144
Re: PIC C - Hitech C compiler
« Reply #5 on: June 21, 2011, 09:43:06 pm »
These are always loaded questions to me.
Are you asking for advice on learning C?
or
learning 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.
The more you learn, the more you realize just how little you really know.

- college buddy and long time friend KernerD (aka: Dr. Pinhead)
 

Offline VK3DRB

  • Super Contributor
  • ***
  • Posts: 2261
  • Country: au
Re: PIC C - Hitech C compiler
« Reply #6 on: March 03, 2012, 04:56:13 am »
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.
 

Offline kaz911

  • Super Contributor
  • ***
  • Posts: 1052
  • Country: gb
Re: PIC C - Hitech C compiler
« Reply #7 on: March 03, 2012, 12:11:43 pm »
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)
 

Offline mariush

  • Super Contributor
  • ***
  • Posts: 5135
  • Country: ro
  • .
Re: PIC C - Hitech C compiler
« Reply #8 on: March 15, 2012, 10:29:52 pm »
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.htm

It'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.
 

Offline gregariz

  • Frequent Contributor
  • **
  • Posts: 545
  • Country: us
Re: PIC C - Hitech C compiler
« Reply #9 on: March 15, 2012, 11:13:50 pm »
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)

I 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.
 

Offline Black_Moons

  • Newbie
  • Posts: 3
  • Country: 00
    • Prototype Machining
Re: PIC C - Hitech C compiler
« Reply #10 on: March 24, 2012, 04:16:32 pm »
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.
http://www.PrototypeMachining.ca
Making your dreams come to life
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf