Home     Contact     Projects     Experiments     Circuits     Theory     BLOG     PIC Tutorials     Time for Science     RSS     Terms of services     Privacy policy  
   
 Home      Projects     Experiments     Circuits     Theory     BLOG     PIC Tutorials     Time for Science   



Creating new files and adding them in the project

First of all, we need to prepare the project directory a little bit. Microchip has create and distributes together with the MPLAB IDE, some header files that will make your life easier when programming with assembly. Those files will give a name to the numerous hexadecimal positions of the memory of the PIC. To give you an example on the degree of ease that this file provides, i will show you an example:

movlw b'00100000'
movwf 0x05h


and...

movlw b'00100000'
movwf PORTA

The two code blocks above will do exactly the same job. The second one uses the name PORTA instead of the hexadecimal memory position of the PORT-A of the PIC. Which one is easier to read? And imagine that there are tens of such memory positions!

This header file is located within the MPLAB IDE directory, under the subdirectory 'devices'. Instead, you can directly download it from our following link:

 PIC16f88 Microchip header file



Adding the Microchip PIC16F88 header file in your progect
Step 1:

There are two ways to begin. Either you will copy this file inside your project directory, or you will link to it from the directory that originally exists. I prefer the first way. I always want to have all project files inside one directory. There are some files of course that should be placed in a common directory and held there. For this one, you can do as you wish. Just make sure that if you happen to change your computer configuration, if you keep the file at the original position, then this files should be located in the same position as before.

Step 2:

Then you go to the menu Project -> Add files to project

Step 3:

A file browser appears. Make sure that you have chosen 'Files of type' to be 'Header *.h, *.inc'. Go to your project directory (or wherever else the PIC16f88.inc file is located) and open it.

Step 4:

When you click 'Open', the project explorer should have the header file located under the 'Header Files' node. You should note that right now, the file is loaded in the project but will not take part in the compilation of the program at all. This means that the file is only shown there, but does absolutely nothing. Each and every file MUST be included using the #include command to take part in the compilation. We will refer to this command in the following pages.

Adding new files in your project

You should not confuse this procedure with the previous one. Adding files and adding new files are two different meus. The first one will add existing files to the project explorer. The second one that will be demonstrated right now, will create a new file and will add it to the project explorer as well.

Step 1:

Go to the menu Project -> Add New File to Project

Step 2:

The file browser will appear. Make sure that you are in your project's directory. In the 'File Name' textbox, write the name of the new file that you wish to create and add. IMPORTANT! You should include also the extension of the file!!! During our tutorials, you should need to know two extensions: the .asm that represents an assembly listing file, and the .inc that represents a header file. Right now we need an assembly file to be created. I have used the name 'Tutor-1.asm'. You should use the same for following this tutorial.

Step 3:

When you click 'Save', two things will happen: First, a new file shall be created with the filename given before. Second, this file will be loaded in the project and will be shown in the project explorer window. If you did everything correct, then you should have the 'Tutor-1.asm' shown under the 'Source Files' tree node. Also, the file will be opened for editing. It will be of course blank.







Confirm your knowledge

There is an online test to check your knowledge on this page. You may reveal the test with the following button:






Previous page ---- Next page



Go back to the book contents

Go to the discussion forum of this book





 

Comments

  Name

  Email (shall not be published)

  Website

Notify me of new posts via email


Write your comments below:
BEFORE you post a comment:You are welcome to comment for corrections and suggestions on this page. But if you have questions please use the forum instead to post it. Thank you.


      

  • At 19 September 2014, 14:52:02 user Jack Schmidling wrote:   [reply @ Jack Schmidling]
    • Please explain the difference or why we have .inc and .h
      or why .h becomes .inc when added.

      Also, I have never added headers to or even noticed the header file folder in the project folder but just put the .inc at the top of the program if it was not already there.

      When done this way, it does not appear in the header folder and I never noticed this nor does it seem to matter.

      Thanks,

      Jack


  • At 30 December 2012, 12:43:24 user George soli wrote:   [reply @ George soli]
    • Amazin


  • At 18 December 2011, 9:37:57 user Alan Oxley wrote:   [reply @ Alan Oxley]
    • Hi,
      thanks a lot for these tutorials. Most demo's assume you have a "C" compiler so without one, its impossible to get going with PIC's.
      I have some LED's blinking in 90 minites from not knowing anything at all about PIC's.


  • At 28 March 2011, 18:29:04 user aaron wrote:   [reply @ aaron]
    • i'm at the few first pages of reading now this pic tutorial and I find it "easy to understand". the author of this simply knows how to teach the beginners! thanks


  • At 13 March 2011, 7:37:03 user Sayan Das (de.das.dude) wrote:   [reply @ Sayan Das (de.das.dude)]
    • awesome work done!
     






    No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise without the prior written permission of the author.

    Read the Disclaimer


    All trademarks used are properties of their respective owners.
    Copyright © 2007-2009 Lazaridis Giorgos.
    All rights reserved.






     HOT in heaven!


  • Disclaimer
  • Book Contents
  • Discussion forum

  • Basics
  • What will you need
  • Choosing the right PIC
  • The MPLAB
  • Getting familiar with the MPLAB environment
  • Creating a new project
  • Open and close projects
  • Creating new files and including them in the project
  • Your very first assembly program
  • Compile a program and transfer to the PIC
  • Section 1: Beginner's theory
  • Memory Organization
  • The Data Memory Organization
  • The Program Memory Organization
  • The instructions
  • General knowledge about instructions
  • Value Loading Instructions
  • Program Flow Instructions
  • Mathematic Instructions
  • Logic Function Instructions
  • Bit Orientated Instructions
  • Byte Orientated Instructions
  • Miscellaneous Instructions
  • The Basic Special Function Registers
  • The Status Register
  • The Option_Reg Register
  • The TRIS and PORT registers
  • Beginner's PIC Tutorials
  • How to use our PIC Tutorials
  • A Pushbutton turning an LED on and off
  • A Simple LED Flasher
  • Interfacing Multiple Switches - The internal Pull-Up resistors
  • An LED Sequencer
  • Interface a Single 7seg Digit
  • Interface Multiple 7seg Digits
  • A 3-digits Decimal Counter
  • A Clever Button
  • Section 2: Intermediate theory
  • Instruction Cycle Duration and Calculated Delays
  • The Timer Modules - Timer0
  • The Timer Modules - Timer1
  • The Timer Modules-Timer2



  • NEW in heaven!



    New Theory: AC electric motor working principle






     Contact     Forum     Projects     Experiments     Circuits     Theory     BLOG     PIC Tutorials     Time for Science     RSS   

    Site design: Giorgos Lazaridis
    © Copyright 2008
    Please read the Terms of services and the Privacy policy