CAE PIC1001 01 Microcontroller & MCC PIC1001 v1...A Leading Provider of Smart,Connected and Secure...

Post on 26-Aug-2021

2 views 0 download

transcript

A Leading Provider of Smart, Connected and Secure Embedded Control Solutions

CAE空中教室 PIC1001系列-01

Microcontroller & MCCPIC1001 v1.00

Mar. 11, 2021

CAE Taiwan Team

Microchip Technology Inc.

Major Course (1/3)

Microchip 16-bits Microcontroller Introduction

IDE,Compilers,MCC and Development Tools Introduction

APP041 8, 16, 32-bits General Purpose EVM Introduction

Getting Started with First ProjectLab0 First Project

GPIO ArchitectureLab1 GPIO Output

Lab2 Multi-GPIO Output

Lab3 GPIO Input and Output

Oscillator ArchitectureLab4 Clock PRIPLL

Major Course (2/3)

Interrupt ArchitectureTimer Architecture

Lab5 Timer1 Interrupt

MCCP/SCCP ArchitectureLab6 SCCP Timer Interrupt

OLED Architecture(PPS&SPI)Lab7 OLED DisplayLab8 Customize Screen

12 Bits High Speed ADC ArchitectureLab9 ADC Single ChannelLab10 ADC Multiple Channel

Major Course (3/3)

High Resolution PWM ArchitectureLab11 PWM Output

Lab12 PWM Duty Adj By ADC

Lab13 PWM Buzzer

UART ArchitectureLab14 UART Printf

Lab15 UART Communication

Microchip 16-bits Microcontroller Architecture

16-bits PIC/dsPIC® MCU series

Microchip 16-bits MCU families include below,PIC24FJ (16 MIPS)

Very high CP. Low price and high performance.PIC24HJ (40 MIPS)

Built-in DMA, upgrade performance to 40 MIPS.PIC24EP (70 MIPS)

Latest generation of PIC24 series, upgrade performance to 70 MIPS.dsPIC30F (30 MIPS)

Base on PIC24FJ, Built-in DSP.dsPIC33FJ (40 MIPS)

Base on PIC24HJ, Built-in DSP.dsPIC33EP (60 MIPS)

Built-in DSP & USB OTG, upgrade performance to 60 MIPS.dsPIC33CK (100 MIPS)

High Performance, 12-bits High Speed ADC & High-Resolution PWM.

Core Architecture

Microchip 16-bits PIC/dsPIC® MCU isHarvard architecture. This means program and data memory bus are independently.

Data Memory is 16-bits, Up to 64K Bytes.

Program Memory is 24-bits, Up to 16 M Bytes.

9

24

Program MemoryUp to 16M Bytes

16-Bits CPU(RISC)

Data MemoryUp to 64K Bytes

16

Program Memory Mapping

10

Reset Address

Interrupt Vector Table (IVT)PIC24/dsPIC30F/dsPIC33F provide two IVTs

for different situation.dsPIC33E own lots of interrupt source,

so only provide one IVT.

Application Code put here.

Configuration BitsImportant Setting for MCU,

Like System clock, WDT, Debug Interface, etc..

Build-in EEPROM (only for dsPIC30F)

0x000000

0x0001FE

0x000004

0x000200

0x800000

0xFFFFFEReserved

Configuration

Reserved

EEPROM(dsPIC30 Only)

UserProgram Memory

AlternateInterrupt Table

Interrupt Table

Reset Address

24-Bits

Data Memory Mapping

11

Unimplemented

0x0000

0x17FE

0x07FE

0x1800

0x8000

0xFFFE

Unimplemented

Y Data

X Data

SFR Space

0x0800

0x27FE

16-Bits

Ne

ar D

ata

Me

mo

ry(8

K B

yte

s)M

app

ing

to P

rogr

amM

em

ory

(P

SV)

The 8-Kbyte area is referred as thenear data space.

The 64-Kbyte area is referred as thefar data space.

X Data, Y Data area only for DSP EngineFor Dual Access Operation.

All Data is X Data area for PIC24 series.

The first 2 Kbytes are primarily occupiedwith Special Function Registers (SFRs).

0x8000 ~ 0xFFFF is mapping area for PSV use.

Machine & Instruction Cycle

TOSC(Machine Cycle) :A machine cycle consists of the steps that a computer’s processor executes whenever it receives a machine language instruction. (techopedia)

TCY(Instruction Cycle) :The basic operational process of a computer system.(wiki)

dsPIC30 Family1 TCY = 4 TOSC . ( FCY = FOSC /4) Ex:120 MHz => 30 MIPS, TCY = 33nS.

PIC24F/PIC24H/dsPIC33 Families1 TCY = 2 TOSC . ( FCY = FOSC /2)Ex:32 MHz => 16 MIPS, TCY = 62.5nS.

12

IDE, Compiler, MCC &Development Tools Introduction

All in One Development Tools

