buy hot The Fixer cool video Year One download Kasabian album nice Terminator Salvation hit cool track Jordin Sparks USA Whatever Works video download Check My Brain melodies nice video Finding Nemo nice Pop - Various Artists hit cheap DIVX Year One

digital-diy.com

MPLAB C18 Tutorial - Setting up a new C18 project and creating an application Print E-mail
( 9 Votes )
  
Saturday, 04 April 2009 01:19
Article Index
MPLAB C18 Tutorial - Setting up a new C18 project and creating an application
Preface
Project Notes
Setting up the project folder structure
Files used for a project
Creating a new project
Configuring the project: Build Options - Search Paths
Configuring your project: Selecting your programmer
Creating the main code file
Writing the setup code into main.c
Functions and prototypes
Blinking LED application
All Pages

Setting up a new C18 project and creating an application

bg_picmicro bg_18f452 bg_pickit2 bg_mplab bg_c18

Last updated November 28, 2009 (11.28.09)

This tutorial will show you how to create and configure a new C18 project and then how to create an application within that project. The application is a simple one, well, at least it is at first. Yes, the typical and all-so-popular LED blinking application. What is great about this simple objective is that there are so many ways to do it! At first we will use a simple loop, then we will make use of some basic and specialized software and hardware libraries to add features and special abilities. We will eventually make use of interrupts, timers, even the PWM peripheral to 'enhance' our LED blinking application. Finally, we will conclude by adding RS-232 communication with a PC terminal program so we can control the operation of the LED blinker.

The article does not end here! Either view all pages, click next for each sequential page or click on the subject headings on the article index (located on the right) to continue.




Comments (7)
  • Graham  - Edits

    Hi Hop,

    I've finally got some time this weekend to delve into the world of C - you have answered a lot of my questions with this tutorial!

    I did find some errors, one was induced by some old site settings, the other was while following the guide step by step (excellent guide by the way - picking up new software idiosyncrasies can be quite frustrating). The errors;

    - Anything in tags (such as includes) where removed (old site settings did this on article saves, it has been fixed).
    - The Libraries directory needed to be C:MCC18h (I had build errors with C:MCC18 declared).

    I've updated the include files and uploaded new images which reflect the path change - hope you don't mind.

    Once again, thanks for the article! (PS - I archived the old comments on this article to clean things up a little more)

    Edit: above should read C: -backslash- MCC18 -backslash- h, backslashes are omitted from these comments for sql compatibility issues with other backend stuff. Backslashes work fine in articles though *

    Edit (16 Mar 2010): Seems somewhere along the line that the mod for include tags had disappeared. I've re-added it as of today.

  • AllVol

    I'll read and enjoy your tutorial, hopefully learning much but...

    "Also, please bare with me"

    is going too far. I ain't gettin' nekked for no teacher.

    LOL

  • Double D  - lkr sub-folder

    Nice and well done Tutorial!

    FYI concerning : Page 7 of 12
    Configuring the project: Build Options - Search Paths:

    If you cant't find the lkr sub-folder, dont worry,


    The linker files aren't missing, they're now obsolete.


    from : http://www.microchip.com/forums/printable.aspx?m=463383

    " The multiple linker files per CPU have been replaced by a single _g linker file. This is probably discussed in the compiler's release notes.

    Any instructions that tell you to use 18f45k20i.lkr are outdated. You no longer need to use a linker file at all; MPLAB IDE will use the correct linker file automatically. If you have added a linker file to your project, remove it."

  • Matt Rhys-Roberts  - good starting point

    Thanks for going to the trouble of creating this tutorial. It was just what I needed to refresh my mind about functions, declarations etc., but within a practical context.

  • Mihal  - :)

    Greetings from Slovakia :) super

  • ozbecool  - Moving COnfig bits to a separate file : Bad practi

    The author (Hop) suggests to "set the target PIC's configuration bits in a separate header file "xxx ConfigBits.h".

    This is a bad practice since the bits actually CONFIGURE the PIC uC to act in a PARTICULAR manner therefore the bits programmed are NOT processor specific only - they are APPLICATION specific as well.

    For example for PIC16F690: bit 3 (called WDTE in PIC16F690 manual) enables or disables Watchdog Timer. So in one user program (say AA.C the watchdog timer might be needed while in another user program BB.C (but still for THE SAME PIC uC type) that timer might not be needed (used / required).

    So it is a better practice to have the configuration bits listed in your MAIN "C" file - and of course good practice is to ADD COMMENTS to each of those bits so that you / others now / in future would easily see what is the uC configured for.

Write comment
Your Contact Details:
Comment:
[b] [i] [u] [url] [quote] [code] [img]   
Security
Please input the anti-spam code that you can read in the image.
Last Updated ( Saturday, 28 November 2009 23:18 )
 

Whos Online

  • andyo
  • Jon Chandler

Forum Activity