ECE 3740 SEP1: MPLAB Introduction and LED Blinking. An Introduction to Microchip's MPLAB IDE and

Similar documents
An Introduction to Microchip's MPLAB IDE and an Example Application: LED Blinking

Configuration of Device Specific Features

MPLAB XC32 USER S GUIDE FOR EMBEDDED ENGINEERS. MPLAB XC32 User s Guide for Embedded Engineers INTRODUCTION

PIC32MX150F128 Breakout Board

Quickstart. Chapter 1

chipkit MX3 is the new name for Cerebot MX3. This board retains all functionality of the Cerebot MX3.

Section 33. Device Configuration (Part II)

Section 42. Oscillators with Enhanced PLL

Section 9. Watchdog Timer and Power-up Timer

Table of Contents Overview Functional Description Programming Tools... 4

#pragma config Usage. #pragma config Settings. #pragma config <setting>=<named value>

Part 1: Introduction to the C Language

Section 32. High-Level Device Integration

MPLAB Harmony Help - MPLAB Harmony Overview

Doc: page 1 of 34

MPLAB Harmony Help - MPLAB Harmony Configurator User's Guide

MPLAB Harmony Configurator User's Guide

Section 7. Oscillator

Section 7. Oscillator

Table of Contents Contents Abstract... 3 Executive Summary... 4 Introduction... 5 Motivation... 5 Implementation... 5 ADPCM Algorithm...

PIC32 DEVELOPMENT. A Design Project Report. Presented to the School of Electrical and Computer Engineering. of Cornell University

Section 7. Oscillator

Embedded Systems Module. 6EJ505. C Tutorial 3: using the ICD3 rev tjw

MPLAB XC16 USER S GUIDE FOR EMBEDDED ENGINEERS. MPLAB XC16 User s Guide for Embedded Engineers INTRODUCTION

Microchip 18F4550 Interface, Signal conditioning, USB, USB- RS-232, 16x2 LCD Interface

Infinity Project. an additional memory for GLCD where to store programs. July Infinity Project. Additional memory for GLCD by Tony, i2tzk Pag.

ECE383: Microcomputers Lab 6 Basic and Finite State Machine LED and Switch I/O Programming

Table of Contents COMPANY PROFILE 1-1 SECTION 1. INTRODUCTION 1-1

MPLAB Harmony Help - MPLAB Harmony Tutorial: Creating an Application

ET-PIC 24 WEB-V1. o Central Processing Unit (CPU) o System. o nanowatt Power Managed Modes. o Analog Features

F²MC-8FX FAMILY MB95200H/210H SERIES HOW TO USE DBG PIN 8-BIT MICROCONTROLLER APPLICATION NOTE

F²MC-8FX FAMILY MB95200H/210H SERIES HOW TO USE DBG PIN 8-BIT MICROCONTROLLER APPLICATION NOTE

Section 29. Device Configuration Bits

Getting Started with the Texas Instruments ez430

An Introduction to Designing Ham Radio Projects with PIC Microcontrollers. George Zafiropoulos KJ6VU

MPLAB XC16 USER S GUIDE FOR EMBEDDED ENGINEERS. MPLAB XC16 User s Guide for Embedded Engineers INTRODUCTION

Hibernation Module. Introduction. Agenda

PIC18F2XJXX/4XJXX FAMILY

University of Hawaii EE 361L MPLab Quick Tutorial and Project 2.1 Last updated September 1, 2011

Section 10. Watchdog Timer and Power Saving Modes

Using Code Composer Studio IDE with MSP432

Introduction. Prerequisites: Procedure Steps. Step1: Downloading and Adding the MCC Plugin

Section 28. WDT and SLEEP Mode

MT2 Introduction Embedded Systems. MT2.1 Mechatronic systems

Section 9. Watchdog Timer (WDT) and Power-Saving Modes

Embedded Systems. PIC16F84A Internal Architecture. Eng. Anis Nazer First Semester

MPLAB Harmony System Service Libraries Help

Development board for PIC24FJ128GA010. with 262k TFT color LCD module

MPLAB SIM. MPLAB IDE Software Simulation Engine Microchip Technology Incorporated MPLAB SIM Software Simulation Engine

Microcontroller Overview

Microprocessors B Lab 1 Spring The PIC24HJ32GP202

Introduction to Microcontroller Apps for Amateur Radio Projects Using the HamStack Platform.

CHAPTER 1 - World of microcontrollers

Lecture 1: Introduction to Microprocessors

MPLAB Harmony Help - System Service Libraries

SISTEMI EMBEDDED. The C Pre-processor Fixed-size integer types Bit Manipulation. Federico Baronti Last version:

Manual of Board ET-PIC STAMP 18F8722-K22 ET-PIC STAMP 18F8722-K22