New generation Integrated Development Environment, Support PIC, sic, AVR, CEC and SAM Series MCU/MPU, Provide Plug-in function to extend more advance feature. Java Based, Cross platform, latest version is v5.45.

14

C Compiler for 16-bits PIC/dsPIC® MCU

XC16 is new generation C compiler, it’s supported all 16-bits PIC/dsPIC® MCU (PIC24F/PIC24H/PIC24E, dsPIC).Base on GNU C, apply GPL License (GNU General Public License).Provide standard C libraries (printf, strlen, etc..) and Peripheral Libraries (old versions).All version you can download from Microchip website. It’s provided free version.

15

MPLAB® Code Configurator

MPLAB® Code Configurator - MCC is a free, graphical programming environment that generates seamless, easy-to-understand C code to be inserted into your project.

Supports 8-bits, 16-bits and limited 32-bits PIC® microcontrollers.

16

MCC’s GUI Quick View

17

Resources Composer Pin Manager

MCC’s GUI Quick View

18

System clock Graphically.Configuration Word settings

are clearer and simpler.

MCC’s GUI Quick View

19

Pin assign Graphically.PPS Code generate

automatically.

MCC’s GUI Quick View

20

Interrupt assign Graphically.

ISR related code generate automatically.

MCC’s GUI Quick View

More ?www.microchip.com/mcc

21

專注學習代碼

CAE

Programmer/Debugger

The MPLAB® PICkit™ 4 In-Circuit Debugger/Programmer allows fast and easy debugging and programming of all PIC®, dsPIC®, AVR, SAM and CEC flash microcontrollers. Features

Matches silicon clocking speed.Target voltage of 1.20V to 5.5V.Can supply up to 50mA of power to the target.Minimal current consumption at <100µA from target.Portable USB-powered and RoHS-compliant.8-pin single in-line header.Backward compatible for demo boards, headers and target systems using 2-wire JTAG and ICSP.Option to be self-powered from the target (2.7V to 5.5V).

22

$57.95

Programmer/Debugger

The MPLAB® SNAP In-Circuit Debugger/Programmer allows fast and easy debugging and programming of most PIC®, dsPIC®, AVR, SAM and CEC flash microcontrollers.Features

Affordable performanceMatches silicon clocking speedTarget voltage of 1.20V to 5.5VPortable USB-poweredCE and RoHS-compliant8-pin single in-line headerBackward compatible for demo boards, headers and target systems using 2-wire JTAG and ICSP

23

$24.95

APP041 8, 16, 32-bitsGeneral Purpose EVM Introduction

8, 16, 32-bits General Purpose EVM

APP041 v3.10 is general purpose EVM, it’s support8, 16, and 32-bits 64-pins microcontroller. Built-in PIC24FJ128GB106-I/PT microcontroller at factory.

Multiply power supply available,Serial USB PortNative USB PortDC Jack (DC 9 ~ 12V)

Built-on rich components,LEDs, Buttons, Potentiometer.Temperature and Light Sensor, Buzzer, Phone Jack, MicroSD Socket.Graphic OLED Module, Character LCD Module(Optional).I2C & SPI EEPROM, DAC, ENCODE, QEI, CAN-FD Transceiver.Touch PADs, USB Serial Emulator, MikroBUS Socket.

Built-in SNAP Debugger/Programmer(optional)PIM for easy device swapping.

PIM, Plug-In Module

Rich PIMs to support different microcontroller. It’s included PIC18, PIC24, dsPIC33, PIC32MX, PIC32MZ, SAMD21, SAMD51, SAML and SAMC series.

26

Main Controller

MPLAB® SNAPDebugger/Programmer

PIC16F1455USB Serial Emulator

PIC24FJ128GB106Main Controller

Components-1

Character LCD Socket

Serial Port USB

Native USB

ICD/ICSP Connector

DC Jack (9~12V)

I2C Temperature Sensor

CAN-FD Transceiver

MikroBUS Socket

Pull High Res.

LEDsButtons

MikroBUS Socket

MicroSD Card Socket

Potentiometer

Main Voltage Select

Components-2

Character LCD Pin Select

SPI DAC

USBID Connector

I2C EEPROM

SPI EEPROM

PIC16F684(Encoder)

MCU Pin Function

Debug Pin Select

Ext. MOSFET

Encoder

8MHz Crystal

USB Pin Select

MCU Select

MUC PIM Socket

Phone Jack

Touch

Caution !

You must check all jumpers position before power on. Wrong setting will damage silicon and your power source.

Please confirm all setting shows below, It’s for dsPIC33CK256MP506.

J1 PIM

J2 3.3V

J3 J3A

J4Pin17, 18

(PGx2)

S1 ON

Plug-In Module Assembly專注學習代碼

CAE

Power On & Getting started

Just plug-in micro-USB cable to COM3 and MPLAB® SNAP then confirm power LED (SYSLED1) and ACTIVE LED on MPLAB® SNAP are light or not.

OLED/LCM will show preloaded demo firmware.

LED Must lighting !

First MCC Project

Lab Preparation

Open MPLAB X IDE v5.45 firstly.

