You are on page 1of 21

MSP432 Deep-dive Lab Manual

Contents
MSP432 Deep-dive Lab Manual .............................................................................................................................. 1
Set-Up MSP432 platform .................................................................................................................................... 2
Lab 1 Power System Lab .................................................................................................................................. 5
Lab 2 Clock System Lab .................................................................................................................................... 8
Lab 3 Memory Lab............................................................................................................................................ 9
Lab 4 ADC14 Lab............................................................................................................................................. 10
Lab 5 Software Lab ......................................................................................................................................... 11
Lab 6 Platform Porting Lab............................................................................................................................. 13

Set-Up MSP432 platform


1. Open up your MSP432 Deep-dive lab box. You should find the following:
The MSP432 LaunchPad
One Micro-USB cable
Educational BoosterPack MK II Board
2. Initial Board Set-Up
a. Using the micro-USB cable, connect the LaunchPad to a free USB port on your PC.

CCS IDE
MSP432P401R LaunchPad
micro-USB cable

MSP432P401 LaunchPad

b. For the labs that need to use the BoosterPack MK II, connect the Educational BoosterPack MK II to
the LaunchPad.

MSP432P401R
LaunchPad

BoosterPack
MK II

Note: A PCs USB port is capable of sourcing up to 500 mA for each attached device, which is sufficient for
the evaluation board. If connecting the board through a USB hub, it must usually be a powered hub. The
drivers should install automatically.

3. Run the training lab


a. Open the Code Composer Studio v6.1 (make sure you installed the MSPware support package).
b. Open the MSPWare in TI Resource Explorer. Click and Import the specific lab project in MSPWare-->
Devices--> MSP432P4xx-->Training-->Deep Dive Training.

c. Run the lab.


Note: for all labs that require you to complete the code, all missing code lines are marked with #error symbol,
building an incomplete project will reveal all missing code lines as errors.

Lab 1 Power System Lab


This lab exercises different power states available on the MSP432P401R. At each power state, the device is
also configured to operate at the respective maximum operating frequency. When running the project on the
LaunchPad, the program will start up in default mode AM_LDO_VCORE0. Push button P1.1 can be used to
cycle to the next power mode. Different LED colors and blink counts indicate the power state transition.
1. Import the lab lab1_power
Open the MSPWare in TI Resource Explorer of CCS. Click and Import the specific lab project in MSPWare-->
Devices--> MSP432P4xx--> Training--> Deep Dive Training--> Lab 1: Power
There are 3 source files in the project:
- lab1_power.c is the main function file
- lab1_power_startup_ccs.c is the startup file for lab 1
- lab1_power_solution.c is the reference solution for lab 1, excluded from build by default
This project includes MSP432 DriverLib source code. This will allow you to browse through and examine
the implementation of the API.
2. Insert your code
Click the View Menu to open the TI Resource Explorer. Find the Driver Library API Programmers Guide in
MSPWare. You can choose the modules with the necessary APIs.

Using the MSP432 DriverLib, determine the correct API to use to change the device power state. Insert
your code at line 94-150 in the main loop of lab1_power.c to change to the specific power mode.
5

Hints:
- The same API is used for all cases. You can copy and paste the API and simply change the function
parameter.
- The valid power mode transitions can be found in the Power Mode Selection Summary in Table 6-1 of
the User's Guide.

3. Build, download, and run the project on the LaunchPad


Build and download the project, and run on the LaunchPad. Then, push the button P1.1. The P1.0 LED will
blink different colors to indicate the power state transition.

4. Debug with EnergyTrace+


Enable EnergyTrace+ while debugging Lab 1. Observe the power/current change each time the device
enters a new power mode. Notice the all the high-current spikes are due to the LED toggling to indicate
state change.

Do the current consumptions for various power modes on your device match with the datasheet numbers?
Keep in mind the measurement unit here is power (mW) based on a 3V source.

Take away:
a.
b.
c.
d.
e.
f.

1st look at MSPWare featuring MSP432 DriverLib and Training


Get familiar with MSP432 device power modes
Evaluate different MSP432 power states
Exercise MSP432 DriverLib API to change power state
First look at MSP432 Interrupt usage
Debug with EnergyTrace+

Lab 2 Clock System Lab


