So you attempted to use the Hitech C Compiler through the standard MPLab installation?
As other people have mentioned, there are various programs that you can use, such as GCBasic as NickelFlipper posted, and Oshonsoft (not free, trial version) as Ian has mentioned.
In terms of programming BASIC is the beginners language, however, I would say if you can, write your code in C!
With regards to C you have to remember that everything that is a command MUST end in a semi colon ( ; ), apart from statements that "jump".
For example:
Code:
void main(void)
{
int i = 0;
for(i = 0; i < 500; i++)
{
__delay_ms(1);
}
}
void main(void)
This is what is commonly referred to as the "entry point" it is the "main" point in which your application will execute, and will always be called "main".
"void" is nothing, quite literally, when you void something you make it non existant, so, what this is doing is saying that the function "main" will not return anythiing, which is the "void" before the text "main". Nor will it expect any parameters to be passed to it, which is the "void" inside the brackets after "main".
The curly brackets "{}" symbolise the start and end of a function, this is present on every function, and any chunk of code that needs to be executed before comming out, like the for loop. You will notice that there is no semicolon ( ; ) at the end of this line of code.
int i = 0;
Here you will notice the semi colon, basically this line defines a variable with the name "i" of type integer, which is a whole number, we are also initialising it to "0", which just means it will start with a value of "0". If we put "i = 1" then the variable "i" will be initialised with the value of "1".
for(i = 0; i < 500; i++)
This is called a "for loop", quite simple, you will notice that the parameters of "for" is seperated by 3 semicolons, but does not end in a semi colon, the code inside of the for loop is also contained within curly brackets.
The first instruction of the "for loop" is to initialise "i" to 0, the next parameter makes the "for" loop check if it is below 500, if it is below 500 then carry on and do what is inside the "for loop", the last paramter increments i, we could of used i=i+1, but in C/C++ they give us special operators to do things more simplistically, such as the ++ operator, we can also use -- to decrement the variable by 1.
So, the 3 parameters are start condition (int i = 0
, the clause ( i < 500
and finally the end condition (i++).
This can be written as:
i equals 0
(loop) if i is less than 500 do the following
delay by 1 millisecond
if i is not less than 500 then exit other wise increment i and go back to loop.
So, you can see from the above that the code will simply call what is inside the for loop "n" number of times, "n" in this case being 500 (0 - 499) = 500 times.
Another common mistake is that "i<500" means 499, not 500. If "i" hits 500 then it will exit the loop but because we start at "0" 0 to 499 = 500 times. (Hope that makes sense!).
__delay_ms(1);
Observe the semicolon at the end of this statement.
This is a built in routine specific to HITECH C that will delay by 1 millisecond, it wont run as is, it needs a few variables set up to define the clock speed (the speed at which the instructions are run at).
When dealing with PIC's in particular, you will note that the smaller 8 pin variants use what is called GPIO, General Purpose Input / Output. This is addressed as a single "port" and individual bits, so GPIO.0, GPIO.1, GPIO.2 etc.
When you move on to the bigger chips this will change to actual port "names", this will be in the convention of "RA, RB, RC, RD, RE" etc, it's not a massive change, just make sure that you dont try and address the bigger chips with "GPIO" as it wont work! you can address "RA.0" for example instead.
For your LED project, as blinky LED's are a hardware reference to a software's "hello world", I assume you have the correct electronics knowledge to interface the LED's with the pins?
Hope this helps and gives you a basic insight into C and PIC programming.
Wilksey