Claim Your: Useful
"Arduino Software Guide"
Re-compilation is only needed to examine (see the .lst file produced to see the assembler code along with the C source code) or change the code as the ZIP files found on this site already contain the hex file for programming the chip.
MikroC V6.0.4 main screen
MikroC has quite a few controls but for this compiler tutorial you only need to consider a few of them.
Download the ZIP file and extract its contents to your
directory e.g. create the directory c:\Projects\a-project\
In this directory you will have files with extensions .c, .h ,.hex ,.mcppi - the .mcppi file is the main project file that you select from mikroC using the Open project button:
Opening a project file.
Navigate to your stored files and select the .mcppi extension to load the project.
If you want to change the project settings e.g. the chip type, oscillator frequency or other chip parameters then hit the 'Edit Project' button :
Next hit the compile button:
When the MikroC PIC C Compiler has completed its compilation the messages box at the bottom will show the compilation status (any errors in compilation are shown in red).
When the compile finishes (and if successful) you should see something similar to the following:
Now there should now be a lot more files in the original directory and the hex file will have been updated.
MikroC is unusual in that it has a set of built-in libraries that you can use for many different peripherals. I tend to create the code myself as I like to know exactly how something works and this also has the advantage that:
However, if you are pushed for time, then the built in libraries provide a convenient way of speeding up the design process and include code support many different devices/concepts.
To find the libraries Use the Menu:
Examples of available libraries:
Note: Double click the library to bring up help for that library component.
Warning: If you use the library you will be locked into using the tool and it will be difficult to change over to a different pic c compiler should you wish to do so. Also, sometimes MikroC likes to change things around and that breaks your existing code examples from this site are that they re-labelled UART functions as USART1 and USART2 and they don't provide a simple definition that would have stopped code breaking - you have to go away and figure it out which is a pain.
Library code is ready to use to operate multiple hardware devices and some of these are complex such as compact flash, ethernet, CAN interface and there are specific device supported ranging from port expanders to graphical LCDs. Note however you do not get access to the source code for these libraries.
Since MikroC uses standard libraries the functions contained in ANSI libraries are the same so the library viewer lets you easily see what functions are defined in which libraries - otherwise if you are not too familiar with ANSIC you have to go and look up what function is contained in which library so you can put the correct include header into the c source.
For instance where is the function memcpy defined? -its easy to look up = string.h
The main reason for bringing up the subject of libraries is that for a normal project as some point you will be asked if you want to include all libraries (slows compilation a bit - I think). If you do not then you need to go in a specifically click checkboxes in the library manager to include standard libraries.
This is totally non-standard behaviour - other compilers will include the libraries asked for in the source file - especially standard ones such as stdlib.h and string.h.
If you don't click the checkboxes you will get errors in the message output and the message will not indicate why it is there.
Example: If you turn off the C_Stdlib and compile the 7segment counter timer code the following error appears:
"Line 0 ErrNo.=360 Unresolved extern 'ldiv'"
The reason is that somwhere in the code a long divide operation is occuring and stdlib happens to be the place that this (assembler) library function is located - but the compiler wont' tell you that so you have to go through your code and check all libraries that are "included" by your code are matched by the checkboxes in the library manager. Some errors are more obvious e.g. LCD_Init and not checking the lcd library.
The other slightly wrong thing with libraries is that you can use them without declaring the include directive e.g. for the LCD frequency counter code it does not have the following line
Also the above line causes a warning anyway!
There are two issues with this:
When you look at the code alone, you can not tell that it relies on a library that is built into the MikroC compiler.
A library is included only by the external environment i.e. by the MikroC compiler - that is Ok if you only ever use that environment but not if you want to move to a different compiler. Also it is just non-standard bad practice and allows you to get away with code that should have an include directive in it.
Jump from PIC C
Best-Microcontroller-Projects Home Page
Nov 20, 14 04:58 AM
How to drive a dot matrix LED display. This project shows you how to drive one with 64 LEDs (8 rows by 8 columns) or less e.g. 35 LEDs (7 rows by 5 columns).
Nov 20, 14 04:55 AM
USB serial port: How to setup an RS232 serial link when you only have a USB port. There are two types of digital interfaces to consider...
Nov 06, 14 05:22 PM
Liquid level control using thermistors : How to use thermistors to detect and control the level of a liquid.
Sign up for MicroZine:
''The'' Microcontroller Newsletter
Enter your first Name and primary email address in the form below:
And receive absolutely FREE a full project for:
"Measuring Analogue Voltages
Without An ADC"
(Using only one pin).
Get It Right Now
Remember this is a project with full description and fully debugged C Source code - and it's not available from the main website.
You can only get it through this newsletter.
To get exclusive access Enter your first name Name and primary email address Now in the form above.:
But wait !
You'll receive more
free and exclusive reports as well as site information and site product updates.
Scroll up to the form above and sign up NOW. Don't forget it's FREE and if you don't like it you can unsubscribe at any time.
Click Here Now to use the form above to get your Valuable information absolutely free.