Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Hitech PICC Need help for C

Status
Not open for further replies.

neazoi

Advanced Member level 6
Joined
Jan 5, 2008
Messages
4,122
Helped
13
Reputation
26
Reaction score
15
Trophy points
1,318
Location
Greece
Activity points
36,951
Hello,
Is there any good guide in getting started in embedded C and Hitech PICC?

I have red some tutorials on the pic16f84 and assembly programming on it but I need to get started on embedded C.

I am a web programmer so I am able to understand what I am reading, I just need to know the embedded C rules/definitions etc. sources with examples are desirable.

My basic question. Is embedded C rules the same, regardless of the compiler to use?
 
Last edited:

Yes.

The following tutorial are excellent.

**broken link removed**

They cover both the baseline and midrange PIC families, using both MPASM Assembly and Hi-Tech C languages.

They are very professionally done, cover a wide range of topics and best of all they are free.

BigDog

---------- Post added at 23:55 ---------- Previous post was at 23:49 ----------

My basic question. Is embedded C rules the same, regardless of the compiler to use?

The answer unfortunately is No. Some C Compilers are more compliant to Standard C (C89) & (C90) than others.

There is also a wide variation in C Extensions which are not defined by Standard C, but are needed to deal with various aspects of the embedded devices for which they are compiling code.

I personally like Hi-Tech C Compilers, however Microchip recently purchased the company and began to incorporate many of the features of the Hi-Tech line into their compilers, slowing phasing out the Hi-Tech versions for various PIC families.

It is a fairly easy transition from using Hi-Tech to the Microchip Compilers, as they are being merged together.

BigDog
 

You should have some basic understanding about microcontrollers to program those PICs n other microcontrollers...

There are several C compilers available for programming PICs... All of them support most of the keywords used in C language...

Based on my experience, different C compilers provide different set of libraries and there are small differences in each library functions.
So a program C program written using one compiler can not be used with another compiler mainly due to differences in library differences..

However the basic keywords (Is that you mentioned as "C rules"?) are same in most of the compilers...

You need to have a basic understanding about the architecture of the microcontroller to program it...
Specially, what are the available resources, peripherals available and how to control them using the registers (registers are the control interface provided to the programmer to control the resources and peripherals of the microcontroller....).

If you have programming knowledge and some basic understanding about microcontrollers, I don't see any difficulty in getting into PIC programming (any microcontroller programming in general... )

The best way to learn it with some simulation package such as "Proteus" if you have access to that... If not just buy a development kit from ebay and start coding.... :)

cheers,
 

I have noticed that the mplabx/hitech picc has some code examples/projects embedded. Maybe I should start looking at code snippets relevant of what I need to do for a quicker learning? as you said some things rely on the specific micro you program, unlike C for PC. But some things are quite easy to understand by just looking at the code. For example printing characters on an LCD using the internal examples given.
I think a side by side tutorial reading and code trying would be the best...
If there is anything else I should consider please let me know.
 

If you study the Gooligum Tutorials and work through the examples as well as review the compiler manual of your choosing, you should be well on your way.

When you hit a snag, just start a thread here on the forum and I and others with gladly assist you.

Do you have a PIC development board? If not the Gooligum Tutorials provide enough information for you to breadboard a PIC with the few components needed.

The tutorials start off with the PIC12F series and later move into the PIC16F series, you can most likely get by with less than $10 worth of parts.

BigDog

---------- Post added at 01:44 ---------- Previous post was at 01:12 ----------

If you have not already done so, the following is the link to the freely downloadable Hi-Tech C Compiler for Baseline and Midrange PICs:

**broken link removed**

The only limitation with the Hi-Tech C Compiler is the level of optimization, which should not be an issue for your current purposes.

You can then either work through the examples using a simulator, like ISIS Proteus:

Proteus Professional Demonstration

Or using real hardware as outlined in the first lesson:





If you cannot obtain the exact PIC used in the lesson, there are plenty of adaptable versions which will fulfill the lesson requirements.

The Tutorials give the option of using breadboarded parts or using a Microchip Development Board:

Gooligum Introduction to PIC Microcontrollers


If you do decide to learn by using real hardware, you will need to purchase a PIC programmer/debugger, the following are some of Microchip's offerings:

**broken link removed**

The PICkit 2 Starter Kit includes a development board the Gooligum Tutorials recommend as an option in their lessons.


If you have any other questions feel free to post them.

BigDog
 
Last edited by a moderator:
Thank you very much for the information. It is a base to begin!
To be honest currently, I am more confident with assembly for the pic16f84, even if it sounds a bit crazy. :)
That is because I have read in depth the information provided here **broken link removed**
I hope I have the same luck with C :)
Just a final question please. Does the MPASM provide code optimization? I.e. if you write assembly code, to optimize this code.
Thanks a lot!
 
Last edited:

As per my knowledge, MPASM does not optimize the code, just converts assembly code into binary format to be able to write in the flash mem. in the PIC.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top