{"id":1750,"date":"2011-02-12T21:45:10","date_gmt":"2011-02-13T02:45:10","guid":{"rendered":"http:\/\/embedded-lab.com\/blog\/?p=1750"},"modified":"2012-07-30T09:29:24","modified_gmt":"2012-07-30T13:29:24","slug":"mikroc-pro-for-pic-installation-and-setup","status":"publish","type":"post","link":"https:\/\/embedded-lab.com\/blog\/mikroc-pro-for-pic-installation-and-setup\/","title":{"rendered":"MikroC Pro for PIC : Installation and Setup"},"content":{"rendered":"<p>My PIC tutorials and projects use MikroC compiler for firmware development. But I don&#8217;t think I ever posted anything on its installation and setup. Today, I am going to show how to install MikroC Pro for PIC (v4.60) on a Windows PC. First of all, download the zipped installation file from <a href=\"http:\/\/www.mikroe.com\/eng\/downloads\/get\/29\/mikroc_pro_pic_2011_v460_setup.zip\">here<\/a>, unzip it and run the setup program.\u00a0Installation is straightforward. When you first start the MikroC compiler, it opens a LED blinking example project. You can close this project by clicking on &#8216;Close Project&#8217; under Project menu.<!--more--><\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/02\/MikroC1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-1751  aligncenter\" title=\"MikroC1\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/02\/MikroC1-550x375.png\" alt=\"\" width=\"550\" height=\"375\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/02\/MikroC1-550x375.png 550w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/02\/MikroC1.png 800w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" \/><\/a><\/p>\n<p>Now, I am going to show you how to create a new project. I will demonstrate with my MikroC code that I wrote for one of my tutorials (<a href=\"http:\/\/embedded-lab.com\/blog\/?p=264\" target=\"_blank\">Analog to Digital Conversion<\/a>). First, Do File -&gt; New -&gt; New Project and you will see the Welcome wizard. Click on Next and you will see a wizard for selecting device. Select PIC16F688, and click Next. Then select Device Clock = 4.0 MHz. The third step is to give your project a filename. You can browse to the directory you want and type in the name for your project. I usually create a separate folder for each project so that all the files associated with the project remain inside the folder, including the final output HEX file. The next step is to add files to your project. You can click Next as there are no files that are needed to be included at this point. The fifth step gives you the option to include the built in library routines. Select Include All (Default).<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/02\/MikroC2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-1753  aligncenter\" title=\"MikroC2\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/02\/MikroC2-550x390.png\" alt=\"\" width=\"550\" height=\"390\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/02\/MikroC2-550x390.png 550w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/02\/MikroC2.png 603w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" \/><\/a><\/p>\n<p>Click Next and you will see the message saying New Project created successfully. Click on Finish, and you will see the programming editor. You will see a default main() function is added to your program editor.<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/02\/MikroC3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-1754  aligncenter\" title=\"MikroC3\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/02\/MikroC3-550x369.png\" alt=\"\" width=\"550\" height=\"369\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/02\/MikroC3-550x369.png 550w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/02\/MikroC3.png 600w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" \/><\/a><\/p>\n<p>Type in the following program and save it<\/p>\n<pre><span style=\"color: #003366;\">\/*<\/span><\/pre>\n<pre><span style=\"color: #003366;\"> Lab 5: Analog-to-digital converter<\/span><\/pre>\n<pre><span style=\"color: #003366;\"> Internal Oscillator @ 4MHz, MCLR Enabled, PWRT Enabled, WDT OFF<\/span><\/pre>\n<pre><span style=\"color: #003366;\"> Copyright @ Rajendra Bhatt<\/span><\/pre>\n<pre><span style=\"color: #003366;\"> October 10, 2010<\/span><\/pre>\n<pre><span style=\"color: #003366;\">*\/<\/span><\/pre>\n<pre><span style=\"color: #003366;\">\/\/ LCD module connections<\/span><\/pre>\n<pre><span style=\"color: #003366;\"> sbit LCD_RS at RC4_bit;<\/span><\/pre>\n<pre><span style=\"color: #003366;\"> sbit LCD_EN at RC5_bit;<\/span><\/pre>\n<pre><span style=\"color: #003366;\"> sbit LCD_D4 at RC0_bit;<\/span><\/pre>\n<pre><span style=\"color: #003366;\"> sbit LCD_D5 at RC1_bit;<\/span><\/pre>\n<pre><span style=\"color: #003366;\"> sbit LCD_D6 at RC2_bit;<\/span><\/pre>\n<pre><span style=\"color: #003366;\"> sbit LCD_D7 at RC3_bit;<\/span><\/pre>\n<pre><span style=\"color: #003366;\"> sbit LCD_RS_Direction at TRISC4_bit;<\/span><\/pre>\n<pre><span style=\"color: #003366;\"> sbit LCD_EN_Direction at TRISC5_bit;<\/span><\/pre>\n<pre><span style=\"color: #003366;\"> sbit LCD_D4_Direction at TRISC0_bit;<\/span><\/pre>\n<pre><span style=\"color: #003366;\"> sbit LCD_D5_Direction at TRISC1_bit;<\/span><\/pre>\n<pre><span style=\"color: #003366;\"> sbit LCD_D6_Direction at TRISC2_bit;<\/span><\/pre>\n<pre><span style=\"color: #003366;\"> sbit LCD_D7_Direction at TRISC3_bit;<\/span><\/pre>\n<pre><span style=\"color: #003366;\">\/\/ End LCD module connections<\/span><\/pre>\n<pre><span style=\"color: #003366;\">\/\/ Define Messages<\/span><\/pre>\n<pre><span style=\"color: #003366;\"> char message1[] = \"ADC Value= \";<\/span><\/pre>\n<pre><span style=\"color: #003366;\"> char *temp = \"0000\";<\/span><\/pre>\n<pre><span style=\"color: #003366;\"> unsigned int ADC_Value;<\/span><\/pre>\n<pre><span style=\"color: #003366;\"> void main() {<\/span><\/pre>\n<pre><span style=\"color: #003366;\">  ANSEL = 0b00000100; \/\/ RA2\/AN2 is analog input<\/span><\/pre>\n<pre><span style=\"color: #003366;\">  ADCON0 = 0b00001000; \/\/ Analog channel select @ AN2<\/span><\/pre>\n<pre><span style=\"color: #003366;\">  CMCON0 = 0x07 ; \/\/ Disbale comparators<\/span><\/pre>\n<pre><span style=\"color: #003366;\">  TRISC = 0b00000000; \/\/ PORTC All Outputs<\/span><\/pre>\n<pre><span style=\"color: #003366;\">  TRISA = 0b00001100; \/\/ PORTA All Outputs, Except RA3 and RA2<\/span><\/pre>\n<pre><span style=\"color: #003366;\">  Lcd_Init(); \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\/\/ Initialize LCD<\/span><\/pre>\n<div>\n<p><span style=\"color: #003366;\"><span style=\"color: #003366;\"> <\/span><\/span><\/p>\n<pre><span style=\"color: #003366;\">  Lcd_Cmd(_LCD_CLEAR); \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/\/ CLEAR display<\/span><\/pre>\n<pre><span style=\"color: #003366;\">  Lcd_Cmd(_LCD_CURSOR_OFF); \u00a0 \u00a0 \u00a0 \u00a0\/\/ Cursor off<\/span><\/pre>\n<pre><span style=\"color: #003366;\">  Lcd_Out(1,1,message1); \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/\/ Write message1 in 1st row<\/span><\/pre>\n<\/div>\n<pre><span style=\"color: #003366;\">  do {<\/span><\/pre>\n<pre><span style=\"color: #003366;\">   adc_value = ADC_Read(2);<\/span><\/pre>\n<pre><span style=\"color: #003366;\">   temp[0] = adc_value\/1000 + 48; \/\/ Add 48 to get the ASCII character value<\/span><\/pre>\n<pre><span style=\"color: #003366;\">   temp[1] = (adc_value\/100)%10 + 48;<\/span><\/pre>\n<pre><span style=\"color: #003366;\">   temp[2] = (adc_value\/10)%10 + 48;<\/span><\/pre>\n<pre><span style=\"color: #003366;\">   temp[3] = adc_value%10 + 48;<\/span><\/pre>\n<pre><span style=\"color: #003366;\">   Lcd_Out(1,11,temp);<\/span><\/pre>\n<pre><span style=\"color: #003366;\">   Delay_ms(2000);<\/span><\/pre>\n<pre><span style=\"color: #003366;\">  } while(1);<\/span><\/pre>\n<pre><span style=\"color: #003366;\"> }<\/span><\/pre>\n<p>In order to set the configuration bits go to Project -&gt; Edit Project. You can see all the options for selecting clock oscillator, WDT, Power up timer, etc. Select the right setting for your project. In this example, I am using the internal RC clock, and so I selected Internal RC No Clock option for the oscillator. If you are using the MCLR reset pin, you should select Enabled option for Master Clear Enable. To compile click on Build -&gt; Build or hit Ctrl + F9. If there are no errors, the HEX file will be generated successfully inside the same project folder and you will see Project Finished Successfully message in the message window, at the bottom.<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/02\/MikroC4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-1756  aligncenter\" title=\"MikroC4\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/02\/MikroC4-550x352.png\" alt=\"\" width=\"550\" height=\"352\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/02\/MikroC4-550x352.png 550w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/02\/MikroC4.png 815w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" \/><\/a><\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/02\/MikroC5.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-1757  aligncenter\" title=\"MikroC5\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/02\/MikroC5-550x207.png\" alt=\"\" width=\"550\" height=\"207\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/02\/MikroC5-550x207.png 550w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/02\/MikroC5.png 788w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" \/><\/a><\/p>\n<p>The HEX file is ready to be downloaded inside the PIC16F688 microcontroller. It&#8217;s so easy.<!--more--><\/p>\n","protected":false},"excerpt":{"rendered":"<p>My PIC tutorials and projects use MikroC compiler for firmware development. But I don&#8217;t think I ever posted anything on its installation and setup. Today, I am going to show how to install MikroC Pro for PIC (v4.60) on a Windows PC. First of all, download the zipped installation file from here, unzip it and run the setup program.\u00a0Installation is straightforward. When you first start the MikroC compiler, it opens a LED blinking example project. You can close this project by clicking on &#8216;Close Project&#8217; under Project menu.<\/p>\n","protected":false},"author":1,"featured_media":1751,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29,183],"tags":[187,186,20],"class_list":["post-1750","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-embedded-lessons","category-tips-and-tricks","tag-c-compiler","tag-mikroc-installation","tag-pic16f688"],"_links":{"self":[{"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/posts\/1750","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/comments?post=1750"}],"version-history":[{"count":8,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/posts\/1750\/revisions"}],"predecessor-version":[{"id":5788,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/posts\/1750\/revisions\/5788"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/media\/1751"}],"wp:attachment":[{"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/media?parent=1750"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/categories?post=1750"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/tags?post=1750"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}