Lesson 14. Title of the Experiment: Introduction to Microcontroller (Activity number of the GCE Advanced Level practical Guide 27)

ECE372 CodeWarrior Simulator Andreou/Michaelides

Prefetch Cache Module

ASF4 API Reference Manual

Introducing the 32 bit Micro Experimenter

Section 9. Watchdog Timer (WDT)

M16C R8C FoUSB/UART Debugger. User Manual REJ10J

ASF4 API Reference Manual

PPC Multicore example with Cosmic Tools:

Midrange 8b PIC Microcontrollers. ECE Senior Design 14 February 2017

Release Notes for MPLAB Code Configurator v2.25.1

ET-BASE AVR ATmega64/128

Laboratory: Introduction to Mechatronics

MPLAB C18 C Compiler

SISTEMI EMBEDDED. The C Pre-processor Fixed-size integer types Bit Manipulation. Federico Baronti Last version:

AN-8205 AMC Library Hall Interface Summary AMC Introduction

SISTEMI EMBEDDED. The C Pre-processor Fixed-size integer types Bit Manipulation. Federico Baronti Last version:

1 Introduction to Computers and Computer Terminology Programs Memory Processor Data Sheet... 4

ME 333: Introduction to Mechatronics

Embedded Systems and Software

Creating a New USB project with KSDK and Processor Expert support in KDS

ecog1kg Microcontroller Product Brief

MASTERs 2012 LAB Manual for 1658 BTL Bootloading, Application Mapping and Loading Techniques on PIC32. Table of Contents

Basic Embedded Software C Review Using MPLAB SIM. Loops. Embedded Systems Interfacing. 25 August 2011

5xx Active & Low Power Mode Operation

1 Introduction to Computers and Computer Terminology Programs Memory Processor Data Sheet Example Application...

PIC-LCD-3310 development board Users Manual

M16C/62P QSK QSK62P Plus Tutorial 1. Software Development Process using HEW4

Generating PWM on LPCXpresso - LPC1769

Introduction to Microchip-SIMULINK Blocksets and MATLAB Plug-in for MPLAB IDE

Explanation of PIC 16F84A processor data sheet Part 2: More on the PIC

Microcomputers. C and Embedded Systems

Engineer-to-Engineer Note

F 2 MC-8FX Family. 8-bit Microcontroller. MB95200 Series

Basic C Programming (2) Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island

MPLAB C1X Quick Reference Card

MICROPROCESSOR BASED SYSTEM DESIGN

Engineer-to-Engineer Note

Table of Contents Overview Software Support... 6 Coursework and Additional Materials Programming the Board...

Code Composer Studio. MSP Project Setup

PIC16F87X. 28/40-pin 8-Bit CMOS FLASH Microcontrollers. Devices Included in this Data Sheet: Pin Diagram PDIP. Microcontroller Core Features:

Experiment 9: Using HI-TECH C Compiler in MPLAB

Interconnects, Memory, GPIO

Transcription:

ECE 3740 SEP1: MPLAB Introduction and LED Blinking An Introduction to Microchip's MPLAB IDE and an Example Application: LED Blinking 1

Objective Rotate LEDs 2

Port Functions Library Help >Help Contents >Search: Port Functions PORTClearBits Function PORTRead Function PORTReadBits Function PORTResetPins Function PORTSetBits Function PORTSetPinsAnalogIn Function PORTSetPinsAnalogOut Function PORTSetPinsDigitalIn Function PORTSetPinsDigitalOut Function PORTToggleBits Function PORTWrite Function 3

PORTSetPinsDigitalOut FUNCTION Description Configures selected pins as digital outputs Input Parameters Description portid Enumerated PORT Identifier see ports.h Example MASK: Identifies which bits are to be configured as digital outputs: 1100 0000 PORTSetPinsDigitalOut(IOPORT_C, BIT_7 BIT_6); IO Port ID OR Operator 4

