Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Tools
Old 6th January 2009, 02:49 AM   #1
Default Hi-Tech C

I just recently got into C programming for the PIC's, and I am completely lost as to what compiler I have to pick. I have the PIC 16F877A.

I have ran C programs on the PIC, but I am having trouble decoding what the program instruction do - I havnt found any useful tutorial for Hi-Tech C (Im using the PIC lite intergration with MPLAB)

Are there any useful tutorials, etc. Or are there better compilers, with a larger support base.
usif is offline  
Old 6th January 2009, 03:18 AM   #2
Default

Quote:
Originally Posted by usif View Post
I just recently got into C programming for the PIC's, and I am completely lost as to what compiler I have to pick. I have the PIC 16F877A.

I have ran C programs on the PIC, but I am having trouble decoding what the program instruction do - I havnt found any useful tutorial for Hi-Tech C (Im using the PIC lite intergration with MPLAB)

Are there any useful tutorials, etc. Or are there better compilers, with a larger support base.
Grab the BoostC demo from SourceBoost. It's an excellent PIC compiler. The demo works on all supported PICs. It's only memory and code size limited. When your programs get too big for the demo you can buy a full license for about $75. That gets you both 16F and 18F compilers, as well as support for some 12F's. A ton of bang for the buck!

You can't beat that deal anywhere. Microchip's C18 is about $500 and is for 18F's only. You get to pay again to get another compiler for 16F's. PICC is around $1000 for a full license, I think for only one family (16F or 18F). I could be mistaken about that, but still it's a lot of bucks if you're a hobbiest.
__________________
=========================
Futz's Microcontrollers & Robotics
=========================
futz is offline  
Old 6th January 2009, 03:21 AM   #3
Default

Quote:
Originally Posted by futz View Post
Grab the BoostC demo from SourceBoost. It's an excellent PIC compiler. The demo works on all supported PICs. It's only memory and code size limited. When your programs get too big for the demo you can buy a full license for about $75. That gets you both 16F and 18F compilers, as well as support for some 12F's. A ton of bang for the buck!

You can't beat that deal anywhere. Microchip's C18 is about $500 and is for 18F's only. You get to pay again to get another compiler for 16F's. PICC is around $1000 for a full license, I think for only one family (16F or 18F). I could be mistaken about that, but still it's a lot of bucks if you're a hobbiest.
In terms of support and noob-friendliness - i.e tutorials, etc, does BoostC stand out from the rest?

And im assuming that all C compilers syntax's are very similar to each other?
usif is offline  
Old 6th January 2009, 03:57 AM   #4
Default

Quote:
Originally Posted by usif View Post
In terms of support and noob-friendliness - i.e tutorials, etc, does BoostC stand out from the rest?
There's lots of BoostC users here at Electro Tech. I don't know of any tutorials targetted exactly at BoostC, but aside from compiler specific stuff it's an ANSI C compiler. It works as you would expect one to work. Tutorials for other compilers, except for minor syntax differences (not in C, but in register/bit access), should work fine.

Quote:
And I'm assuming that all C compilers syntax's are very similar to each other?
Well, C is C, and has been "forever". The equates in the include files and the libraries supplied are mostly what makes compilers different from each other. And libs are pretty standardized too.

