msp432™ mcus training part 9: porting between msp430 and msp432 1 code compatibility register...

10
MSP432™ MCUs Training Part 9: Porting between MSP430 and MSP432 1 Code Compatibility Register Access & DriverLib Interrupt Intrinsics

Upload: bonnie-page

Post on 23-Dec-2015

240 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: MSP432™ MCUs Training Part 9: Porting between MSP430 and MSP432 1 Code Compatibility Register Access & DriverLib Interrupt Intrinsics

MSP432™ MCUs TrainingPart 9: Porting between MSP430 and MSP432

1

Code CompatibilityRegister Access & DriverLibInterrupt Intrinsics

Page 2: MSP432™ MCUs Training Part 9: Porting between MSP430 and MSP432 1 Code Compatibility Register Access & DriverLib Interrupt Intrinsics

MSP Platform PortabilityM

SP

430

MS

P432

MSP430 Modules

MSP 16-bit core

430

MSPWare

Register-Level

DriverLibrary

430

MSP Debugger

LaunchPad

BoosterPacks

Target Board

BSL

ULP Tools: ULP Advisor & EnergyTrace

IAR IDE

Energia

CCS IDE

GCC

CMSIS

ARM Modules

New MSP432 Modules

ARM M4F 32-bit core

432

ARM

432

ARM Keil

ULP Tools: ULP Advisor & EnergyTrace+

Intrinsics & Interrupts

New for MSP432Same as MSP430

Slight modifications from MSP430

430 430

MSPWareRegister-

LevelDriverLibrary

Libraries

Libraries

Intrinsics & Interrupts

RTOSs

Hardware SoftwareDevelopment

ToolsDevelopment

Kits

Page 3: MSP432™ MCUs Training Part 9: Porting between MSP430 and MSP432 1 Code Compatibility Register Access & DriverLib Interrupt Intrinsics

Porting | Code CompatibilityModule C-code DriverLib Recommendation

CORE SYSTEM

Core/CPU New New msp430dna.h, intrinsic support available

Power New New Develop new code using DriverLib APIs

CS New New Develop new code using DriverLib APIs

Flash & RAM New New Develop new code using DriverLib APIs

NVIC New New Develop new code using DriverLib, CMSIS, or MSP432 intrinsics

ISR Small changes Small changes Special consideration for flag clearing & power modes when entering/exiting ISRs

Intrinsics Some MSP430 intrinsics supported on MSP432

msp430dna.h converts applicable ones, helps guide through changing non-compatible ones to msp432/CMSIS intrinsics

MSP430

Digital: Timer_A, eUSCI, GPIO, AES

100% Portable 100% Portable Port existing code, check & verify data types.

ADC14 Portable, new registers added

Portable, new APIs added

Port existing code, update code utilizing new features (14-bit, flag check, etc.), check & verify data types.

COMP_E, REF 100% Portable 100% Portable Port existing code, check & verify data types.

AES, CRC 100% Portable 100% Portable Port existing code, check & verify data types.

ARM

DMA New New Use DriverLib APIs

Timer32 New New, similar to TivaC

Simple modules: use C-code, DriverLib, or CMSIS

SysTick New New, similar to TivaC

Simple modules: use C-code, DriverLib, or CMSIS

Application Code Take care of data types (16-bit, 32-bit, native int, signs, etc.) Try to use explicit C99 types (uint32_t) if possible.

• Header file definitions, register names, bits compatible to MSP430• Existing register-access code compatible on MSP432• MSP430 DriverLib APIs  also compatible on MSP432• See interrupt/NVIC component below for specific interrupt changes.• Double-check if code has specific data-type (16-bit vs. 32-bit)

requirements• New core system configuration code required.• No need to develop code from scratch: take advantage of DriverLib

APIs and example to quickly configure and bring up system• Utilize new core features such as DC-DC, tunable DCO, dual flash

banks, SRAM bank controls, etc. • CPU: check native data types, different code execution

deterministic due to 3-stage pipeline

• Existing applicable MSP430 intrinsics usable on MSP432• Non-compatible MSP430 intrinsics are detected & guided to convert

to MSP432 intrinsics• CMSIS core intrinsic functions also available.