ports.h C:\Program Files (x86)\microchip\xc32\v1.33\pic32mx\include\peripheral typedef enum { #ifdef _PORTA IOPORT_A, #endif #ifdef _PORTB IOPORT_B,... #endif #ifdef _PORTG IOPORT_G, #endif IOPORT_NUM }IoPortId; #define BIT_31 (1 << 31) #define BIT_30 (1 << 30) #define BIT_29 (1 << 29) #define BIT_28 (1 << 28) #define BIT_27 (1 << 27) #define BIT_26 (1 << 26) #define BIT_25 (1 << 25) #define BIT_24 (1 << 24)... #define BIT_4 (1 << 4) #define BIT_3 (1 << 3) #define BIT_2 (1 << 2) #define BIT_1 (1 << 1) #define BIT_0 (1 << 0) 5

Complete MPLAB Project Led Blinking V1 main.c #include <plib.h> // include file required by all projects // Entire file is included at this point // Configuration Bits #pragma config FNOSC = PRIPLL // Oscillator Selection #pragma config FPLLIDIV = DIV_2 // PLL Input Divider #pragma config FPLLMUL = MUL_20 // PLL Multiplier #pragma config FPLLODIV = DIV_1 // PLL Output Divider #pragma config FPBDIV = DIV_1 // Peripheral Clock divisor #pragma config FWDTEN = OFF // Watchdog Timer #pragma config WDTPS = PS1 // Watchdog Timer Postscale #pragma config FCKSM = CSDCMD // Clock Switching & Fail Safe Monitor #pragma config OSCIOFNC = OFF // CLKO Enable #pragma config POSCMOD = XT // Primary Oscillator #pragma config IESO = OFF // Internal/External Switch-over #pragma config FSOSCEN = OFF // Secondary Oscillator Enable #pragma config CP = OFF // Code Protect #pragma config BWP = OFF // Boot Flash Write Protect #pragma config PWP = OFF // Program Flash Write Protect #pragma config DEBUG = ON // Debugger Enabled #pragma config ICESEL = ICS_PGx1 // Page 3 of 34: Cerebot_MX7cK_rm.pdf // CPU clock #define SYS_FREQ (80000000) 6

Complete MPLAB Project Led Blinking V1 main.c (Continued) int main(void) { // Start of main() function SYSTEMConfig(SYS_FREQ, SYS_CFG_ALL); //See <system.h> PORTSetPinsDigitalOut(IOPORT_G, BIT_12); //Set pin connected to LED1 as output PORTSetPinsDigitalOut(IOPORT_G, BIT_13); //Set pin connected to LED2 as output PORTSetPinsDigitalOut(IOPORT_G, BIT_14); //Set pin connected to LED3 as output PORTSetPinsDigitalOut(IOPORT_G, BIT_15); //Set pin connected to LED4 as output PORTClearBits(IOPORT_G, BIT_12); PORTClearBits(IOPORT_G, BIT_13); PORTClearBits(IOPORT_G, BIT_14); PORTClearBits(IOPORT_G, BIT_15); // LED1 off // LED2 off // LED3 off // LED4 off // Continued on next slide 7

Complete MPLAB Project Led Blinking V1 while(1) { unsigned int i; PORTSetBits(IOPORT_G, BIT_12); for(i = 0; i < 1000000; i++); PORTClearBits(IOPORT_G, BIT_12); PORTSetBits(IOPORT_G, BIT_13); for(i = 0; i < 1000000; i++); PORTClearBits(IOPORT_G, BIT_13); PORTSetBits(IOPORT_G, BIT_14); for(i = 0; i < 1000000; i++); PORTClearBits(IOPORT_G, BIT_14); PORTSetBits(IOPORT_G, BIT_15); for(i = 0; i < 1000000; i++); PORTClearBits(IOPORT_G, BIT_15); } } //End of main() function() // LED1 on // Delay some time // LED1 off // LED2 on // Delay some time // LED1 off // LED3 on // Delay some time // LED1 off // LED4 on // Delay some time // LED4 off 8

Project Modularization A project can be made more modular Object Oriented manner Easier to maintain Easier to read and debug Easier to manage Encapsulate similar items into their own file C files that do certain function and that function only Include files (*.h) files that contain certain code of definitions 9

Modular MPLAB Project Project was split into 3 C files main.c PortIO.c SysInit.c And 3 h files (include files) PICConfig.h PortConfig.h SysConfig.h Project 1.1: Figure out how I did the modularization, and implement it. 10

Configuration Management Project 1 has three parts, therefore: P1: P1.1, P1.1, and P1.3 P1.1 has two parts: therefore, P1.1.1 and P1.1.2 11

Configuration Management P1.1.1 has two versions: therefore, P1.1.1\v1 and P1.1.1\v2 12

Creating Folder for v2 For each major change, create a new MPLAB project and leave the old one untouched. Example: you want to change LED Blinking v1 to create modularized version v2 Using the OS: Create a new folder: v2 Using MPLAB: Create a new MPLAB project in that folder: v2, and name the project LEDBlinkingMod Using the OS: Copy the main.c file from the v1 folder to the v2 folder Using MPLAB: Include this v2\main.c file in your new project, and start making your edits. 13

Configuration Management Note: For project P1.1.2 The initial copy of the stack should not be changed. The first step is to save the original Stack, as shown in folder TCPIPStackOrg Using the OS: make a folder v1 under P1.1.2. Then, copy and paste TCPIPStack from TCPIPStackOrg to v1, as shown. TCPIPStackOrg should never be modified. The idea is to make a copy of the original stack, and work on that copy. If, for any reason, the application of the updates does not go as intended, you can always revert to the original stack distribution and start from there. Last working copy 14

What Should Not Be Changed Never change the Compiler s files!!! 15