Chapter%201%20The%20First%20Flight - PowerPoint PPT Presentation

About This Presentation
Title:

Chapter%201%20The%20First%20Flight

Description:

Chapter 1 The First Flight ... output window A first statement A first complete program Controlling I ... and other special-function registers of the microcontroller: ... – PowerPoint PPT presentation

Number of Views:198
Avg rating:3.0/5.0
Slides: 17
Provided by: Lucio161
Category:

less

Transcript and Presenter's Notes

Title: Chapter%201%20The%20First%20Flight


1
Chapter 1 The First Flight
  • Creating the first project and saying Hello to
    the World

2
Checklist
  • The following tools will be used throughout the
    course
  • MPLAB X, Integrated Development Environment (v1.8
    or later, free)
  • MPLAB XC16, C compiler (v1.11 or later, free)
  • The following pieces of documentation will be
    used during this lesson
  • PIC24FJ128GA010 Datasheet DS39747 (latest rev.)
  • PIC24 Family Reference Manual - Section 12. I/O
    Ports
  • Make sure they are available and/or installed and
    ready to use on your computer.
  • You can download them from Microchip web site at
    http//www.microchip.com/mplabx
  • And http//www.microchip.com/xc16

3
Creating the First Project
  • Use the New Project wizard

4
New Project Wizard step 2
  • Select the PIC24 model

5
New Project Wizard step 3
  • No Header is required

6
New Project Wizard step 4
  • Select the programmer/debugger of choice
  • ICD3
  • PICKit3
  • Real ICE
  • ...

7
New Project Wizard step 5
  • Select the XC16 compiler (and version)

8
New Project Wizard step 6
  • Define the project location (folder) and assign
    the Project Name

9
New File Wizard
  • Use the New File wizard to create a new main file
    from a Microchip Embedded template

10
New File Wizard Alternate step1
  • Use the New File wizard to create a new empty
    file

11
New File Wizard step 2
  • Assign the name Hello1.c

12
The Plan
  • The first project with MPLAB X IDE
  • The project window
  • The editor
  • The output window
  • A first statement
  • A first complete program
  • Controlling I/Os Ports and Pins
  • Building the project
  • The first debugging experience
  • Hello World!

13
The First Program Hello1.c
  • / File Hello1.c
  • Author your name here Created current
    date here /
  • include ltxc.hgt
  • int main( void)
  • return 0

Replaces previously used include ltp24Fxxxx.hgt
14
Whats in ltxc.hgt
  • After a selection based on the PIC24 model you
    chose for your project, you will find the
    definitions of the program counter and other
    special-function registers of the
    microcontroller
  • ...
  • extern volatile unsigned int PCL
    __attribute__((__sfr__))
  • extern volatile unsigned char PCH
    __attribute__((__sfr__))
  • extern volatile unsigned char TBLPAG
    __attribute__((__sfr__))
  • extern volatile unsigned char PSVPAG
    __attribute__((__sfr__))
  • extern volatile unsigned int RCOUNT
    __attribute__((__sfr__))
  • extern volatile unsigned int SR
    __attribute__((__sfr__))
  • ...

15
Meet the Project Window
  • It contains a logical grouping of all the files
    that belong to the project
  • Note Like most MPLAB X windows, it can be free
    floating or docked!

right-click here to dock the window
16
Meet PORTA
  • /
  • Hello Embedded World
  • Hello1.c my first PIC24 program in C
  • /
  • include ltxc.hgt
  • int main( void)
  • PORTA 0xff
  • return 0

dont forget the semicolon!
17
Building the Project
  • There are several ways to achieve the same result
    in MPLAB X, select
  • Run gt Build Project
  • Will compile all new and changed source files
  • Or
  • Run gt Clean and Build Project
  • Produces a forced recompile of all source files
  • Or
  • Run gt Run Project
  • Will compile all new and changed source files, if
    successful it will also program the part using
    the selected programmer/debugger
  • Or
  • Use the corresponding buttons in the top toolbar
Write a Comment
User Comments (0)
About PowerShow.com