Introduction
Welcome to the MikroElektronika Compiler Quick Start Guide.
The goal of this page is to help you make your first project in the compiler and understand how the IDE operates.
Our examples will help you along the way. We will take you through all the steps, one by one, and show you how simple and easy it is to use any of our compilers.
We have seven different architectures (PIC, dsPIC, PIC32, ARM, AVR, 8051, and FT90x) on three programming languages: C, Basic and Pascal.
Quick start guide structure
The Quick Start Guide is composed of three main sections:
Compiler Help file
All our compilers come with a comprehensive Help file and many coding examples that can help you get started and get to know the compiler.
You can also easily access them by clicking on the Open Examples folder.
Free software upgrades
The compiler license offers free upgrades. The only time you'll pay is when you buy the compiler.
All you need to do is check if there is a new update. You can do this by clicking on the Help -> Check for Updates.
The compiler license is valid until the end of the product life.
Free support
We offer free support, for all our products. There is a live chat option if you want to communicate with our support team and a Helpdesk where you can submit a ticket if you are having any trouble or need more information.
Visual TFT
Human-machine interface technology is used in almost every industry in the world today, and more and more households.
It certainly makes the interaction with any machine easier. We have decided to make it easier for you to create graphic interfaces — Visual TFT is an application for developing graphical user interfaces for TFT displays.
The code generated by this software is compatible with all our compilers.
You can download and try our free demo version of the Visual TFT software on our web page. The demo version of the software allows you to freely design your GUI with as many components as you want, but code generation is limited to a maximum of seven components.
Since our PIC (from v.7.0.0), dsPIC (from v. 7.0.0) and FT90x (from v.2.0.0) compilers are merged with the Visual TFT, there is no need to download Visual TFT separately.
You can easily start a project in your desired compiler and by pressing F12 to switch between the compiler mode and Visual TFT mode.
Introduction | IDE | Creating Your First Project | Examples
IDE
An IDE or an Integrated Development Environment is a software application in which all the developing is done.
Each of our IDEs is dedicated to one programming language: C, Basic and Pascal.
Our IDE is intuitive and easy to use and has a Windows based point-and-click environment.
With a detailed help file, developing applications and working on projects is simple and straightforward.
The "Introduction" chapter (Help file) gives you an excellent overview of the compiler you are using, and we suggest you read it before you start your first project.
In case this is your first encounter with one of our compilers the Help file has a "Specifics" chapter that will give you a better understanding of its capabilities.
Project organisation
The compiler organizes applications into projects consisting of a single project file and one or more source files. You will be able to manage several projects at the same time.
The picture below shows the default layout of the compiler IDE. You can always customize the layout in a way that suits your needs.
Hide the features that are of no use to you at the moment, and add the ones that you require.
1. Main Toolbar
By the default layout, the first section of the Main Toolbar is dedicated to the creating, editing and deleting of the project. The second section is for adding files.
The third one is concerned with saving options and printing. The fourth one is for building your project and starting the programmer.
The fifth one is for managing the USART terminal, EEPROM editor tool, and other options. The sixth one is for layout features.
The seventh one is for assembly, listings, and statistics. The eight one is for the Help file and the examples folder.
The ninth and last section is History, for retracing your steps in the Code Editor.
2. Code Explorer
The Code Explorer is located at the top left corner of the screen. You can see a list of functions, web links, and active comments in the project you opened.
3. Project Settings
In this section, you have the name of the device you are using, the frequency of the MCU clock and the Build/Debugger types.
The frequency of the MCU clock determines the speed of the microcontroller.
4. Messages
In case that errors were encountered during compiling, the compiler will report them in the Message box, and won’t generate a hex file.
The compiler also reports warnings, but these do not affect the output; only errors can interfere with the generation of a hex.
5. Quick Convertor
Makes translating from one form to another easy. For example from a decimal number to binary number.
6. Code editor
The Code Editor features adjustable Syntax Highlighting, Code Folding, Code Assistant, Parameters Assistant, Auto Correct for common typos
and Code Templates (Auto Complete).
7. Image Preview
The image Preview box is located in the top right corner of the screen, by default. It shows the images of active links you have added in the comments section of the code.
8. Project Manager
The Project Manager is an IDE feature which allows you to manage multiple projects. It shows source and header files in each project.
Several projects can be open at the same time, but only one of them may be active at one time.
To set a project in an active mode you need to double click on the desired project in the Project Manager.
9. Library Manager
The Library Manager allows you to work with the libraries in a simple and easy way. The Library Manager window lists all libraries.
The desirable library is added to the project by selecting the check box next to the library name.
In order to have all library functions available, simply press the Check All button, and that’s it.
Visual TFT IDE
Visual TFT supports a total of 17 TFT controllers. We have designed the IDE so that you can create your visual projects with ease.
Your projects can be organized into multiple screens or you can keep everything on a single screen.
Each screen can be moved and changed to your liking. Change the color of the background or reorganize the components.
One screen can contain one application or one functionality of the application.
The Components palette lets you choose between different fonts and labels, gradient and standard fill for boxes, visibility, border color and many more options.
You can use multiple screens and edit the components.
The Layer box in the IDE lets you specify layer position and visibility, and to make things even better you can lock certain layers.
Tools
We are here to make your work easier and more enjoyable. With this set of built-in tools your just a few clicks away from making a great project.
- The mE Programmer— Runs the MikroElektronika programmer.
- Package Manager— The Package Manager is a free software which enables you to easily integrate your libraries into all MikroElektronika Compilers.
It creates a redistributable archive which can be installed on other computers. Along with libraries, packages can contain other valuable information such as:
Definition Files, Help Files, Dependencies, and Examples. Using this tool you can start distributing your own libraries much faster and easier. - MikroProg Power Options— Sets the target circuit power options (in voltage).
- Ascii Chart— opens a window containing the Ascii chart. The Ascii code is a numerical representation of characters we use every day, like 4, %, H, or @., because computers can only understand numbers.
This tool is very useful when working with an LCD display. - EEPROM Editor— The EEPROM Editor is used for manipulating MCU's EEPROM memory. You can choose the format (Dec, Hex, Float, String) in the bottom left corner of the screen.
The default size is measured in bytes. If you want to modify individual locations, you will need to enter a new value in the .hex format for the appropriate address. - GLCD Bitmap Editor— This editor generates code equivalent of a BMP image, which you can then see on the LCD display. The “Load BMP” button is located in the top left corner of the screen.
Once you choose the image you want from the folder, you will be able to see both the preview of how it will look on the screen and the code in the “Generated code” box below. - HID Terminal— HID communication terminal for USB communication.
- LCD Custom Character— This tool allows you to design your own custom character and display them on a LCD screen. All you need to do is draw the character, and the tool will translate it into code.
Once you are satisfied with how the character looks like click on the “Generate Code” button in the bottom of the screen. - mikroBootloader— This feature allows a small bootloader program to receive and write new firmware into memory.
In its most simple form, the bootloader starts the user code running, unless it finds that new firmware should be downloaded.
If there is new firmware to be downloaded, it gets the data and writes it into program memory. - Seven Segment Editor— The Seven Segment Editor is a convenient visual panel which returns decimal/hex value for any viable combination you would like to display on seven segment display.
Click on the parts of seven segment image to get the requested value in the edit boxes. - UDP Terminal— UDP communication terminal allows easy sending and receiving of USB packages.
- USART Terminal— the compiler includes the USART terminal for RS232 communication. The USART Terminal window contains options for serial communication configuration and display of sent/receive data.
- USB HID Bootloader— A tool for uploading the hex code on devices that have a USB HID.
Introduction | IDE | Creating Your First Project | Examples
Creating Your First Project
In this part of the guide, we will show you how to create your first project in the compiler, compile it and then test the results.
When you open the compiler select the New Project option from the Project menu.
The New Project Wizard window will appear and easily guide you through the process of creating your project.
Step 1 — Visual TFT or Standard Project
A new window will appear asking you to choose whether you will be creating a Visual TFT project or a Standard project if you are using one of the followings
compilers: PIC, dsPIC or FT90x.
Step 2 — Project Settings
The first thing we have to do is specify the general project information. Select the target microcontroller, it's operating frequency and the name of your project.
The compiler will adjust the internal settings based on the information you have entered. The default configuration is suggested for you at the beginning.
If you don't want to use the suggested path for storing your new project, you can change the destination folder. In order to do that please follow these instructions:
- Click on the Browse button on the Project Settings window to open the Browse for Folder window.
- Select the desired folder to be the destination path for storing your new project files.
- Click the OK button to confirm your selection and apply the new path.
Now we can do the rest of the project settings:
- Enter the name of the project, depending on the type of project you will be working on. For example, it could be "LEDblinking".
- Set the Device clock. Clock speed depends on your target hardware. Make sure you specify the exact clock that the microcontroller is operating on.
- Click the OK button.
Step 3 — Add files
This step allows you to include additional files that you need in your project: some headers or source files that you already wrote, and that you might need in further development
. If you are going to add files, choose the folder they are located in and click the Next button. You can also add files later, by opening the Project Manager.
Step 4 — Include Libraries
This step allows you to quickly set whether you want to include all libraries in your project, or not.
Even if all libraries are included, they will not consume any memory unless
they are explicitly used from within your code. The main advantage of including all libraries is that you will have over 500 functions available to use
in your code right away. These functions will be visible from Code Assistant [CTRL+Space]. The default configuration is the "Include All" option.
When you are done click on the Finish button.
New Project created
Now that you have successfully created a new project you will see that the source file is called the way you have named the project. For example "LEDblinking.mpas".
In case you want to see code examples for LED blinking, for each of our compilers, click on the following link: Examples
Helpful shortcuts
You can use keyboard shortcuts for repetitive tasks:
- Ctrl+Alt+G to Generate Code
- Ctrl + Shift + S to Save All files
- Ctrl + F9 to build generated code
- Ctrl + F11 build generated code and program to MCU
In case you want to see the full list of shortcuts you can find them in the Help file.
Creating your first project in the Visual TFT
Visual TFT software is a standalone application used for rapid development of graphical user interfaces for TFT displays.
The software generates code compatible with MikroElektronika compilers.
The visual/design process for creating new projects is the same for every compiler and on every architecture.
Visual TFT IDE
These are the most important sections in the Visual TFT IDE for you to learn about before you begin:
- Main Toolbar — This section features buttons with icons that depict each button’s function. Here you can open, save or export projects, add or delete screens,
generate code, start the target compiler, invoke Project Settings window and much more. - Object Inspector — This window can be used to change properties of each screen and component. Change names, captions, fonts, sizes, position,
add events to components and define their behavior. - Welcome Screen Buttons — The New Project option will take you through the process of creating your new project. The second one, Open Project, allows you to open existing
projects, and the third one, Open Examples, lets you choose from the Examples folder. - Components Palette — Collection of components which can be placed on screens. There are simple, basic components, such as a box, circle, line, image and label,
and as well as more complex components such as buttons, checkbox and progress bar. - Layers Window — Like in any other vector graphic editor, you can group components on layers while designing, and quickly navigate through different layers using this
window.
In this tutorial, we will show you how to develop a simple application with two screens. Each screen will carry a button which can be used to switch to the other screen.
You will be designing a graphical interface in Visual TFT software.
New Project Wizard
Step 1 — Create the project in the wizard
Let’s start by creating a new project. On the Start page, click the New Project button. A new window will appear asking you to choose whether you will be creating
a Visual TFT project or a Standard project. Choose the Visual TFT project and click the Next button at the bottom of the screen.
The first thing we need to do is to specify the new project’s name and destination folder. Give a name to your project, “MyFirstProject”, for example.
Click the browse button if you want to edit the destination of the project. After you are done, click the Next button to continue with the creation of your project.
In the next window, you can add files to your project. Choose the files on your computer that you want to add and click the "Add" button.
After you have added all the files you wanted you can click the "Next" button and proceed to the last step in the New Project Wizard.
This step allows you to include additional files that you might need in your project - some headers or source files that you already wrote, and that you might
need in future development.
If you are a beginner we suggest that you choose the "Include All (Default)" option.
This step allows you to quickly set whether you want to include all libraries in your project, or not.
Even if you do include all libraries, they will not consume all memory unless they are explicitly used from within your code.
The main advantage of including all libraries is that you will have over 500 functions available for use in your code right away.
All the functions will be visible from the Code Assistant [CTRL+Space].
Step 2 — Design the user interface
So far, we have successfully created a blank new project for EasyPIC Fusion v7 development board. Now, we are going to design the user interface.
We are going to add one button and one text section. In the tools section, in the upper right corner of the IDE, you have a list buttons you can add.
Choose the one you like and drag it to the display screen in the middle of the IDE.
After you click on the button, you can change its color, size, text and font in the Components section - Properties tab, in the bottom left corner of the IDE.
You can change the features of the screen in the upper lest corner of the IDE.
The Events tab, next to the Properties tab in the Components section defines what a button does.
Step 3 — Building the code in the compiler
Once you are satisfied with how your buttons, text, and display look click on "Build" (CTRL+F9) in the drop-down menu.
If an error happens you will be notified in the Message section of the compiler.
You can switch between the compiler and Visual TFT mode by pressing F12 on your keyboard.
Introduction | IDE | Creating Your First Project | Examples
Examples
To get you acquainted with our compilers we have prepared code examples for LED blinking for each of the 21 compilers we have on offer.
We suggest that you read the documentation on the MCU you are using before you start programming.
LED blinking is the simplest example, and once you understand how it works you will be able to move on to more complex examples.
LEDs can be used for visual indication of the logic state on PORT pins. An active LED indicates that a logic high (1) is present on the pin. In order to enable PORT LEDs, it is necessary to enable the corresponding switches on the board you are using.
LED blinking for mikroC
mikroC PRO for PIC
For this example we have used the EasyPIC7 development board
- MCU: PIC18F45K22 from Microchip.
- Oscillator: HS-PLL 32.0000 MHz, 8.0000 MHz Crystal.
- Board settings: Turn ON the PORT LEDs at SW3.
void main() { TRISA = 0; // set direction to be output TRISB = 0; // set direction to be output TRISC = 0; // set direction to be output TRISD = 0; // set direction to be output TRISE = 0; // set direction to be output do { LATA = 0x00; // Turn OFF LEDs on PORTA LATB = 0x00; // Turn OFF LEDs on PORTB LATC = 0x00; // Turn OFF LEDs on PORTC LATD = 0x00; // Turn OFF LEDs on PORTD LATE = 0x00; // Turn OFF LEDs on PORTE Delay_ms(1000); // 1 second delay LATA = 0xFF; // Turn ON LEDs on PORTA LATB = 0xFF; // Turn ON LEDs on PORTB LATC = 0xFF; // Turn ON LEDs on PORTC LATD = 0xFF; // Turn ON LEDs on PORTD LATE = 0xFF; // Turn ON LEDs on PORTE Delay_ms(1000); // 1 second delay } while(1); // Endless loop }
mikroC PRO for dsPIC
For this example we have used the EasyPIC7 development board
- MCU: dsPIC30F4013 from Microchip;
- Oscillator: XT-PLL8, 80.000MHz.
void main() { TRISA = 0; // set direction to be output TRISB = 0; // set direction to be output TRISC = 0; // set direction to be output TRISD = 0; // set direction to be output TRISE = 0; // set direction to be output do { LATA = 0x00; // Turn OFF LEDs on PORTA LATB = 0x00; // Turn OFF LEDs on PORTB LATC = 0x00; // Turn OFF LEDs on PORTC LATD = 0x00; // Turn OFF LEDs on PORTD LATE = 0x00; // Turn OFF LEDs on PORTE Delay_ms(1000); // 1 second delay LATA = 0xFF; // Turn ON LEDs on PORTA LATB = 0xFF; // Turn ON LEDs on PORTB LATC = 0xFF; // Turn ON LEDs on PORTC LATD = 0xFF; // Turn ON LEDs on PORTD LATE = 0xFF; // Turn ON LEDs on PORTE Delay_ms(1000); // 1 second delay } while(1); // Endless loop }
mikroC PRO for PIC32
For this example we have used the EasyPIC Fusion v7 development board.
- MCU: P32MX795F512L from Microchip;
- Oscillator: XT-PLL, 80.0000MHz.
- Board settings: Turn ON PORTA, B, C, D, F & G LEDS at SW15.
void main() { AD1PCFG = 0xFFFF; // Configure AN pins as digital I/O JTAGEN_bit = 0; // Disable JTAG TRISA = 0; // Initialize PORTA as output TRISB = 0; // Initialize PORTB as output TRISC = 0; // Initialize PORTC as output TRISD = 0; // Initialize PORTD as output TRISF = 0; // Initialize PORTE as output TRISG = 0; // Initialize PORTG as output LATA = 0; // Set PORTA to zero LATB = 0; // Set PORTB to zero LATC = 0; // Set PORTC to zero LATD = 0; // Set PORTD to zero LATF = 0; // Set PORTE to zero LATG = 0; // Set PORTG to zero while(1) { LATA = ~PORTA; // Invert PORTA value LATB = ~PORTB; // Invert PORTB value LATC = ~PORTC; // Invert PORTC value LATD = ~PORTD; // Invert PORTD value LATF = ~PORTF; // Invert PORTE value LATG = ~PORTG; // Invert PORTG value Delay_ms(1000); } }
mikroC PRO for ARM
For this example we have used the EasyMx v7 for STM(R) ARM(R) development board.
- MCU: STM32F107VC;
- Oscillator: HSE-PLL, 72.000MHz.
- Board settings: Turn ON PORTA, PORTB, PORTC, PORTD, PORTE at SW15.
void main() { GPIO_Digital_Output(&GPIOA_BASE, _GPIO_PINMASK_ALL); // Set PORTA as digital output GPIO_Digital_Output(&GPIOB_BASE, _GPIO_PINMASK_ALL); // Set PORTB as digital output GPIO_Digital_Output(&GPIOC_BASE, _GPIO_PINMASK_ALL); // Set PORTC as digital output GPIO_Digital_Output(&GPIOD_BASE, _GPIO_PINMASK_ALL); // Set PORTD as digital output GPIO_Digital_Output(&GPIOE_BASE, _GPIO_PINMASK_ALL); // Set PORTE as digital output GPIOA_ODR = 0; GPIOB_ODR = 0; GPIOC_ODR = 0; GPIOD_ODR = 0; GPIOE_ODR = 0; while(1) { GPIOA_ODR = ~GPIOA_ODR; // Toggle PORTA GPIOB_ODR = ~GPIOB_ODR; // Toggle PORTB GPIOC_ODR = ~GPIOC_ODR; // Toggle PORTC GPIOD_ODR = ~GPIOD_ODR; // Toggle PORTD GPIOE_ODR = ~GPIOE_ODR; // Toggle PORTE Delay_ms(1000); } }
mikroC PRO for AVR
For this example we have used the EasyAVR v7 development board.
- MCU: ATMEGA32;
- Oscillator: External Clock 08.0000 MHz.
- Board settings: Make sure you turn ON the PORTA, PORTB, PORTC and PORTD LEDs (SW10.5, SW10.6, SW10.7 and SW10.8).
void main() { DDRA = 0xFF; // Set direction to be output DDRB = 0xFF; // Set direction to be output DDRC = 0xFF; // Set direction to be output DDRD = 0xFF; // Set direction to be output do { PORTA = 0x00; // Turn OFF diodes on PORTA PORTB = 0x00; // Turn OFF diodes on PORTB PORTC = 0x00; // Turn OFF diodes on PORTC PORTD = 0x00; // Turn OFF diodes on PORTD Delay_ms(1000); // 1 second delay PORTA = 0xFF; // Turn ON diodes on PORTA PORTB = 0xFF; // Turn ON diodes on PORTB PORTC = 0xFF; // Turn ON diodes on PORTC PORTD = 0xFF; // Turn ON diodes on PORTD Delay_ms(1000); // 1 second delay } while(1); // Endless loop }
mikroC PRO for 8051
For this example we have used the Easy8051v6 development board.
- MCU: AT89S8253 MCU;
- Oscillator: External Clock 10.0000 MHz.
- Board settings: Turn ON the PORT LEDs (SW7). On Easy8051v6 LEDs are activated by logical zero.
void main() { do { P0 = 0x00; // Turn ON diodes on PORT0 P1 = 0x00; // Turn ON diodes on PORT1 P2 = 0x00; // Turn ON diodes on PORT2 P3 = 0x00; // Turn ON diodes on PORT3 Delay_ms(1000); // 1 second delay P0 = 0xFF; // Turn OFF diodes on PORT0 P1 = 0xFF; // Turn OFF diodes on PORT1 P2 = 0xFF; // Turn OFF diodes on PORT2 P3 = 0xFF; // Turn OFF diodes on PORT3 Delay_ms(1000); // 1 second delay } while(1); // Endless loop }
mikroC PRO for FT90x
For this example we have used the EasyFT90x v7 development board.
- MCU: FT900;
- Oscillator: CPU at full system clock, 100.000MHz.
- Board settings: Turn ON ports GPIO 00-07, GPIO 08-15, GPIO 16-23, GPIO 24-31, GPIO 32-39, GPIO 40-47, GPIO 48-55 and GPIO 56-66 at SW8.
void main() { GPIO_Digital_Output(&GPIO_PORT_00_07, _GPIO_PINMASK_ALL); // Set GPIO 00-07 port as digital output GPIO_Digital_Output(&GPIO_PORT_08_15, _GPIO_PINMASK_ALL); // Set GPIO 08-15 port as digital output GPIO_Digital_Output(&GPIO_PORT_16_23, _GPIO_PINMASK_ALL); // Set GPIO 16-23 port as digital output GPIO_Digital_Output(&GPIO_PORT_24_31, _GPIO_PINMASK_ALL); // Set GPIO 24-31 port as digital output GPIO_Digital_Output(&GPIO_PORT_32_39, _GPIO_PINMASK_ALL); // Set GPIO 32-39 port as digital output GPIO_Digital_Output(&GPIO_PORT_40_47, _GPIO_PINMASK_ALL); // Set GPIO 40-47 port as digital output GPIO_Digital_Output(&GPIO_PORT_48_55, _GPIO_PINMASK_ALL); // Set GPIO 48-55 port as digital output GPIO_Digital_Output(&GPIO_PORT_56_63, _GPIO_PINMASK_ALL); // Set GPIO 56-63 port as digital output GPIO_Digital_Output(&GPIO_PORT_64_66, _GPIO_PINMASK_ALL); // Set GPIO 64-66 port as digital output GPIO_PORT_00_07 = 0; GPIO_PORT_08_15 = 0; GPIO_PORT_16_23 = 0; GPIO_PORT_24_31 = 0; GPIO_PORT_32_39 = 0; GPIO_PORT_40_47 = 0; GPIO_PORT_48_55 = 0; GPIO_PORT_56_63 = 0; GPIO_PORT_64_66 = 0; while (1) { GPIO_PORT_00_07 = ~GPIO_PORT_00_07; // togle PORT 00-07 GPIO_PORT_08_15 = ~GPIO_PORT_08_15; // togle PORT 08-15 GPIO_PORT_16_23 = ~GPIO_PORT_16_23; // togle PORT 16-23 GPIO_PORT_24_31 = ~GPIO_PORT_24_31; // togle PORT 24-31 GPIO_PORT_32_39 = ~GPIO_PORT_32_39; // togle PORT 32-39 GPIO_PORT_40_47 = ~GPIO_PORT_40_47; // togle PORT 40-47 GPIO_PORT_48_55 = ~GPIO_PORT_48_55; // togle PORT 48-55 GPIO_PORT_56_63 = ~GPIO_PORT_56_63; // togle PORT 56-63 GPIO_PORT_64_66 = ~GPIO_PORT_64_66; // togle PORT 64-66 Delay_ms(1000); } }
LED blinking for mikroBasic
mikroBasic PRO for PIC
For this example we have used the EasyPIC7 development board.
- MCU:PIC18F45K22 from Microchip;
- Oscillator: HS-PLL 32.0000 MHz, 8.0000 MHz Crystal.
- Board settings: Turn ON the PORT LEDs at SW3.
void main() { GPIO_Digital_Output(&GPIO_PORT_00_07, _GPIO_PINMASK_ALL); // Set GPIO 00-07 port as digital output GPIO_Digital_Output(&GPIO_PORT_08_15, _GPIO_PINMASK_ALL); // Set GPIO 08-15 port as digital output GPIO_Digital_Output(&GPIO_PORT_16_23, _GPIO_PINMASK_ALL); // Set GPIO 16-23 port as digital output GPIO_Digital_Output(&GPIO_PORT_24_31, _GPIO_PINMASK_ALL); // Set GPIO 24-31 port as digital output GPIO_Digital_Output(&GPIO_PORT_32_39, _GPIO_PINMASK_ALL); // Set GPIO 32-39 port as digital output GPIO_Digital_Output(&GPIO_PORT_40_47, _GPIO_PINMASK_ALL); // Set GPIO 40-47 port as digital output GPIO_Digital_Output(&GPIO_PORT_48_55, _GPIO_PINMASK_ALL); // Set GPIO 48-55 port as digital output GPIO_Digital_Output(&GPIO_PORT_56_63, _GPIO_PINMASK_ALL); // Set GPIO 56-63 port as digital output GPIO_Digital_Output(&GPIO_PORT_64_66, _GPIO_PINMASK_ALL); // Set GPIO 64-66 port as digital output GPIO_PORT_00_07 = 0; GPIO_PORT_08_15 = 0; GPIO_PORT_16_23 = 0; GPIO_PORT_24_31 = 0; GPIO_PORT_32_39 = 0; GPIO_PORT_40_47 = 0; GPIO_PORT_48_55 = 0; GPIO_PORT_56_63 = 0; GPIO_PORT_64_66 = 0; while (1) { GPIO_PORT_00_07 = ~GPIO_PORT_00_07; // togle PORT 00-07 GPIO_PORT_08_15 = ~GPIO_PORT_08_15; // togle PORT 08-15 GPIO_PORT_16_23 = ~GPIO_PORT_16_23; // togle PORT 16-23 GPIO_PORT_24_31 = ~GPIO_PORT_24_31; // togle PORT 24-31 GPIO_PORT_32_39 = ~GPIO_PORT_32_39; // togle PORT 32-39 GPIO_PORT_40_47 = ~GPIO_PORT_40_47; // togle PORT 40-47 GPIO_PORT_48_55 = ~GPIO_PORT_48_55; // togle PORT 48-55 GPIO_PORT_56_63 = ~GPIO_PORT_56_63; // togle PORT 56-63 GPIO_PORT_64_66 = ~GPIO_PORT_64_66; // togle PORT 64-66 Delay_ms(1000); } }
mikroBasic PRO for dsPIC
For this example we have used the EASYPIC v7 for dsPIC30 development board.
- MCU: dsPIC30F4013 from Microchip;
- Oscillator: XT-PLL8, 80.000MHz.
- Board settings: Turn ON port LEDs at SW10.
program LED_Blinking main: ADPCFG = 0xFFFF ' Configure AN pins as digital I/O TRISB = 0 ' Initialize PORTB as output TRISC = 0 ' Initialize PORTC as output TRISD = 0 ' Initialize PORTD as output TRISF = 0 ' Initialize PORTF as output LATB = 0 ' Set PORTB to zero LATC = 0 ' Set PORTC to zero LATD = 0 ' Set PORTD to zero LATF = 0 ' Set PORTF to zero while TRUE LATB = not LATB ' Invert PORTB value LATC = not LATC ' Invert PORTC value LATD = not LATD ' Invert PORTD value LATF = not LATF ' Invert PORTF value Delay_ms(1000) wend end.
mikroBasic PRO for PIC32
For this example we have used the EasyPIC Fusion v7 development board.
- MCU: P32MX795F512L from Microchip;
- Oscillator: XT-PLL, 80.0000MHz.
- Board settings: Turn ON PORTA, B, C, D, F & G LEDS at SW15.
program Led_Blinking main: AD1PCFG = 0xFFFF ' Configure AN pins as digital I/O JTAGEN_bit = 0 ' Disable JTAG TRISA = 0 ' Initialize PORTA as output TRISB = 0 ' Initialize PORTB as output TRISC = 0 ' Initialize PORTC as output TRISD = 0 ' Initialize PORTD as output TRISF = 0 ' Initialize PORTE as output TRISG = 0 ' Initialize PORTG as output LATA = 0 ' Set PORTA to zero LATB = 0 ' Set PORTB to zero LATC = 0 ' Set PORTC to zero LATD = 0 ' Set PORTD to zero LATF = 0 ' Set PORTE to zero LATG = 0 ' Set PORTG to zero while TRUE LATA = not PORTA ' Invert PORTA value LATB = not PORTB ' Invert PORTB value LATC = not PORTC ' Invert PORTC value LATD = not PORTD ' Invert PORTD value LATF = not PORTF ' Invert PORTE value LATG = not PORTG ' Invert PORTG value Delay_ms(1000) wend end.
mikroBasic PRO for ARM
For this example we have used the EasyMx v7 for STM(R) ARM(R) development board.
- MCU: STM32F107VC;
- Oscillator: HSE-PLL, 72.000MHz.
- Board settings: Turn ON PORTA, PORTB, PORTC, PORTD, PORTE at SW15.
program LedBlinking main: GPIO_Digital_Output(@GPIOA_BASE, _GPIO_PINMASK_ALL) ' Set PORTA as digital output GPIO_Digital_Output(@GPIOB_BASE, _GPIO_PINMASK_ALL) ' Set PORTB as digital output GPIO_Digital_Output(@GPIOC_BASE, _GPIO_PINMASK_ALL) ' Set PORTC as digital output GPIO_Digital_Output(@GPIOD_BASE, _GPIO_PINMASK_ALL) ' Set PORTD as digital output GPIO_Digital_Output(@GPIOE_BASE, _GPIO_PINMASK_ALL) ' Set PORTE as digital output GPIOA_ODR = 0 GPIOB_ODR = 0 GPIOC_ODR = 0 GPIOD_ODR = 0 GPIOE_ODR = 0 while TRUE GPIOA_ODR = not GPIOA_ODR ' Toggle PORTA GPIOB_ODR = not GPIOB_ODR ' Toggle PORTB GPIOC_ODR = not GPIOC_ODR ' Toggle PORTC GPIOD_ODR = not GPIOD_ODR ' Toggle PORTD GPIOE_ODR = not GPIOE_ODR ' Toggle PORTE Delay_ms(1000) wend end.
mikroBasic PRO for AVR
For this example we have used the EasyAVR v7 development board.
- MCU: ATMEGA32;
- Oscillator: External Clock 08.0000 MHz.
- Board settings: Make sure you turn ON the PORTA, PORTB, PORTC and PORTD LEDs (SW10.5, SW10.6, SW10.7 and SW10.8).
program LED_Blinking main: DDRA = 0xFF ' Set direction to be output DDRB = 0xFF ' Set direction to be output DDRC = 0xFF ' Sset direction to be output DDRD = 0xFF ' Set direction to be output while TRUE PORTA = 0x00 ' Turn ON diodes on PORTA PORTB = 0x00 ' Turn ON diodes on PORTB PORTC = 0x00 ' Turn ON diodes on PORTC PORTD = 0x00 ' Turn ON diodes on PORTD Delay_ms(1000) ' 1 second delay PORTA = 0xFF ' Turn OFF diodes on PORTA PORTB = 0xFF ' Turn OFF diodes on PORTB PORTC = 0xFF ' Turn OFF diodes on PORTC PORTD = 0xFF ' Turn OFF diodes on PORTD Delay_ms(1000) ' 1 second delay wend ' Endless loop} end.
mikroBasic PRO for 8051
For this example we have used the Easy8051v6 development board.
- MCU: AT89S8253;
- Oscillator: External Clock 10.0000 MHz;
- Board settings: Turn ON the PORT LEDs (SW7). On Easy8051v6 LEDs are activated by logical zero.
program LED_Blinking main: while TRUE P0 = 0x00 ' Turn ON diodes on PORT0 P1 = 0x00 ' Turn ON diodes on PORT1 P2 = 0x00 ' Turn ON diodes on PORT2 P3 = 0x00 ' Turn ON diodes on PORT3 Delay_ms(1000) ' 1 second delay P0 = 0xFF ' Turn OFF diodes on PORT0 P1 = 0xFF ' Turn OFF diodes on PORT1 P2 = 0xFF ' Turn OFF diodes on PORT2 P3 = 0xFF ' Turn OFF diodes on PORT3 Delay_ms(1000) ' 1 second delay wend ' Endless loop end.
mikroBasic PRO for FT90x
For this example we have used the EasyFT90x v7 development board.
- MCU: FT900;
- Oscillator: CPU at full system clock, 100.000MHz.
- Board settings: Turn ON ports GPIO 00-07, GPIO 08-15, GPIO 16-23, GPIO 24-31, GPIO 32-39, GPIO 40-47, GPIO 48-55 and GPIO 56-66 at SW8.
program LedBlinking main: GPIO_Digital_Output(@GPIO_PORT_00_07, _GPIO_PINMASK_ALL) ' Set GPIO 00-07 port as digital output GPIO_Digital_Output(@GPIO_PORT_08_15, _GPIO_PINMASK_ALL) ' Set GPIO 08-15 port as digital output GPIO_Digital_Output(@GPIO_PORT_16_23, _GPIO_PINMASK_ALL) ' Set GPIO 16-23 port as digital output GPIO_Digital_Output(@GPIO_PORT_24_31, _GPIO_PINMASK_ALL) ' Set GPIO 24-31 port as digital output GPIO_Digital_Output(@GPIO_PORT_32_39, _GPIO_PINMASK_ALL) ' Set GPIO 32-39 port as digital output GPIO_Digital_Output(@GPIO_PORT_40_47, _GPIO_PINMASK_ALL) ' Set GPIO 40-47 port as digital output GPIO_Digital_Output(@GPIO_PORT_48_55, _GPIO_PINMASK_ALL) ' Set GPIO 48-55 port as digital output GPIO_Digital_Output(@GPIO_PORT_56_63, _GPIO_PINMASK_ALL) ' Set GPIO 56-63 port as digital output GPIO_Digital_Output(@GPIO_PORT_64_66, _GPIO_PINMASK_ALL) ' Set GPIO 64-66 port as digital output GPIO_PORT_00_07 = 0 GPIO_PORT_08_15 = 0 GPIO_PORT_16_23 = 0 GPIO_PORT_24_31 = 0 GPIO_PORT_32_39 = 0 GPIO_PORT_40_47 = 0 while true GPIO_PORT_00_07 = 0 GPIO_PORT_08_15 = 0 GPIO_PORT_16_23 = 0 GPIO_PORT_24_31 = 0 GPIO_PORT_32_39 = 0 GPIO_PORT_40_47 = 0 Delay_ms(100) GPIO_PORT_00_07 = 0xff GPIO_PORT_08_15 = 0xff GPIO_PORT_16_23 = 0xff GPIO_PORT_24_31 = 0xff GPIO_PORT_32_39 = 0xff GPIO_PORT_40_47 = 0xff Delay_ms(100) wend end.
LED blinking for mikroPascal
mikroPascal PRO for PIC
For this description we have used the EasyPIC7 development board.
- MCU: PIC18F45K22 from Microchip;
- Oscillator: HS-PLL 32.0000 MHz, 8.0000 MHz Crystal.
- Board settings: Turn ON the PORT LEDs at SW3.
program LED_Blinking; begin TRISA := 0; // set direction to be output TRISB := 0; // set direction to be output TRISC := 0; // set direction to be output TRISD := 0; // set direction to be output TRISE := 0; // set direction to be output while TRUE do begin LATA := 0x00; // Turn OFF LEDs on PORTA LATB := 0x00; // Turn OFF LEDs on PORTB LATC := 0x00; // Turn OFF LEDs on PORTC LATD := 0x00; // Turn OFF LEDs on PORTD LATE := 0x00; // Turn OFF LEDs on PORTE Delay_ms(1000); // 1 second delay LATA := 0xFF; // Turn ON LEDs on PORTA LATB := 0xFF; // Turn ON LEDs on PORTB LATC := 0xFF; // Turn ON LEDs on PORTC LATD := 0xFF; // Turn ON LEDs on PORTD LATE := 0xFF; // Turn ON LEDs on PORTE Delay_ms(1000); // 1 second delay end; // Endless loop end.
mikroPascal PRO for dsPIC
For this example we have used the EASYPIC v7 for dsPIC30 development board.
- MCU: dsPIC30F4013 from Microchip;
- Oscillator: XT-PLL8, 80.000MHz.
- Board settings: Turn ON port LEDs at SW10.
program LED_Blinking; begin ADPCFG := 0xFFFF; // Configure AN pins as digital I/O TRISB := 0; // Initialize PORTB as output TRISC := 0; // Initialize PORTC as output TRISD := 0; // Initialize PORTD as output TRISF := 0; // Initialize PORTF as output LATB := 0; // Set PORTB to zero LATC := 0; // Set PORTC to zero LATD := 0; // Set PORTD to zero LATF := 0; // Set PORTF to zero while TRUE do begin LATB := not LATB; // Invert PORTB value LATC := not LATC; // Invert PORTC value LATD := not LATD; // Invert PORTD value LATF := not LATF; // Invert PORTF value Delay_ms(1000); end; end.
mikroPascal PRO for PIC32
For this example we have used the EasyPIC Fusion v7 development board.
- MCU: P32MX795F512L from Microchip;
- Oscillator: XT-PLL, 80.0000MHz.
- Board settings: Turn ON PORTA, B, C, D, F & G LEDS at SW15.
program Led_Blinking; begin AD1PCFG := 0xFFFF; // Configure AN pins as digital I/O JTAGEN_bit := 0; // Disable JTAG TRISA := 0; // Initialize PORTA as output TRISB := 0; // Initialize PORTB as output TRISC := 0; // Initialize PORTC as output TRISD := 0; // Initialize PORTD as output TRISF := 0; // Initialize PORTE as output TRISG := 0; // Initialize PORTG as output LATA := 0; // Set PORTA to zero LATB := 0; // Set PORTB to zero LATC := 0; // Set PORTC to zero LATD := 0; // Set PORTD to zero LATF := 0; // Set PORTE to zero LATG := 0; // Set PORTG to zero while TRUE do begin LATA := not PORTA; // Invert PORTA value LATB := not PORTB; // Invert PORTB value LATC := not PORTC; // Invert PORTC value LATD := not PORTD; // Invert PORTD value LATF := not PORTF; // Invert PORTE value LATG := not PORTG; // Invert PORTG value Delay_ms(1000);
mikroPascal PRO for ARM
For this example we have used the EasyMx v7 for STM(R) ARM(R) development board.
- MCU: STM32F107VC;
- Oscillator: HSE-PLL, 72.000MHz.
- Board settings: Turn ON PORTA, PORTB, PORTC, PORTD, PORTE at SW15.
program LedBlinking; { Declarations section } begin { Main program } GPIO_Digital_Output(@GPIOA_BASE, _GPIO_PINMASK_ALL); // Set PORTA as digital output GPIO_Digital_Output(@GPIOB_BASE, _GPIO_PINMASK_ALL); // Set PORTB as digital output GPIO_Digital_Output(@GPIOC_BASE, _GPIO_PINMASK_ALL); // Set PORTC as digital output GPIO_Digital_Output(@GPIOD_BASE, _GPIO_PINMASK_ALL); // Set PORTD as digital output GPIO_Digital_Output(@GPIOE_BASE, _GPIO_PINMASK_ALL); // Set PORTE as digital output GPIOA_ODR := 0; GPIOB_ODR := 0; GPIOC_ODR := 0; GPIOD_ODR := 0; GPIOE_ODR := 0; while TRUE do begin GPIOA_ODR := not GPIOA_ODR; // Toggle PORTA GPIOB_ODR := not GPIOB_ODR; // Toggle PORTB GPIOC_ODR := not GPIOC_ODR; // Toggle PORTC GPIOD_ODR := not GPIOD_ODR; // Toggle PORTD GPIOE_ODR := not GPIOE_ODR; // Toggle PORTE Delay_ms(1000); end; end.
mikroPascal PRO for AVR
For this example we have used the EasyAVR v7 development board.
- MCU: ATMEGA32;
- Oscillator: External Clock 08.0000 MHz.
- Board settings: Make sure you turn ON the PORTA, PORTB, PORTC and PORTD LEDs (SW10.5, SW10.6, SW10.7 and SW10.8).
program LED_Blinking; begin DDRA := 0xFF; // Set direction to be output DDRB := 0xFF; // Set direction to be output DDRC := 0xFF; // Set direction to be output DDRD := 0xFF; // Set direction to be output while TRUE do begin PORTA := 0x00; // Turn ON diodes on PORTA PORTB := 0x00; // Turn ON diodes on PORTB PORTC := 0x00; // Turn ON diodes on PORTC PORTD := 0x00; // Turn ON diodes on PORTD Delay_ms(1000); // 1 second delay PORTA := 0xFF; // Turn OFF diodes on PORTA PORTB := 0xFF; // Turn OFF diodes on PORTB PORTC := 0xFF; // Turn OFF diodes on PORTC PORTD := 0xFF; // Turn OFF diodes on PORTD Delay_ms(1000); // 1 second delay end; // Endless loop} end.
mikroPascal PRO for 8051
For this example we have used the Easy8051v6 development board.
- MCU: AT89S8253;
- Oscillator: External Clock 10.0000 MHz.
- Board settings: Turn ON the PORT LEDs (SW7). On Easy8051v6 LEDs are activated by logical zero.
program LED_Blinking; begin while TRUE do begin P0 := 0x00; // Turn ON diodes on PORT0 P1 := 0x00; // Turn ON diodes on PORT1 P2 := 0x00; // Turn ON diodes on PORT2 P3 := 0x00; // Turn ON diodes on PORT3 Delay_ms(1000); // 1 second delay P0 := 0xFF; // Turn OFF diodes on PORT0 P1 := 0xFF; // Turn OFF diodes on PORT1 P2 := 0xFF; // Turn OFF diodes on PORT2 P3 := 0xFF; // Turn OFF diodes on PORT3 Delay_ms(1000); // 1 second delay end; // Endless loop end.
mikroPascal PRO for FT90x
For this example we have used the EasyFT90x development board.
- MCU: FT900 MCU;
- Oscillator: CPU at full system clock, 100.000MHz.
- Board settings: Turn ON ports GPIO 00-07, GPIO 08-15, GPIO 16-23, GPIO 24-31, GPIO 32-39, GPIO 40-47, GPIO 48-55 and GPIO 56-66 at SW8.
program LedBlinking; begin GPIO_Digital_Output(@GPIO_PORT_00_07, _GPIO_PINMASK_ALL); // Set GPIO 00-07 port as digital output GPIO_Digital_Output(@GPIO_PORT_08_15, _GPIO_PINMASK_ALL); // Set GPIO 08-15 port as digital output GPIO_Digital_Output(@GPIO_PORT_16_23, _GPIO_PINMASK_ALL); // Set GPIO 16-23 port as digital output GPIO_Digital_Output(@GPIO_PORT_24_31, _GPIO_PINMASK_ALL); // Set GPIO 24-31 port as digital output GPIO_Digital_Output(@GPIO_PORT_32_39, _GPIO_PINMASK_ALL); // Set GPIO 32-39 port as digital output GPIO_Digital_Output(@GPIO_PORT_40_47, _GPIO_PINMASK_ALL); // Set GPIO 40-47 port as digital output GPIO_Digital_Output(@GPIO_PORT_48_55, _GPIO_PINMASK_ALL); // Set GPIO 48-55 port as digital output GPIO_Digital_Output(@GPIO_PORT_56_63, _GPIO_PINMASK_ALL); // Set GPIO 56-63 port as digital output GPIO_Digital_Output(@GPIO_PORT_64_66, _GPIO_PINMASK_ALL); // Set GPIO 64-66 port as digital output GPIO_PORT_00_07 := 0; GPIO_PORT_08_15 := 0; GPIO_PORT_16_23 := 0; GPIO_PORT_24_31 := 0; GPIO_PORT_32_39 := 0; GPIO_PORT_40_47 := 0; GPIO_PORT_48_55 := 0; GPIO_PORT_56_63 := 0; GPIO_PORT_64_66 := 0; while (TRUE) do begin GPIO_PORT_00_07 := not(GPIO_PORT_00_07); // togle PORT 00-07 GPIO_PORT_08_15 := not(GPIO_PORT_08_15); // togle PORT 08-15 GPIO_PORT_16_23 := not(GPIO_PORT_16_23); // togle PORT 16-23 GPIO_PORT_24_31 := not(GPIO_PORT_24_31); // togle PORT 24-31 GPIO_PORT_32_39 := not(GPIO_PORT_32_39); // togle PORT 32-39 GPIO_PORT_40_47 := not(GPIO_PORT_40_47); // togle PORT 40-47 GPIO_PORT_48_55 := not(GPIO_PORT_48_55); // togle PORT 48-55 GPIO_PORT_56_63 := not(GPIO_PORT_56_63); // togle PORT 56-63 GPIO_PORT_64_66 := not(GPIO_PORT_64_66); // togle PORT 64-66 Delay_ms(1000); end; end.