• Register access code available, but DriverLib APIs recommended for complex module such as DMA

• DriverLib APIs Similar to Tiva C DriverLib APIs• CMSIS register definitions compatible with other ARM devices.

Page 4: MSP432™ MCUs Training Part 9: Porting between MSP430 and MSP432 1 Code Compatibility Register Access & DriverLib Interrupt Intrinsics

Porting | Direct Register Access

MSP430

MSP432

Page 5: MSP432™ MCUs Training Part 9: Porting between MSP430 and MSP432 1 Code Compatibility Register Access & DriverLib Interrupt Intrinsics

Porting | DriverLib I2C Master Initialization

MSP430

MSP432

Page 6: MSP432™ MCUs Training Part 9: Porting between MSP430 and MSP432 1 Code Compatibility Register Access & DriverLib Interrupt Intrinsics

Porting | CMSIS Support

• CMSIS-style device header file – msp432_cmsis.h

• CMSIS core header files – Supplied from ARM – Provide intrinsic/instruction support

• CMSIS DSP & Math library

6

Page 7: MSP432™ MCUs Training Part 9: Porting between MSP430 and MSP432 1 Code Compatibility Register Access & DriverLib Interrupt Intrinsics

Porting | MSP430 DNA & Intrinsic Support• Enabled using msp430dna.h & CMSIS standard library• Intrinsic functions:

– __no_operation();– Low-power mode intrinsics– Stack pointer, registers, etc.– __delay_cycles(); Supported in CCS

• Incompatible intrinsics are detected & recommended for MSP432 replacement– Detects all incompatibility– Guides developers through replacement & migration

7

Page 8: MSP432™ MCUs Training Part 9: Porting between MSP430 and MSP432 1 Code Compatibility Register Access & DriverLib Interrupt Intrinsics

Porting | Interrupts Declaration on MSP432

8

Option 1: Declare the entire Interrupt Vector table

Option 2: MSP430 methodUse #pragma vector

msp

432_s

tart

up_c

cs.c

#pragma vector = USCI_B0_VECTOR__interrupt void USCI_B0_ISR(void){ switch(__even_in_range(UCB0IV,12)) { case 0: break; ……}

//All unused interrupts trapped#pragma vector = unused_interrupts__interrupt void intDefaultHandler(void){ //trap}

1. MSP430 code re-use2. Interrupt vector & handler function defined together

ISR Handlers: stubs defined in table. Treated as regular function, code in user’s application

Page 9: MSP432™ MCUs Training Part 9: Porting between MSP430 and MSP432 1 Code Compatibility Register Access & DriverLib Interrupt Intrinsics

Porting | Interrupts Usage on MSP432

9

Individual module

interrupt sources

Module interrupt

vector in NVIC

NVIC Master Interrupt

Reset

TimerA

Port6. .

RTC

SysTickReady INTAlarm INT

Pre-scale T0Pre-scale T1

Event INTOsc. Fault

RTC interrupt sources

Interrupt Event

1. Enable module interrupt sources2. Enable module interrupt in NVIC3. Enable NVIC Master Interrupt

RTCPS1CTL |= RT1PSIE; SCS_NVIC_ISER0 = INT_RTC_BIT;

__enable_interrupt();

Extra step for MSP432

Page 10: MSP432™ MCUs Training Part 9: Porting between MSP430 and MSP432 1 Code Compatibility Register Access & DriverLib Interrupt Intrinsics

Porting | Interrupts Usage on MSP432

10

Individual module

interrupt sources

Module interrupt

vector in NVIC

NVIC Master Interrupt

Reset

TimerA

Port6. .

RTC

SysTickReady INTAlarm INT

Pre-scale T0Pre-scale T1

Event INTOsc. Fault

RTC interrupt sources

Interrupt Event

1. Enable module interrupt sources2. Enable module interrupt in NVIC3. Enable NVIC Master Interrupt

RTC_enableInterrupt( RTC_CLOCK_READ_READY_INTERRUPT | RTC_CLOCK_ALARM_INTERRUPT | RTC_PRESCALE_TIMER1_INTERRUPT);

Interrupt_enableInterrupt(INT_RTC);

Interrupt_enableMaster();

Extra step for MSP432