This lab exercises different MSP432 DCO clock frequencies. DCO cycles through different DCO clock
frequencies in active mode. A SysTick interval is configured to wake up and toggle the LED P1.0 output.
Different LED toggling rate indicates a change in DCO clock frequency.
1. Import the lab lab2_clock
Open the MSPWare in TI Resource Explorer of CCS. Click and Import the specific lab project in MSPWare-->
Devices--> MSP432P4xx--> Training--> Deep Dive Training--> Lab 2: Clock
There are 3 source files in the project:
- lab2_clock_system.c is the main function file
- lab2_clock_system_startup_ccs.c is the startup file for lab 2
- lab2_clock_system_solution.c is the reference solution for lab 2, excluded from build by default
2. Insert your code
Line 109: Add MSP432 DriverLib API to configure MCLK to run from DCO with divider = 1.
Line 118: Add API to configure DCO to the 1.5MHz Center Frequency by either using the DriverLib
definition CS_DCO_FREQUENCY_1_5 or frequencyCycle[0] (0th option of the frequency array).

Line 128: Add API call to change DCO to the next Centered Frequency frequencyCycle[curFrequency].

3. Build, download, and run the project on the LaunchPad


Build and download the project, and run on the LaunchPad. Then, push the button P1.1. The P1.0 LED will
blink at different rates, indicating the change of DCO setting.

Take away:
a.
b.
c.
d.

Get familiar with MSP432 device clock system


Exercise device at different clock frequencies
Learn how to use MSP432 DriverLib APIs to configure the clock system
Notice the inter-peripheral dependencies of core modules at high-speed

Lab 3 Memory Lab


Learn how to manipulate Flash and SRAM memories using DriverLib in this lab. Part 1 of the lab demonstrates
Flash operations including protecting/unprotecting sectors, erasing, and programming flash. Part 2 of the lab
demonstrates SRAM feature to disable and enable SRAM banks to optimize current consumption.
Note: We are not using the Memory Protection Unit (MPU) module in this lab.
1. Import the lab lab3_memory
Open the MSPWare in TI Resource Explorer of CCS. Click and Import the specific lab project in MSPWare-->
Devices--> MSP432P4xx--> Training--> Deep Dive Training--> Lab 3: Memory
There are 4 source files in the project:
- lab3_memory.c is the main function file
- lab3_memory_startup_ccs.c is the startup file for lab 3
- msp432p401rpz_MODIFIED_SRAM.cmd is the customized linker command file relocating the STACK to
SRAM bank 0
- lab3_memory_solution.c is the reference solution for lab 3, excluded from build by default
2. Insert your code
Flash operations
Lines 20&21: Set flash wait state to 2 for both banks 0 and 1 (use MSP432 DriverLib Flash API)

Lines 56&57: Erase flash sector and verify (use MSP432 DriverLib Flash API)

Line 70: Re-protect Flash Sector 0 with a DriverLib Flash API

SRAM operation
Line 115: Use DriverLib SysCtl API to disable SRAM banks 4 through 7

3. Build, download, and run the project on the LaunchPad


Set breakpoints at lines 44, 61, and 73 to check flash memory content during flash operation. Set
breakpoints at lines 99 and 126 to validate SRAM bank operations.

Take away:

a. Exercise various Flash and SRAM DriverLib APIs


b. Notice the Flash protection, erase, and program sequence
c. Examine the customized linker command file, notice SRAM and STACK relocation, and consideration for
SRAM enhancement feature
9

Lab 4 ADC14 Lab


Learn how to configure the new and enhanced ADC14 module and perform ADC conversion in this lab.
Additionally, the lab also exercises Timer_A and GPIO operations using direct register access. The Educational
BoosterPack MK IIs joystick is used as the analog input (A15) for the ADC14 module. Set up in single
conversion mode, the ADC14 is periodically triggered for a conversion. Conversion result is conditioned and
used as the duty cycle for the Timer_As PWM output channel on a port pin connected to an LED.
Note: We will strictly use register-access code (no DriverLib API at all) for this lab.
1. Set-up the BoosterPack MK II
2. Import the lab lab4_adc14
Open the MSPWare in TI Resource Explorer of CCS. Click and Import the specific lab project in MSPWare-->
Devices--> MSP432P4xx--> Training--> Deep Dive Training--> Lab 4: ADC14
There are 4 source files in the project:
- lab4_adc14.c is the main function file
- lab4_adc14_startup_ccs.c is the startup file for lab 4
- lab4_adc14_solution.c is the reference solution for lab 4, excluded from build by default
- lab4_adc14_bonus_buzzer.c is a bonus application to drive the buzzer, excluded from build by default
3. Insert your code
Using the direct register accesses code of general MSP432, insert your code at lines 106 and 108 of
lab4_adc14.c to configure ADC14 and enable ADC conversion complete interrupt.

