Presentation is loading. Please wait.

Presentation is loading. Please wait.

ECE 3567 Microcontroller Lab

Similar presentations


Presentation on theme: "ECE 3567 Microcontroller Lab"— Presentation transcript:

1 ECE 3567 Microcontroller Lab
Lecture 2 Project Demo, Embedded C, MSP430FR6989 Architecture Autumn 2018 Dr. Gregg Chapman

2 ECE 3567 Microcontroller Lab
Project Demo

3 Project Set-up Open Code Composer Studio version 7.2.0
Select a Workspace on your U: drive Select File  New  CCS Project In the CCS Project window set Target to MSP430FRxxx and select MSP430FR6989 Enter the Project Name and click Finish Select File  New  Source File Enter Code Save the File Select Project  Rebuild Project At this point it is essential to connect the hardware Make sure that the Project is selected as [Active – Debug] Select the Debug ICON Once the GREEN ARROW comes up you can run the code Halt execution with the RED SQUARE

4 Transferring a Project to a New Location
You must do two things before your project will function normally Change the Workspace Update the path for the Include Options under the Complier settings

5 Change Workspace Select  File  Switch Workspace  Other
Enter the new workspace. Always select the file ABOVE your Project file that CCS created. When you select OK, Code Composer will restart

6 Change Include Options
Select Project  Properties Go to Include Options under MSP430 Compiler You will need to add the proper path to all three of the following : “U:\<your path>\<your project name.\driverlib“ “U:\<your path>\<your project name.\driverlib\MSP430FR5xx_6xx“ “U:\<your path>\<your project name.\driverlib\MSP430FR5xx_6xx\inc“ Use the ICON to add a path When finished, click OK

7 Code Composer Studio Common Error Messages
ERROR: Unable to Launch. The selection cannot be launched, and there are no recent launches Solution: Switch Workspace : File => Switch Workspace => Other Always select the folder that is ONE LEVEL ABOVE your project folder as the workspace. ERROR: Cannot open source file “driverlib.h” Solution: Change the paths to the following folders - 1. Right click the project set as [Active-Debug] and open Properties 2. Under MSP430 Compiler options, select Include Options 3. Delete old paths to driverlib Add ALL THREE new paths: …/ driverlib …/ driverlib/MSP430FR5xx_6xx …/ driverlib/MSP430FR5xx_6xx/inc

8 Code Compilation and Execution
Compile Debug Run Stop

9 Terminal Window View  Terminal
Click on the ICON to launch the terminal. The Launch Terminal window should open: Choose the Serial Terminal to switch to the proper settings The pulldown menu for Port should list the available COM ports. If these end up not working you will have to resort to the process on the following slide to discover the COM ports If not already the default settings, select: Baud Rate – 9600, Data Bits – 8, Parity – None, Stop Bits – 1, Flow Control – None, Timeout – 5 secs, Encoding - Default (ISO ) Select OK

10 The CCS Com Terminal Each lab computer uses numerous COM ports. Before you activate the Terminal in CCS, you must identify an available COM port. To do this outside of the CCS Terminal: type CMD in the search window to bring up the Command Line prompt type MODE and write down the communication port numbers that are available (e.g. COM12, COM3) Close the Command window

11 Communication When you run the ECE 3567 Project program, You should receive the following message from the ECE 3567 software after the next RESET: ECE 3567 Microcontroller Lab Please enter a Command Code: You can test the transmit with valid two character commands, which must be capitalized. If they are not, you will receive: UNKNOWN COMMAND Please enter the next Command Code: For now, a valid command code will only respond with: Please enter the next Command Code: The command: TE should work You will add function to these codes throughout the semester

12 Watch Window Note that there is not a dynamic debugger for the LaunchPad. Expressions and Variables are only updated after a Breakpoint is reached. Select View  Expressions Right click to add registers or variable names.

13 Breakpoints Double click the line number to set a breakpoint
You must re-compile to incorporate the breakpoint Click twice more to clear a breakpoint

14 Embedded C Programming
ECE 3567 Microcontrollers Embedded C Programming

15 Embedded C It is C, but does NOT conform to common software practice due to all the # compiler directives and header files. It relies extensively on #defines and #typedefs located in included HEADER files (.h) in order to make low level manipulation of the hardware much easier than assembly language. NOTE: this also makes the C program look “funny” to software engineers. It is hardware dependent, particularly constant and variable sizes. If unsure of a constant or variable size use sizeof() to find out!

16 Embedded C REAL WORLD ADVICE ON EMBEDDED PROGRAMMING:
NEVER write from the ground up. COPY and MODIFY working source code. Be careful of COPYWRITES. ALWAYS use the HEADER files from the MCU manufacturer. Use an Evaluation Board for development if possible. If not, these usually come with schematics that give you a good idea of what is required to get your MCU “off the ground”. UNDERSTAND THE HARDWARE! Read the Datasheet, at least for the modules that you are using. Initialization is MORE THAN HALF of the project. Write the initialization for each MCU sub-device (module) as a SEPARATE function.

17 Embedded C REAL WORLD ADVICE ON EMBEDDED PROGRAMMING:
The main.c should consist of the following, in this order: A DETAILED DESCRIPTION in comment format #includes (esp. xxx.h files) and compiler directives Calls to INITIALIZATION FUNCTIONS The MAIN LOOP consisting almost entirely of function calls Interrupt Service Routines if applicable

18 Embedded C EXAMPLES: P1OUT = 0x01;
Sets bit zero on the output of PORT 1, but clears the other 7 bits. the P1OUT and it’s address are defined in a header file. P1OUT |= BIT0; Bitwise ORs PORT 1 with BIT0 (0x01 or b), setting the LS bit of PORT 1 and preserving the other 7 bits in their original state. P1OUT &= ~BIT0; Bitwise ANDs PORT 1 with NOT BIT0 (0xFE or ), clearing the LS bit of PORT 1 and preserving the other 7 bits in their original state.

19 The MSP430FR6989 Microcontroller Architecture
ECE 3567 Microcontrollers The MSP430FR6989 Microcontroller Architecture

20 The MSP430FR6989 Microcontroller Architecture

21 The MSP430FR6989 Microcontroller Architecture
Timers: TA0 – ISR, Command, USCI_A0 TA1 – ADC12, USCI_A1 TB0 – PWMs


Download ppt "ECE 3567 Microcontroller Lab"

Similar presentations


Ads by Google