Introdução ao MikroC

Introduction to MikroC

Before starting with a microcontroller , certain factors like cost, availability, etc. must be considered. One of the most important criteria for choosing a controller is the availability of its development tools such as assembler, compiler, debugger, simulator, etc. Several companies have developed different types of compilers and simulators that are easily available for use.

Development cycle:
To develop or test an embedded system application, a specific development cycle consisting of several steps is followed. An Integrated Development Environment (IDE) allows the implementation of all these stages of a development cycle.
Typically, a development cycle has the following steps:
The. The code is written/edited in an Editor program.
B. Compiler/Assembler/Linker programs generate relevant support files like .hex, .obj etc.
w. The code is loaded into the Simulator/Debugger program.
d. The code is analyzed by Simulation or Debugging.
If an error occurs, the code is re-edited and the entire cycle is repeated.
Imagem mostrando o Ciclo de Desenvolvimento de Software
Figure 1: Image showing the Software Development Cycle
Different IDE Tools:
There are several IDE tools provided by different companies for the PIC18 series of microcontrollers. Microchip has developed MPLAB IDE tools for each PIC Microcontroller series. This IDE suite provides the following programs:
· Publisher: MPLAB Editor
· Assembler: MPASM
· Compiler: MPLAB C Compiler for PIC18 MCUs
· Linker: MPLINK
· Simulator: MPLAB SIM
· Debugger: MPLAB ICD 2/3
· Programmer: Pickit 2/3
In addition to these, the Hi-Tech C compiler, Byte Craft's MPC and CCS's PCWH are third-party compilers that can work in MPLAB IDE.
MicroElectronics has also developed an IDE for PIC Microcontroller which is named Micro C. This IDE provides C compiler, software simulator and mikroICD debugger. Along with this package mikroElektronika provides different tools like LCD bitmap graphic editor, LCD custom character editor, USART terminal etc. MikroC IDE also provides built-in custom libraries not only for PIC internal peripherals such as ADC , USART , SPI, I2C etc. but also for external peripherals such as LCD, 7 segments etc.
Note that a dedicated USB HID terminal and HID class library are also provided with this package for USB communication with PIC microcontrollers that support USB protocols like PIC18F4550 etc.

How to work with MicroC

How to work with MikroC:
Following are the steps to start a project with Mikro C IDE.
Step 1 :
To start a new project, open mikroC.exe and go to Project -> New Project. The following window will appear.
Captura de tela da janela Novo Projeto no MikroC

Figure 2: Screenshot of the New Project window in MikroC

The project name, its location, and clock frequency are provided in the New Project window. Device configuration settings are also selected at the beginning of the project. The PIC18F4550 includes several features such as internal oscillator, watchdog timer, etc. to maximize reliability and minimize cost by eliminating external components. These features are configured through configuration bits.
Step 2:
After configuring the initial settings, code can be written in the Code Editor.
The code is written in the Code Window and built by pressing Ctrl+F9 or Project -> Build. The error(s), if any, will be displayed in the message window at the bottom.
Captura de tela mostrando partes da janela principal do MikroC IDE

Figure 3: Screenshot showing parts of the main MikroC IDE window

Continuous

Step 3: Debugging
Code debugging can be started with F9 or Run -> Start debugging. The Watch window can be opened from View -> Debug Window -> View Watch. A clock can be added via the Add option in the observation window. Step-by-step debugging can be done by pressing F7 and the corresponding result will be displayed.
Captura de tela das opções de depuração no MikroC IDE

Figure 4: Screenshot of debug options in MikroC IDE

Step 4: When the code is built, a .hex file is generated in the directory location selected at the beginning of the project. The generated .hex file can be written to the PIC Microcontroller using JDM or PICkit burn type or any other similar burners/programmers.

Back to blog

Leave a comment

Please note, comments need to be approved before they are published.