Insert your code at line 141 for the ADC14 interrupt service routine.

4. Build, download, and run the project on the LaunchPad


Build and download the project, and run on the LaunchPad. Move the joystick on the BoosterPack and the
brightness of LED on BoosterPack should change accordingly to indicate the ADC14 conversion results.

Take away:

a. Get familiar with MSP432 device ADC14 module


b. Learn how to use direct register accesses code to configure ADC14
c. Learn how to use direct register access code to enable external interrupt in ARM NVIC module

10

Lab 5 Software Lab


In this software lab you will learn how to use different software solutions provided for MSP432. The goal is
this lab is to convert the register-access code in Lab 4 ADC 14 to use DriverLib APIs. Use the provided lab 5
code file as the starting point and fill in the missing code lines with appropriate DriverLib API calls.
Notes:
- Keep Lab 4 CCS project open to compare and contrast the use of register-access versus DriverLib APIs.
- Use Ctrl+Space auto-complete feature to quickly find the right API.
- Use Ctrl+Click on the API name to find more information about the API and its required parameters.
- DriverLib Users Guide amd API Guide are available from MSPWare as quick reference on specific
DriverLib API calls.
The final application, if implemented correctly, should be identical to lab 4: sampling ADC14 channel A15 and
using ADC results to drive the Timer_As (TA2CCR1) PWM output.
If lab is completed early, proceed to the bonus lab to convert the same register-access code from Lab 4 to
code using CMSIS-style peripheral definitions.
1. Set-up the BoosterPack MK II
2. Import the lab lab5_software
Open the MSPWare in TI Resource Explorer of CCS. Click and Import the specific lab project in MSPWare-->
Devices--> MSP432P4xx--> Training--> Deep Dive Training--> Lab 5: Software
There are 4 source files in the project:
- lab5_software_driverlib.c is the main function file
- lab5_software_startup_ccs.c is the startup file for lab 5
- lab5_software_driverlib_solution.c is the reference solution for lab 5, excluded from build by default
- lab5_software_cmsis_homwork.c is another main function file to be a homework using ARM CMSIS
intrinsic, excluded from build by default
3. Insert your code
Line 92: Using the MSP432 DriverLib ADC14 API, configure P6.0 as ADC14 input channel

Line 110: Configure ADC14 conversion memory 0, using channel A15, VCC reference

Line 122: Enable ADC14MEM0 conversion completion interrupt


Line 130: Enable ADC14 interrupt in ARMs NVIC interrupt module

Line 150: Get ADC14 conversion result

11

4. Build, download, and run the project on the LaunchPad


Build and download the project, and run on the LaunchPad. Move the joystick on the BoosterPack and the
brightness of LED on BoosterPack should change accordingly to indicate the ADC14 conversion results.

Take away:
a.
b.
c.
d.
e.

Get familiar with MSP432 devices ADC14 and interrupt


Learn how to use MSP432 DriverLib APIs to configure ADC14 and interrupt
Learn how to use MSP432 DriverLib to configure the ARM NVIC for the external interrupts
Get familiar with the ARM CMSIS style code for MSP432
Make educated assessment, comparison, trade-off, and porting effort between different software
styles/techniques/solutions

Bonus:

The lab5_software_cmsis_homwork.c is a bonus project to learn how to use ARM CMSIS style code and CMSIS
intrinsic for MSP432. Compare CMSIS version with the MSP432 DriverLib APIs code and the MSP430
traditional direct register-access code style.

Quiz: List pros/cons/comments for each of the software solutions.


Traditional MSP Register-Access:
DriverLib APIs:
CMSIS:

12

Lab 6 Platform Porting Lab


