Sei sulla pagina 1di 27

Overview

Objectives
This Presentation will.
Provide an overview of the MPLAB Harmony
PIC32 Firmware Development Framework
Architecture
Installation
Key Concepts

Libraries

& State Machines


Multiple Configurations
Real-Time OS Support
Multiple Clients & Instances

Explain how the MPLAB Harmony Configuarator


(MHC) simplifies configuration and development.
2

Capabilities

Architecture
Polled
Solutions

Interrupt
Driven
Solutions

RTOS
Agnostic
Solutions

RTOS
Specific
Solutions
Free Form
RTOS

Consistent State-Machine Format

Bare-Metal

RTOS-Based

Adds

ISR Task
Processing
ISR Task
Prioritization

Adds

Multiple Polled
Task Processing
Polled Task
Prioritization

Adds

RTOS Specific
Capabilities
OS Programming
Model
3

Application(s)

Plug-in

RTOS
(Third-Party)

RTOS

O
S
A
L

Common
System
Services

System

Configuration Configuration

Plug-in

Software Framework

MPLAB Harmony Configurator (MHC)

Architecture

Driver

Middleware
Middleware

Driver

Driver

Driver

Driver

Driver

Driver

PLIB

PLIB

PLIB

PLIB

PLIB

Installation
Default Installation
Directory
Version

Specific
Windows
C:\Microchip\harmony
Mac/Linux

~/microchip/harmony
Contains all collateral
for a specific version
of MPLAB Harmony
5

Installation
Middleware Libraries

Bluetooth Stack
Cryptographic Libraries
Audio (Et. Al.) Decoders
Graphics Library
OS Abstraction Layer (OSAL)
Sample Library
TCP/IP Internet Stack
USB Host & Device Stack

Device Drivers
For Most Peripherals

System Services
For Common Resources

Peripheral Libraries
For All Peripherals
6

Applications
Application
Application Initialization

Different Parts of
an embedded
application serve
different
purposes.

Application Logic
Middleware Initialization
Middleware Logic
Peripheral Initialization
Peripheral Logic
System Initialization
System Control Logic
System Configuration

Applications
System

Framework

Application
Application Initialization
Application Logic

Middleware Initialization
Middleware Logic
Peripheral Initialization
Peripheral Logic
System Initialization
System Control Logic
System Configuration

Applications
System

Framework

System Initialization

Middleware Initialization

System Control Logic

Middleware Logic

System Configuration

Peripheral Initialization

Application
Application Initialization
Application Logic

Peripheral Logic

System &
Configuration
Code

MPLAB Harmony
Libraries

Your Application
Code

Libraries

10

Libraries
Interface

Functions
Input, Process, Output
May have Side Effects
Treated as a Black Box
Module
One or more closely related functions
Share common data or resources
Maintain state of common resources
Provides

Ability to Divide & Conquer


11

System
Configuration
system_config.h
#define
#define
#define
#define
#define
#define

APP_TMR_HW_ID
APP_TMR_HW_ID
SYS_CLK_FREQUENCY
SYS_CLK_FREQUENCY
APP_LED_BLINKING_RATE
APP_LED_BLINKING_RATE

TMR_ID_3
TMR_ID_3
0x0BEBC200
0x0BEBC200
0x0002625A
0x0002625A

system_initialize.c
#pragma
#pragma
#pragma
#pragma
#pragma
#pragma

config
config
config
config
config
config

FPLLODIV
FPLLODIV
OSCIOFNC
OSCIOFNC
ICESEL
ICESEL ==

== DIV_1,
DIV_1, FPLLMUL
FPLLMUL == MUL_20,
MUL_20, FPLLIDIV
FPLLIDIV == DIV_2,
DIV_2, FWDTEN
FWDTEN == OFF
OFF
== ON,
POSCMOD
=
HS,
FSOSCEN
=
ON,
FNOSC
=
PRIPLL
ON, POSCMOD = HS, FSOSCEN = ON, FNOSC = PRIPLL
ICS_PGx2
ICS_PGx2

void
void SYS_Initialize(
SYS_Initialize( void
void ))
{{
/*
/* Call
Call all
all library
library && application
application initialization
initialization routines
routines */
*/
}}
int
int main(void)
main(void)
{{
SYS_Initialize();
SYS_Initialize();
while(true)
while(true)
{{
SYS_Tasks();
SYS_Tasks();
}}
}}

return(EXIT_VALUE);
return(EXIT_VALUE);

system_tasks.c
void
void SYS_Tasks(
SYS_Tasks( void
void ))
{{
/*Call
/*Call all
all polled
polled library
library && app
app "Tasks"
"Tasks" routines*/
routines*/
}}