Step 2

36

MPLAB X IDEv5.45

Double Click!

Lab Preparation

Select : Tools ► Options

Step 3

37

Lab Preparation

Select : Embedded ► Build Tools

Step 4

38

Check XC16 Compiler Version is "v1.61"

Lab Preparation

Select : Tools ► Plugins

Step 5

39

Lab Preparation

Select : Available Plugins

Search : “MCC”

Step 6 (MCC not installed yet)

40

Check MCC "v4.0.2" and install it

Lab Preparation

Select : Installed

Search : “MCC”

Step 6 (MCC has installed)

41

Check MCC Version is "v4.0.2"

Lab0 First Project

Try to create your first MPLAB X IDE Project.

Try to create your first MCC style Project.

To understanding MPLAB X IDE basic operation.

Learn how to use edit, build, project manager and program functions.

How to start ?

Lab0 First Project

Execute Project WizardSelect : File ► New Project or Click icon

Step 1

45

Lab0 First Project

Chooses Project :Categories : Microchip EmbeddedProjects : Standalone Project

Step 2

46

Lab0 First Project

Select Target Device :Family: 16-bit DSCs (dsPIC33) Device: dsPIC33CK256MP506Tool : Snap-SN : BURXXXXXXXXX

Step 3

47

dsPIC33CK256MP506

You must connectMPLAB® SNAP to PC, firstly.

Lab0 First Project

Select Compiler,Compiler Toolchains:XC16 (v1.61) [C:\Program Files\…

Step 4

Lab0 First Project

Select Project Name and Folder :Project Name : Lab0_First_ProjectProject Location : C:\Exercises

Encoding : UTF-8

Step 5

Lab0 First Project

If an old project already exist at the same location, you must delete it firstly or change to new project folder.

Notice

50

Lab0 First Project

Execute MCCMenu Tools ► Embedded ►MPLAB Code Configurator v4: Open/Close or Click

Step 6

51

Lab0 First Project

You may not see below message. Because we are already copy suitable files to .mcc folder at "Lab Preparation" section. You will saw it, if libraries not ready. Just Click OK.

Notice

52

Lab0 First Project

Save MCC Configuration File (*.mc3)Select save directory at your project folder.C:\Exercises\Lab0_First_Project.X\

Step 7

53

Please click "Save" when you open MCC at first time.

Lab0 First Project

Select least library version of MCC.Versions [MCC] ► Libraries ► … ► PIC24 / dsPIC33 / …Right click "Libraries version 1.170.0. [C:\…"Select [Mark for Load. Library built with core v5.0.2.]Left click [Load Selected Libraries]

Step 8

54

1

2

3

Lab0 First Project

If the default Package has different to the chip you are using, please change the Package for correct use.Pin Manager : Gird View ► Package ► TQFP64

Step 9

55

Lab0 First Project

Click [Generate] Button to get your first MCC Project.MCC to generate files include "main.c" automatically.

Step 10

56

Lab0 First Project

Build your first MCC Project.Select Build Main Project iconMake sure compiled result -> BUILD SUCCESSFUL

Step 11

57

Lab0 First Project

Try program compiled firmware to your target board.Select Make & Program Device Main Project iconMake sure the result is “Programming/Verify complete“

Step 12

58

Lab0 First Project

MPLAB X IDE will auto upgrade the firmware of SNAP to keep it up to date, it might take couple minutes to wait for finish. Your project will startprogramming after this.

Notice

59

Lab0 First Project

Nothing happen ????

Check Point

61

Trademarks

The Microchip name and logo, the Microchip logo, dsPIC, KeeLoq, KeeLoq logo, MPLAB, PIC,PICmicro, PICSTART, PIC32 logo, rfPIC and UNI/O are registered trademarks of Microchip Technology Incorporated in the U.S.A. and other countries.FilterLab, Hampshire, HI-TECH C, Linear Active Thermistor, MXDEV, MXLAB, SEEVAL and The Embedded Control Solutions Company are registered trademarks of Microchip Technology Incorporated in the U.S.A.Analog-for-the-Digital Age, Application Maestro, CodeGuard, dsPICDEM, dsPICDEM.net, dsPICworks, dsSPEAK, ECAN, ECONOMONITOR, FanSense, HI-TIDE, In-Circuit Serial Programming, ICSP, Mindi, MiWi, MPASM, MPLAB Certified logo, MPLIB, MPLINK, mTouch, Octopus, Omniscient Code Generation, PICC, PICC-18, PICDEM, PICDEM.net, PICkit, PICtail, REAL ICE, rfLAB, Select Mode, Total Endurance, TSHARC, UniWinDriver, WiperLock and ZENA are trademarks of Microchip Technology Incorporated in the U.S.A. and other countries.SQTP is a service mark of Microchip Technology Incorporated in the U.S.A.All other trademarks mentioned herein are property of their respective companies.© 2010, Microchip Technology Incorporated, Printed in the U.S.A., All Rights Reserved.

Thank You !!

62