The way you access bits and registers is defined in the include files (can be changed if you can't live with it). This is where some of the biggest differences in PIC compiler syntax comes in. BoostC is one of the easiest to live with, IMHO. It is a little different from the others, but not weird or anything - they're all a bit different from each other. It's easy to port code from other compilers. The changes aren't hard to make.

If you've never programmed in C before you might be wise to learn it on a PC first, at least till you're a bit comfortable with it. There's bazillions of tutorials and on a PC you have easy pre-configured stdin and stdout (the keyboard and monitor) to learn with, whereas on a PIC you have to write code to do your own input and output. It can be quite a hump to get over when you're brand new to the language. If you don't yet know how to program in C, how do you write I/O code to learn the basics? On the other hand, blinking a LED in C is trivially easy.
__________________
=========================
Futz's Microcontrollers & Robotics
=========================

Last edited by futz; 6th January 2009 at 04:09 AM.
futz is offline  
Old 6th January 2009, 09:16 AM   #5
Default

Quote:
Originally Posted by futz View Post
Well, C is C, and has been "forever". The equates in the include files and the libraries supplied are mostly what makes compilers different from each other. And libs are pretty standardized too.
People always claim that, yet it's not simple to transfer code from one compiler to another - not even on a PC. And on PIC's compilers are wildly different - C seems no better than BASIC or Pascal for moving between compilers.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 6th January 2009, 09:34 AM   #6
Default

Hi I also like to join to this thread regarding compilers.I have the same issue like OP.

I have CCS C full,BoostC trial,C18 Student versions.

I still wondering what to start with.Futz gave me some nice info about compilers.

I already completed studying a CCS book by (Nigel Gardener) & got the basics of C.
After finding on the net very few working with this compiler (CCS C) & heard there are some bugs on that.

My mind is always focusing to change the current compiler.More focusing on 18F series for future designs.

Any ideas on what compiler to use?
__________________
Gayan

My Website
http://gsmicro.blogspot.com/

Last edited by Gayan Soyza; 6th January 2009 at 09:39 AM.
Gayan Soyza is offline  
Old 6th January 2009, 09:38 AM   #7
Default

Gayan,

What target hardware do you have available.

Mike.
Pommie is online now  
Old 6th January 2009, 09:47 AM   #8
Default

Quote:
Originally Posted by Pommie View Post
Gayan,

What target hardware do you have available.

Mike.
Hi Mike I have

Programmers

*Junebug
*ICD2
*Modified JDM (for 18F)

Target boards

Target boards I have made by myself with the ICSP connector & header pins on all I/O pins on PIC 18F1320,18F452 etc..........

At anytime I can quickly build any target board to check the code is working in real life
__________________
Gayan

My Website
http://gsmicro.blogspot.com/
Gayan Soyza is offline  
Old 6th January 2009, 09:54 AM   #9
Default

As you have a Junebug then I'd start with C18. There's lots of example code on here. Why not start by controlling a servo clicky.

Mike.
Pommie is online now  
Old 6th January 2009, 10:11 AM   #10
Default

Quote:
Originally Posted by Pommie View Post
As you have a Junebug then I'd start with C18. There's lots of example code on here. Why not start by controlling a servo clicky.

Mike.
Thats what I had in mind I may use C18.Thanks for your help.
__________________
Gayan

My Website
http://gsmicro.blogspot.com/
Gayan Soyza is offline  
Old 6th January 2009, 10:57 PM   #11
Default

My vote also goes to my favorite - Sourceboost. In fact it comes with Basic, C and C++ support. It has very nice and simple to use IDE and simulation capabilites. Free version is 2kB and 2 ram banks limited but it takes a while to fill that. (Full license cost is very reasonable as mentioned above).

Btw, Sourceboost developers have recently announced working on compiler for dsPIC/PIC24/PIC32 series
__________________
"The only thing worse than getting an error message is not getting an error message." - Allen Downey
qratman is offline  
Old 7th January 2009, 03:24 AM   #12
Default

I gave BoostC a try last night, and my LED's have been flashing

What I didnt understand, is why I had to turn my porta into digital mode so I can get them on?
usif is offline  
Old 7th January 2009, 03:36 AM   #13
Default

Quote:
Originally Posted by usif View Post
I gave BoostC a try last night, and my LED's have been flashing

What I didnt understand, is why I had to turn my porta into digital mode so I can get them on?
Look at Page 41 of the datasheet where it says:
Quote:
Note: On a Power-on Reset, these pins are configured as analog inputs and read as ‘0’.
__________________
=========================
Futz's Microcontrollers & Robotics
=========================
futz is offline  
Old 7th January 2009, 04:41 AM   #14
Default

Quote:
Originally Posted by usif View Post
I gave BoostC a try last night, and my LED's have been flashing

What I didnt understand, is why I had to turn my porta into digital mode so I can get them on?
You don't, you can light LEDs with the pins set to analogue. What you can't do is bit operations on the port as analogue pins always read as zero.

So,
Code:
	bsf	PORTA,1
	bsf	PORTA,2
will result in bit one being zero because the next bsf will read a zero from bit 1 and write it back.

It's also very confusing.

Mike.
Pommie is online now  
Old 8th January 2009, 11:06 AM   #15
Default

I'm having trouble starting. Can anyone confirm that I should get a good C book, learn the basics and then apply it to the PIC's?
usif is offline  
Reply

Tags
hitech

Thread Tools
Display Modes


Similar
Title Starter Forum Replies Latest
Using 'continue' in Hi-Tech C MrNobody Micro Controllers 13 1st September 2008 12:14 AM
New robotics tech mous3 Robotics Chat 0 31st July 2008 03:07 AM
Greetings Electro-tech. xl5 Chit-Chat 4 29th December 2007 07:06 PM
Getting started with Hi-tech C.. MrNobody Micro Controllers 3 2nd August 2007 03:28 AM
mobile tech jeevan772006 Electronic Projects Design/Ideas/Reviews 0 1st September 2005 07:19 AM



All times are GMT. The time now is 06:34 AM.


Electronic Circuits  |  Learning Electronics
eXTReMe Tracker