system_interrupt.c
void
void __ISR
__ISR (( _TIMER_3_VECTOR
_TIMER_3_VECTOR )) _ISR_TMR_3_stub
_ISR_TMR_3_stub (( void
void ))
{{
/*
/* Call
Call the
the timer
timer librarys
librarys interrupt
interrupt routine
routine */
*/
}}
12

Polled
Configurations
Common
Common
main()
{
while(true)
{
GFX_Tasks();

Graphics
Graphics

TCP/IP
TCP/IP

TCP_Tasks();
SPI_Tasks();
}
}

SPI
SPI

PLIB
PLIB
13

Polled
Configurations
Main
Main Loop
Loop
while(true)
{

Graphics
Graphics Library
Library

Why State
Machines?

(Draw Screen Image 200 ms)

TCP/IP
TCP/IP Stack
Stack
(Process IP Packet 100 ms)

Audio
Audio SPI
SPI Driver
Driver

Transmitter Buffer
Underflow!
14

Interrupt Driven
Configurations
Super
Super Loop
Loop
main()
{
while(true)
{
GFX_Tasks();

Graphics
Graphics

TCP/IP
TCP/IP

TCP_Tasks();
}
}

SPI
SPI
SPI
SPI 11 Interrupt
Interrupt
_SPI1_Interrupt()
{
SPI_Tasks();
}

PLIB
PLIB
15

RTOS Driven
Configurations
GFX_Thread()
{
while(true)
{
GFX_Tasks();
}
}
TCP_Thread()
{
while(true)
{
TCP_Tasks();
}
}

Graphics
Graphics

TCP/IP
TCP/IP

SPI
SPI

SPI
SPI 11 Interrupt
Interrupt
SPI1_Interrupt()
{
SPI_Tasks();
}

PLIB
PLIB
16

Task Operation
Higher

Task B calls Harmony USART driver function to


write string, blocks, because Task A called first
and gained access to shared Harmony
resource first

Task B
Task
Priority
Level

Event occurs, makes higher priority


Task B ready to run, Task A is preempted. Task A did not finish writing.

Task A

Task B
Task B blocks, Task A
resumes

Task B now resumes


running, starting it's write
operation

Task A

Lower

Time
Calls Harmony USART
driver function to write string
first

Task A

Task A resumes,
allowing write operation
to proceed

Task B

Harmony driver finishes writing to


hardware, releasing shared resource,
therefore making higher priority Task B
able to run

signed char* pTaskA_str = Hello World;

signed char* pTaskB_str = Go Rattlers!;

void Task_A_Func(void* pvParameter)


{
while(true)
{
/* Perform a specific task job */
DRV_USART_Write(UART_1_Handle,
(void*)pTaskA_str,
(size_t)(strlen(pTaskA_str)) );
}
}

void Task_B_Func(void* pvParameter)


{
while(true)
{
/*perform Harmony or application specific
task job*/
DRV_USART_Write(UART_1_Handle,
(void*)pTaskB_str,
(size_t)(strlen(pTaskB_str)));
}
}

17

OSAL Services
Multi-Thread
Safety
Multi-Thread
Synchronization
RTOS
Compatibility
OS Agnostic or
Bare Metal"
Light-weight

Semaphores

Control and
Diagnostics

Mutexes

OSAL

Critical
Sections

Memory
Allocation

18

Operating System
Abstraction Layer
Express Logic - ThreadX
tx_semaphore_get()
OSAL call maps to
RTOS API used in
application

Micrium uC/OS-III
OSAL_SEM_Pend

OSSemPend()

FreeRTOS/OPENRTOS
xSemaphoreTake()

At some point, Harmony


driver/middle-ware routine
calls OSAL_SEM_Pend()

OSAL call will block, if resource


not immediately available.
Therefore, Task XYZ will block

Task XYZ

Call returns when resource is


available, letting Task XYZ
resume

Task XYZ

Time
Calls Harmony driver or
middle-ware function

19

Multiple Clients &


Instances
Multiple Instances
USART
USART
Driver
Driver

USART 1

USART 2

Multiple Clients
TCP/IP
TCP/IP
Console
Console

File
File
System
System

Timer
Timer 11
Driver
Driver
Timer 1

Dynamic library modules can manage


multiple instances of same hardware.
Avoids duplicating library code
Simplifies application or client code
Requires use of an instance index
Multiple unrelated clients can
access common server modules.
Localizes protection &
maintenance of shared resources
Isolates clients from each other
Requires use of a client handle
20

Multiple Instances
(Static & Dynamic)

Static
SFRs

Data

Code

(RAM)

(Flash)

Instance
Instance
11

Instance
Instance
11

Instance
Instance
22

Instance
Instance
22

Instance
Instance
33

Dynamic

Instance
Instance
33

Instance
Instance
11

Instance
Instance
22

SFRs

Data

Code

(RAM)

(Flash)

Instance
Instance
11

Instance
Instance
11

Instance
Instance
22

Instance
Instance
22

Instance
Instance
33

Instance
Instance
33

Dynamic
Dynamic

Instance
Instance
33

21

Multiple Clients &


Instances
Static Multi-Client

Static Single-Client

USART
USART 22
Client
Client 11

USART
USART 11
Client
Client

SW
HW

USART
USART 11
Driver
Driver

USART
USART 22
Driver
Driver

SW
HW

USART 1

USART
USART 22
Client
Client 22

USART 2

Dynamic Multi-Client
USART
USART 11
Client
Client 11

USART
USART 11
Client
Client 22

USART
USART
Driver
Driver

SW
HW

USART
USART 22
Client
Client 33

USART 1

USART 2
22

Recap : Key Benefits

Cross-Micro Compatibility

Code Interoperability

Able to develop applications more quickly


Able to easily add features

Microchip More Responsive to Customers

Drivers and libraries work together with minimal effort


Applications port to different boards with minimal effort

Faster Time to Market

Common, consistent APIs


Easier to grow into larger parts
Easier to shrink into smaller parts

Field & Apps teams able to develop applications more quickly


Reduced support burden frees resources for new development

Improved Satisfaction

Eliminates conflicts
Improved code quality
23

Questions?

24

MPLAB Harmony
Resources

www.Microchip.com/Harmony

Download Harmony
Getting Started with MPLAB Harmony
Documentation
Release Notes
Third Party Solutions
Forum/Support
25

Thank You!

LEGAL NOTICE
SOFTWARE:
You may use Microchip software exclusively with Microchip products. Further, use of Microchip software is subject to the copyright notices,
disclaimers, and any license terms accompanying such software, whether set forth at the install of each program or posted in a header or text file.
Notwithstanding the above, certain components of software offered by Microchip and 3rd parties may be covered by open source software licenses
which include licenses that require that the distributor make the software available in source code format. To the extent required by such open
source software licenses, the terms of such license will govern.
NOTICE & DISCLAIMER:
These materials and accompanying information (including, for example, any software, and references to 3rd party companies and 3rd party websites)
are for informational purposes only and provided AS IS. Microchip assumes no responsibility for statements made by 3rd party companies, or
materials or information that such 3rd parties may provide.
MICROCHIP DISCLAIMS ALL WARRANTIES, WHETHER EXPRESS, IMPLIED, OR STATUTORY, INCLUDING ANY IMPLIED WARRANTIES OF
NONINFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE LIABLE FOR
ANY DIRECT OR INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL, OR CONSEQUENTIAL LOSS, DAMAGE, COST, OR EXPENSE OF ANY KIND
RELATED TO THESE MATERIALS OR ACCOMPANYING INFORMATION PROVIDED TO YOU BY MICROCHIP OR OTHER THIRD PARTIES,
EVEN IF MICROCHIP HAS BEEN ADVISED OF THE POSSIBLITY OF SUCH DAMAGES OR THE DAMAGES ARE FORESEEABLE.
TRADEMARKS:
The Microchip name and logo, the Microchip logo, dsPIC, FlashFlex, flexPWR, JukeBlox, KEELOQ, KEELOQ logo, Kleer, LANCheck, MediaLB,
MOST, MOST logo, MPLAB, OptoLyzer, PIC, PICSTART, PIC32 logo, RightTouch, SpyNIC, SST, SST Logo, SuperFlash and UNI/O are registered
trademarks of Microchip Technology Incorporated in the U.S.A. and other countries.
The Embedded Control Solutions Company is a registered trademark of Microchip Technology Incorporated in the U.S.A.
Analog-for-the-Digital Age, BodyCom, chipKIT, chipKIT logo, CodeGuard, dsPICDEM, dsPICDEM.net, ECAN, InCircuit Serial Programming, ICSP,
Inter-Chip Connectivity, KleerNet, KleerNet logo, MiWi, MPASM, MPF, MPLAB Certified logo, MPLIB, MPLINK, mTouch, MultiTRAK, NetDetach,
Omniscient Code Generation, PICDEM, PICDEM.net, PICkit, PICtail, RightTouch logo, REAL ICE, SQI, Serial Quad I/O, Total Endurance, TSHARC,
USBCheck, VariSense, ViewSpan, WiperLock, Wireless DNA, 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.
GestIC is a registered trademarks of Microchip Technology Germany II GmbH & Co. KG, a subsidiary of Microchip Technology Inc., in other
countries.
All other trademarks mentioned herein are property of their respective companies.
2014, Microchip Technology Incorporated, All Rights Reserved.

27

Potrebbero piacerti anche