EEE527 Embedded Systems Lecture 3: Chapter 1: Using MPLAB (X) + XC32 Ian McCrumRoom 5B18, Tel: 90 366364 voice mail on 6 th ring

Slides:



Advertisements
Similar presentations
Chapter 3 Message in a Bottle Programming Loops in C.
Advertisements

Chapter 2 Walking in Circles Programming Loops in C.
Getting started with MPLAB Launch MPLAB Set Toolbar as in the next slide by clicking the leftmost icon Open a new Source file by choosing [FILE][NEW] Type.
Renesas Technology America Inc. 1 SKP8CMINI-15,17 Tutorial 2 Creating A New Project Using HEW4.
Introduction to HT-IDE3000 Micro-C development System Department.
Simple Microcontroller Programming with PIC16F88.
Chapter 4 NUMB3RS.
Code Composer Department of Electrical and Computer Engineering
Copyright  Oracle Corporation, All rights reserved. 1 Creating an Application: The AppBuilder for Java IDE.
Slides created by: Professor Ian G. Harris PIC Development Environment MPLAB IDE integrates all of the tools that we will use 1.Project Manager -Groups.
Lab6 – Debug Assembly Language Lab
1-1 Embedded Software Development Tools and Processes Hardware & Software Hardware – Host development system Software – Compilers, simulators etc. Target.
Using PDG with e2studio: Example
ECE Department: University of Massachusetts, Amherst Lab 1: Introduction to NIOS II Hardware Development.
EEE305 Microcontroller Systems Lecture 4: The PIC microprocessor and the Microchip C Compilers Teaching resources on on
Railway Foundation Electronic, Electrical and Processor Engineering.
SKP8CMINI-15,17 Tutorial 1 Software Development Process using HEW4
LSU 06/04/2007BASIC Stamp Editor1 The BASIC Stamp Editor Programming Unit, Lecture 3.
Renesas Technology America Inc. 1 SKP8CMINI Tutorial 1 Introduction.
M16C/Tiny SKP Tutorial 1 Software Development Process using HEW4
Introduction Purpose Objectives Content Learning Time
EEE527 Embedded Systems Lecture 8: Practical Interrupts Ian McCrumRoom 5B18, Tel: voice mail on 6 th ring Web site:
Chapter 1 The First Flight Creating the first project and saying “Hello to the World”
Part 1 Using the ARM board And start working with C Tutorial 5 and 6
Digital Image Processing Lecture3: Introduction to MATLAB.
Silicon Labs ToolStick Development Platform
The instructor presents the 1st 9 slides
Driver Station MVRT 2009 – 2010 Season. Add information Breadboard Classmate PC USB Hub Joysticks Stop Button.
Department of Electronic & Electrical Engineering Embedded system Aims: Introduction to: Hardware. Software Ideas for projects ? Robotics/Control/Sensors.
Renesas Technology America Inc. 1 M16C/Tiny SKP Tutorial 2 Creating A New Project Using HEW4.
Computer Literacy BASICS: A Comprehensive Guide to IC 3, 5 th Edition Lesson 3 Windows File Management 1 Morrison / Wells / Ruffolo.
Introduction Purpose This training course covers debugging an application on an SH target in the Renesas HEW (High-performance Embedded Workshop) development.
Introduction Purpose This course describes the process of installing the KPIT GNU toolchain on your PC. Objective Learn how easy it is to get information.
IT 211 Project Integration and Deployment Lab #11.
Chapter 2 A Loop in the Pattern Designing the Main Loop and Timing.
Programming and Problem Solving ELEC 330 Digital Systems Engineering Dr. Ron Hayne Images Courtesy of Ramesh Gaonkar and Delmar Learning.
ADAM2 Single Remocon MCU IDE User’s Manual S/W Integrated Development Environment - Assembler - Simulator - Code Wizard V1.0 Technical Sales Team, ETA.
Renesas Technology America Inc. 1 SKP8CMINI Tutorial 2 Creating A New Project Using HEW.
Introduction Purpose This training course covers debugging an application on an SH target in the Renesas HEW (High-performance Embedded Workshop) development.
ECS642U Embedded Systems Digital I/O William Marsh.
4 Copyright © 2004, Oracle. All rights reserved. Creating a Basic Form Module.
EEE527 Embedded Systems Lecture 10B:Chapter 11 Analogue to Digital Convertors (ADCs) (version 2: 25/11/13, see after slide 20 Ian McCrumRoom 5B18, Tel:
EndNote. What is EndNote? EndNote is referencing software that enables you to create a database of references from your readings.
EEE527 Embedded Systems Lecture 2: Chapter 2: C and Using more MPLAB (X) + XC32 Ian McCrumRoom 5B18, Tel: voice mail on 6 th ring
Renesas Technology America Inc. 1 M16C Seminars Lab 3 Creating Projects Using HEW4 14 March 2005 M16C Seminars Lab 3 Creating Projects Using HEW4 Last.
C++ LANGUAGE TUTORIAL LESSON 1 –WRITING YOUR FIRST PROGRAM.
Renesas Technology America Inc. 1 SKP8CMINI Tutorial 2 Creating A New Project Using HEW.
George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Configuring CodeWarrior V5.1 for the HCS12.
Computer Literacy BASICS: A Comprehensive Guide to IC 3, 5 th Edition Lesson 3 Windows File Management 1 Morrison / Wells / Ruffolo.
Object-Oriented Application Development Using VB.NET 1 Chapter 2 The Visual Studio.NET Development Environment.
Creating Web Pages with Links, Images, and Embedded Style Sheets
Microcontrollers JULES CALELLA. Microcontrollers vs Microprocessors  Microprocessors – do not contain RAM, ROM, I/O  Microcontrollers – The whole package.
Embedded C- Language Lets Learn fundamentals !!. An Embedded system is combination of computer hardware and software, and perhaps additional mechanical.
Programming and Debugging with the Dragon and JTAG Many thanks to Dr. James Hawthorne for evaluating the Dragon system and providing the core content for.
A Quick Start Guide to PIC16F877 microcontroller And Microchip Development Environment A Quick Start Guide to PIC16F877 microcontroller And Microchip Development.
CEng3361/18 CENG 336 INT. TO EMBEDDED SYSTEMS DEVELOPMENT Spring 2007 Recitation 01.
© 2008, Renesas Technology America, Inc., All Rights Reserved 1 Introduction Purpose  This training course demonstrates the use of the High-performance.
Lets Learn fundamentals !!
Chapter 3 General-Purpose Processors: Software
Programming and Debugging with the Dragon and JTAG
Lab 1: Using NIOS II processor for code execution on FPGA
The first change to your project files that is needed is to change the device to the correct FPGA. This is done by going to the Assignments tab on the.
Microcontroller Applications
PRU-ICSS Programming with CCS
RX111 Promotion Board (RPB) hands on
EndNote by: fatimah alotaibi.
Digital Image Processing
ECE 3567 Microcontroller Lab
Software Setup & Validation
Presentation transcript:

EEE527 Embedded Systems Lecture 3: Chapter 1: Using MPLAB (X) + XC32 Ian McCrumRoom 5B18, Tel: voice mail on 6 th ring Web site: 24/09/13 "Adapted from the text “Programming 32-bit Microcontrollers in C – Exploring the PIC32, © 2008.” Lucio di Jasio

The Plan The first project with MPLAB 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 Using the MPLAB SIM simulator The first debugging experience Hello World!

Preparation The following tools will be used in this lesson: MPLAB X IDE, Integrated Development Environment (use version X not v8.xx ) MPLAB SIM, free software simulator (included in MPLAB installation) MPLAB XC32, C compiler (free Student Edition) The following pieces of documentation will be used during this lesson: PIC32MX1XX/2XX datasheet Section 11. I/O Ports – DS61118E You will also need individual sections of the PIC32 Family reference manual Sections 12 i/o ports (DS61120E.pdf) Section 17 ADC (DS61104E.pdf) Make sure they are available and/or installed and ready to use on your computer. You can download them from me or the Microchip web site at: DESIGN SUPPORT->Reference Manuals, search for “PIC32 Family” DESIGN SUPPORT->Datasheets, search for “PIC32MX250F128B” DESIGN SUPPORT->Compilers tab

The New Project Set Up Launch MPLAB IDE Follow the “New Project Set Up” Checklist to create a new project using the Project Wizard

The New Project Setup Checklist 1.Select Microchip Embedded – Standalone Project 2.Select the PIC32MX250F128B device and click Next. 3.Select Simulator as the Tool to be used 4.Select the XC32 C-Compiler and click Next 5.Use a Project Name of Hello and click the Browse button and create a new folder named “EEE527” on DRIVE D: 6.Create a folder below this called “Hello” 7.Accept the default project folder “Hello.X”, then click Next. 8.Click on Finish to complete the project set up

The Windows (note the tabs as well! Familiarize yourself with the Windows (Tile) layout of MPLAB X.

You can reset to this view using the Windows top-level menu (Alt-W)

To add a new file to your project Do one of the following; Go to the Projects tab (top RHS of screen) and rightclick on “Source Files” Click on the New File ICON (1 st on icon toolbar) Use the main FILE ->New File menu Use the shortcut.

Choose a C main file

Name it main.c

Make sure you have main.c in these two places

Add the line #include below the other #includes. Find this file and open it using F)ile->Open File… (c:\Program Files\Microchip\xc32\pic32-libs\include) It refers to./proc/p32mx250f128b.h open it as well You will need to refer to this file, and to the datasheet to resolve exact names of registers and bits.

I/O PINS I/O pins can be configured as: – Digital Inputs – Digital Ouputs (Push Pull) – Digital Outputs (Open Drain) – Analog Inputs – Dedicated inputs or outputs for a number of peripherals – Pins to interface to programmers (PICKIT or JTAG)

PORTA and PORTB Different PORTs group pins with different functions PORTB for example contains a number of pins that can be configured as analog inputs to the Analog to Digital Converter (ADC). PORTA contains a number of pins that can be used for the JTAG interface, TRACE function, and the I2C interface Refer to the specific device datasheet for a detailed list of each PORT/pin capabilities

TRIS registers TRIS registers control the direction of each pin (Input/Output) TRISA, TRISB… each port has a corresponding tris register – Setting a bit to 1 configures a pin as Input – Clearing a bit to 0 configure the corresponding pin as an output

Microchip have renamed ANSEL to ADxPCFG in some CPUs

Therefore to use PORT B for simple I/O we must disable the ANALOG functions available on those pins. Similarly to use PORT A for simple I/O we must disable JTAG functionality There are other subtle points such as using the CHANGE registers associated with I/O pins – but the powerup defaults are ok in this case. Also a lot of peripherals can be switched to (almost) any PINs so we will need to look at “PERIPHERAL PIN SELECT” (PPS) at some stage, but, for now, the defaults are ok.

/* * File: main.c * Author: ian * * Created on 24 September 2013, 10:02 */ #include /* * */ int main(int argc, char** argv) { TRISB = 0; // all PORTB as output AD1PCFG = 0x0000; // all PORTB as digital PORTB = 0xff; return (EXIT_SUCCESS); } Edit your main.c to…

The Watch Window  Once a debugging tool (MPLAB SIM) is selected  Open the Watch Window  To inspect the content of a variable (symbol) or any of the special function registers (SFR)  Select the desired output format(s) The “NEW WATCH” under “DEBUG” top menu

Compiling and Linking A compiler transforms the C source code (.c) and all included (.h) files into a relocatable code object (.o) The linker takes all the relocatable code objects (.o) and libraries (.lib) and assembles them into an executable (.hex) file BUILD PROJECT to compile >>

Using the Simulator Learn the basic debugging options offered by the Simulator – Reset – Single Step (Over/In) – Animation – Running – Halting

Debugging: Hello World Set Watchpoints on PORTA and PORTB, set breakpoints on the pink lines and use DEBUG to singlestep and observe the ports change Lookup JTAGEN and AD1PCFG in both xc.h and the datasheets. Note in some pics AD1PCFG is changed to ANSELB

Analog Pin Functions Multiplexing The Analog Pins control: AD1PCFG

Summary In this lesson we learned: How to create a new project How to create our first C source file How to build a project using the MPLAB C32 compiler About PINs and PORTs How to configure and control simple digital output pins How to configure and use the MPLAB SIM simulator

Advanced Material

The Disassembly Window If you want to see what happens at the machine instruction level: – Open the disassembly window

The Memory Gauge If you want to see how much memory RAM and FLASH is being used by the project Look at the memory guage in the dashboard

Notes for the PIC MCU Experts The PIC32 PORTS are not necessarily 32-bit large. In fact most PORTS are 16-bit at the most. The PIC32 PORTS are designed to be compatible with the 8-bit and 16-bit PIC PORTS I/O PORT control in C is easy Use the LATx registers to control directly the output latches

Tips and Tricks Interfacing to 5V input and output signals is possible with some caution: – Digital Input pins are 5V tolerant – Digital Output pins can be configured as Open Drain – Use the ODCx registers to configure an output pin for Open Drain mode. – Watch Out! Pins that are multiplexed with analog functions are NOT 5V tolerant!

Suggested Excercises If you have the Explorer16 board and an in circuit debugger: – Use the MPLAB REAL ICE Debugging or the MPLAB ICD2 Debugging checklists to help you prepare the project for debugging. – Insert the instructions required to disable the JTAG port. – Test the PortA example, connecting the Explorer16 board and checking the visual output on LED0-7. If you have the PIC32 Starter Kit: – Use the PIC32 Starter Kit Debugging checklist to help you prepare the project for debugging. – Modify the code to operate on PortD, but do NOT disable the JTAG port. – Test the code by checking the visual output on LED0-2 on the PIC32 Starter Kit itself. In both cases you can: – Test the PortB example by connecting a voltmeter (or DMM) to pin RB0, if you can identify it on your board, and watching the needle move, between 0 and 3.3V, as you single step through the code.

Recommended Readings Kernighan, B. & Ritchie, D. The C Programming Language Prentice-Hall, Englewood Cliffs, NJ When you read or hear a programmer talk about the “K&R” … they mean this book! Also known as “the white book”, the C language has evolved quite a bit since the first edition was published in 1978! The second edition (1988) includes the more recent ANSI C standard definitions of the language The MPLAB C32 compiler adheres to the ISO/IEC 9899:1990 (also known as C90) standard

Online Resources This is a Wiki-book on C programming and as such it is a bit of a work in progress. It’s convenient if you don’t mind doing all your reading online. Hint: look for the chapter called “A taste of C” to find the omnipresent “Hello World!” example.