You will achieve two goals in this lab:
- Learn to create a new MSP432 project in CCS, and set up your application following the step-by-step
instructions for this lab. You will also learn how to set up the ARM startup file to register your interrupt
handlers.
- Learn all the necessary steps to port an existing MSP430 project to MSP432 using different types of
software/coding style.
This lab requires the use of an MSP430 project source file lab6_platform_porting_msp430f5529.c, which you
can use as the starting point reference. After creating a new MSP432 project from scratch, copy over the
lab6_platform_porting_msp430f5529.c file and update the MSP430 code lines with either appropriate
DriverLib API calls or register-access code to see how code differs between MSP platforms and take note on
the migration step.
1. Set-up the BoosterPack MK II
2. Import the lab lab6_platform_porting for reference and a lab solution
Open the MSPWare in TI Resource Explorer of CCS. Click and Import the specific lab project in MSPWare-->
Devices--> MSP432P4xx--> Training--> Deep Dive Training--> lab6_platform_porting
There are 4 source files in the project.
- The lab6_platform_porting.c is the main function file
- The msp432_startup_ccs.c is the startup file for lab 6
- The lab6_platform_porting_solution.c is the solution for lab 6
- The lab6_platform_porting_msp430f5529.c is the MSP430 code reference of the migration,
excluded from build by default
3. Create your MSP432 project and set up application
1) Create a new empty CCS project with device MSP432P401R and named lab6

13

2) Setup the DriverLib source and include options (this step is a temporary step for the training lab).
a. Copy the DriverLib source folder from imported project lab6_platform_porting to lab6

b. Add the following DriverLib Include Options to Properties (under Project) for lab6
- "${workspace_loc:/${ProjName}/driverlib}"

14

3) Set the emulator to the used Texas Instruments XDS110/XDS-ET USB Emulator

4) Copy the existing MSP430 code lab6_platform_porting_msp430f5529.c to project lab6

4. Modify the existing MSP430 code


Step 1: Change header file names
1) msp430.h --> msp432.h
2) All DriverLib header files are now combined into one: "driverlib.h"

Step 2: Change MCLK_FREQUENCY


1) Change the MCLK_FREQUENCY to 48MHz

15

Step 3: Core system including power, clock, and memory will require new code, as new platform has
different requirements
1) Change Voltage Core Level to 1 (MSP432 has 2 core levels)

2) Change flash memory wait state to 2

3) Change system DCO frequency to 48MHz

4) Enable SRAM bank rententions in LPM3 mode

Step 4: Configure Timer_A


1) Check if all of Timer_A and GPIO code is compatible on MSP432
a. GPIO setup should be modified for different device
The PM_TA0.3 should be set and ported to P2.2 of MSP432P401 (the blue LED on the MSP432).

b. Check and confirm that Timer_A configuration is compatible on MSP432


Note: We were able to reuse the same Timer_A Capture & Compare Register (TA0CCR3) from
the MSP430F5529 due to the flexibility of the Port Map module, allowing us to configure and
use TA0CCR3 on port pin P2.2.
Step 5: Configure RTC
1) Check if all of the RTC code is compatible on MSP432
2) Don't forget the extra NVIC step to enable interrupt
a. Configure RTC
The RTC is a different module on MSP432. Modify the RTC configuration code for new device.

16

b. Enable RTC interrupt in NVIC. This is for ARM core interrupt standard process.

Step 6: ADC12 update to ADC14; this will require some API updates
1) Does the GPIO API work?
2) We will use 14-bit resolution for MSP432, so change resolution setting
3) Any change in the ADC14_Init function?
4) Any change in the ADC14_setupSamplingTimer?
5) Any change in the ADC14_memoryConfigure?
6) What about interrupts?
7) What about NVIC?
a. Configure GPIOs

b. Change resolution setting


c. ADC14 init
d. Configuring ADC Memory

e. Enable the interrupt

f. Enable ADC14

Step 7: Enter LPM3, Enable interrupts

17

Step 8: Double-check application code for compatibility


The result of ADC14 conversion is 14 bit; different from MSP430F5529. Modify the algorithm and
parameters.
1) Retrieving ADC14 memory results

2) Map the x -axis accelerometer results to PWM duty cycles

Steps 9 & 11: #pragma vector support for MSP432 is still under work
1) Remove #pragma vector and __interrupt
2) Insert the ADC and RTC ISR stub into the interrupt vector table inside the msp432_startup_ccs.c
a. Remove the #pragma vector and __interrupt before the ADC and RTC ISR

b. Add external declarations for the interrupt handlers used by the application inside the
msp432_startup_ccs.c

c. Change from the defaultISR interrupt handlers to the ADC and RTC interrupt handlers into the
interrupt vector table in the msp432_startup_ccs.c

