deep dive training

Upload: jose-carlos-cazarin-filho

Post on 28-Feb-2018

249 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/25/2019 Deep Dive Training

    1/21

    1

    MSP432 Deep-dive Lab Manual

    ContentsMSP432 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

  • 7/25/2019 Deep Dive Training

    2/21

    2

    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-Upa. Using the micro-USB cable, connect the LaunchPad to a free USB port on your PC.

    CCS IDE

    micro-USB cable

    MSP432P401 LaunchPad

    MSP432P401R LaunchPad

  • 7/25/2019 Deep Dive Training

    3/21

    3

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

    the LaunchPad.

    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.

    MSP432P401R

    LaunchPad

    BoosterPack

    MK II

  • 7/25/2019 Deep Dive Training

    4/21

    4

    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 #errorsymbol,

    building an incomplete project will reveal all missing code lines as errors.

  • 7/25/2019 Deep Dive Training

    5/21

    5

    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.

  • 7/25/2019 Deep Dive Training

    6/21

    6

    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 willblink different colors to indicate the power state transition.

  • 7/25/2019 Deep Dive Training

    7/21

    7

    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. 1st

    look at MSPWare featuring MSP432 DriverLib and Training

    b.

    Get familiar with MSP432 device power modes

    c.

    Evaluate different MSP432 power states

    d. Exercise MSP432 DriverLib API to change power state

    e. First look at MSP432 Interrupt usage

    f.

    Debug with EnergyTrace+

  • 7/25/2019 Deep Dive Training

    8/21

    8

    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: ClockThere 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 orfrequencyCycle[0] (0thoption of the frequency array).

    Line 128: Add API call to change DCO to the next Centered FrequencyfrequencyCycle[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. Get familiar with MSP432 device clock system

    b.

    Exercise device at different clock frequencies

    c.

    Learn how to use MSP432 DriverLib APIs to configure the clock system

    d. Notice the inter-peripheral dependencies of core modules at high-speed

  • 7/25/2019 Deep Dive Training

    9/21

    9

    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. Setbreakpoints 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

  • 7/25/2019 Deep Dive Training

    10/21

    10

    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 moduleb.

    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

  • 7/25/2019 Deep Dive Training

    11/21

    11

    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

  • 7/25/2019 Deep Dive Training

    12/21

    12

    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 devices ADC14 and interrupt

    b.

    Learn how to use MSP432 DriverLib APIs to configure ADC14 and interruptc.

    Learn how to use MSP432 DriverLib to configure the ARM NVIC for the external interrupts

    d. Get familiar with the ARM CMSIS style code for MSP432

    e. 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:

  • 7/25/2019 Deep Dive Training

    13/21

    13

    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 youcan use as the starting point reference. After creating a new MSP432 project from scratch, copy over the

    lab6_platform_porting_msp430f5529.cfile 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

  • 7/25/2019 Deep Dive Training

    14/21

    14

    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}"

  • 7/25/2019 Deep Dive Training

    15/21

    15

    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

  • 7/25/2019 Deep Dive Training

    16/21

    16

    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.

  • 7/25/2019 Deep Dive Training

    17/21

    17

    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

  • 7/25/2019 Deep Dive Training

    18/21

    18

    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.ca. 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 theinterrupt 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 SLEEPONEXITfeature of MSP432 instead of the__bic_SR_register_on_exit()intrinsica.

    Clear the ADC14 IFG when running into the ADC14 interrupt handler

    b.

    Use SLEEPONEXITfeature or Interrupt_disableSleepOnIsrExit()API to wake up from ISR

  • 7/25/2019 Deep Dive Training

    19/21

    19

    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 needto add new Timer and ADC channels, as well as additional application code in main loop.

  • 7/25/2019 Deep Dive Training

    20/21

    20

    MSP432 Software Cheat Sheet [1]

    DriverLib APIs: 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();

  • 7/25/2019 Deep Dive Training

    21/21

    21

    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.hand msp432_cmsis.hfor complete listing

    __sleep() OR __WFI() OR __wfi()

    __deep_sleep()

    __no_operation() OR __nop()

    __enable_interrupts() OR __enable_irq()

    __disable_interrupts() OR __disable_irq()

    __low_power_mode_off_on_exit()