Step 10: ADC14 interrupt handler


1) Option 1: Use ADC14 DriverLib API
Option 2: If using ADC14 register access code, note that ADC14 has a clear interrupt flag register that
requires writing 1, instead of clearing the bit
2) Use SLEEPONEXIT feature of MSP432 instead of the __bic_SR_register_on_exit() intrinsic
a. Clear the ADC14 IFG when running into the ADC14 interrupt handler
b. Use SLEEPONEXIT feature or Interrupt_disableSleepOnIsrExit() API to wake up from ISR

18

Step 12: RTC interrupt handler


1) Double-check the ISR handler for RTC
2) ADC12 API might need some updates, too
a. Clear RTC pre-scaler event interrupt flag

b. Triggering the start of the ADC14 sample sequence

c. Go back to sleep

5. Build, download, and run the project on the LaunchPad


Build and download the project, and run on the LaunchPad. Then, tilt the board in all x directions. The red,
green, and blue LEDs should blink to indicate movement.

Take away:

a. Learn how to create a new MSP432 application step by step


b. Learn how to migrate the code from MSP430 to MSP432
c. Assess and evaluate the migration effort for different software solutions (register-access, DriverLib,
interrupts, intrinsics.)
Homework:
Please try to add the y (P4.0) and z (P4.2) directions to the Red (P2.0) and Green (P2.1) LEDs. You will need
to add new Timer and ADC channels, as well as additional application code in main loop.

19

DriverLib APIs:

MSP432 Software Cheat Sheet [1]

PCM_setPowerState();
PCM_shutdownDevice();
PCM_gotoSleep();
PCM_gotoDeepSleep();
PSS_enableHighSide();
PSS_setHighSidePerformanceMode();

Module_enableInterrupt(); //Substitute Module with actual Module Name


Interrupt_enableInterrupt();
Interrupt_enableMaster();
Interrupt_disableSleepOnIsrExit();
CS_setDCOFrequencyRange(); set DCO to a calibrated frequency
CS_initClockSignal() initialize clock signal sources
CS_startHFXT() start high-frequency crystal (normal/bypass mode)
CS_startLFXT() start low-frequency crystal (normal/bypass mode)
CS_getACLK() returns ACLK frequency (in Hz)
CS_getMCLK() returns MCLK frequency (in Hz)

FlashCtl_protectSector()
FlashCtl_isSectorProtected()
FlashCtl_eraseSector()
FlashCtl_performMassErase()
FlashCtl_programMemory() program flash memory with data buffer
FlashCtl_setWaitState() required for flash operation @ CPU > 16MHz
SysCtl_enableSRAMBank(); enable SRAM bank(s)
SysCtl_disableSRAMBank(); disable SRAM bank(s)
SysCtl_enableSRAMBankRetention(); retain SRAM content in DSL
SysCtl_disableSRAMBankRetention(); does not retain content in DSL

GPIO_setAsOutputPin(); Configure output pin


GPIO_setAsInputPin(); Configure input pin
GPIO_setAsPeripheralModuleFunctionOutputPin();
GPIO_setOutputHighOnPin();
GPIO_getInputPinValue();
GPIO_enableInterrupt();

20

MSP432 Software Cheat Sheet [2]

DriverLib APIs [2]:

TimerA_startCounter ()
TimerA_configureContinuousMode ()
TimerA_configureUpDownMode ()
TimerA_initCapture ()
TimerA_generatePWM ()
TimerA_setCompareValue()
TimerA_getCaptureCompareCount()
TimerA_clearTimer()

SysTick_enableModule()
SysTick_setPeriod()
SysTick_getValue()
Timer32_setCount()
Timer32_getValue()
Timer32_startTimer()
WDT_holdTimer()
WDT_initWatchdogTimer()
WDT_initIntervalTimer()

ADC14_enableModule();
ADC14_setResolution ();
ADC14_configureSingleSampleMode ();
ADC14_configureMultiSequenceMode();
ADC14_enableConversion();
ADC14_enableComparatorWindow();

MSP432 & ARM Intrinsics:

Open msp430dna.h and msp432_cmsis.h for complete listing


__sleep()
__deep_sleep()

OR

__WFI()

__no_operation()
__enable_interrupts()
__disable_interrupts()

OR
OR
OR

__nop()
__enable_irq()
__disable_irq()

OR

__wfi()

__low_power_mode_off_on_exit()

21