Home
Lab Exercise
Contents
1. step over icon When ready to continuously run the program click on the resume icon or hit F8 in the Debug pane to allow the program to continuously run Challenge Remove the if else statement see results Challenge Change from button 1 to button 2 To accomplish this you would need to refer to the LaunchPad Evaluation Board and the Orbit Schematics There is a quick cheat sheet at the end of this tutorial that will provide ports and pins lab activity Attachment 1 Main c file EEE EEE EEE LEE EEE EEE TEE EEE eese tet eek be Project Orbit Lab 4 ATE Blink Version 1 0 Date 2 20 2013 Author Brian Zufelt Craig Kief Company COSMIAC UNM Comments This code shows how to use the Orbit daughter card It will allow the user to control the state of the LEDs based on state of the buttons and switches FERRE RR EK EE EE EE EE ER EEK EE ER ER EE A EEK KEK KKK KKK KK Chip type ARM TM4C123GH6PM Program type Firmware Core Clock frequency 80 000000 MHz TOIISESORDIOETOROIOROIOTOEGIONSEOECEGIOIEOEGEGIOFSEGORSESEOR IOEOESEGIORSEGECIGRORUE SIOETIESEOIUEHORAIUE include lt stdbool h gt include lt stdint h gt include inc tm4c123gh6pm h include inc hw ints h include inc hw memmap h include inc hw types h include driverlib sysctl h include driverlib interrupt h include driverlib gpio h include driverlib timer h void main void 1 Setting the internal clock SysCtlClockSet
2. TI ARM Lab 4 National Digilent Orbit Board Introduction and LEDs Science Foundation Funded in part by a grant from the National Science Foundation DUE 1068182 Acknowledgements Developed by Craig Kief Brian Zufelt and Jacy Bitsoie at the Configurable Space Microsystems Innovations amp Applications Center COSMIAC Co Developers are Bassam Matar from Chandler Gilbert and Karl Henry from Drake State Funded by the National Science Foundation NSF Lab Summary This lab is very similar to the third lab but it is accomplished using the Digilent Corporation s Orbit daughter card This card was built for academic purposes for learning how to do small projects with a pathway to more complex projects and can be found as a combination with the Tiva board on the Digilent website Lab Goal The goal of this lab is to continue to build upon the skills learned from previous labs This lab helps the student to continue to gain new skills and insight on the C code syntax and how it is used in the TI implementation of the ARM processor with the addition of a daughter board Each of these labs add upon the previous labs and it is the intention of the authors that they will build with each lab a better understanding of the ARM processor and basic C code Even though these tutorials assume the student has not entered with a knowledge of C code it is the desire that by the time the student completes the entire series of tutorials that they will have a
3. sufficient knowledge of C code so as to be able to accomplish useful projects on the ARM processor Learning Objectives The student should continue to become familiar with the complier and understand the use and modification of a main c file The student should also begin to be exposed to C functions In addition the Digilent Orbit board is introduced in this tutorial This board provides expanded capabilities to the Tiva platform for doing more and varied projects during the workshop At the simplest level it provides additional LEDs switches and buttons Grading Criteria N A Time Required Approximately one hour Lab Preparation It is highly recommended that the student read through this procedure once before actually using it as a tutorial By understanding the final goal it will be easier to use this as a tutorial and as a learning guide This lab creates the entire project from scratch Equipment and Materials Access to Tiva TM4C123G LaunchPad software and evaluation kit EK RM4C123GXL as well as the Digilent Orbit board It is assumed that the student has already completed Lab 3 and the software is installed properly Ensure that the boards are plugged in before start of the tutorial Software needed The software requirements from Lab 3 are still applicable here lab activity G Hardware needed The hardware required is the TI Tiva LaunchPad Kit and the Digilent Corporation s Orbit Daughter card Addi
4. use the Orbit daught ontrol t 9 Thi er card 10It will allow the user to control the state of the LEDs 11based on state of the buttons and switches JA 3OCRORORGORAURRUERGUEROORAUERUUORRUOR GUERRE RUE AUGE UE EROR EUR EGO OR EUER E 15 Chip type ARM LM44F120H5QR 16 Prog Firmware 16 Program type 17 Core Clock frequency 80 000000 MHz JR kde desk ok sk sk e se ese ke oe desk oe de oe e oe ee ee dese e de oe dee ee e eee ee ede ee eee ede M 7 4 m3 ad 9 o J types h e driverlib sysctl h Cee E S RR Y El Console 2i ATE Lab4 KORTEX M4 6 GEL Output Initialization Complete CORTEX M4 0 GEL Output Watchdog Timer Enabled CORTEX M4 8 GEL Output UARTs Enable Figure 10 Program Compiled What has now happened is that the executable file has been loaded into the microcontroller and has halted the program at void main void which is the start of your program Using the mouse rearrange the desktop to look like Figure 10 This will make it easier to see all the components as the program executes hndow Help r ue AT 33 Debug 33 0i gi SaD eli amp ATE Lab4 Code Composer Studio Device Debugging gi Stellaris In Circuit Debug Interface CORTEX M4 0 Suspended HW Bre maint at main c 29 Qx00000260 c int00 Ox000008BA c int O has only skeletal debug info Figure 11 Run Executable There are now several options The designer can step line by line through the program by clicking on the yellow
5. As shown in Figure 8 if the button is pushed we write outputs to all the LEDs First we write 1s and then after a little delay time we write Os This is repeated until the button is released Now it is possible to compile the program create the executable and run the program mom ium Uo uni Das ok n ols Window Help Figure 9 Debug Icon Click on the debug icon shown in Figure 9 Save changes to main c if prompted The program will then compile the code create and executable file and place it into the microcontroller lab activity Se CCS Debug ATE_Lab4 main c Code Composer Studio c 4 File Edit View Project Run Scripts Tools Window Help mid Hse e tv i ger gt Project Explorer 23 ajet Debug 23 oe 3 3 0 K Sr 569 60 Variables 23 6f Expressions sto Registers tS ATE Lab4 V9 ATE Lab4 Code Composer Studio Device Debugging Name Type Value i Binaries af Stellaris In Circuit Debug Interface CORTEX M4 0 Suspended HW Breakpoint rs Includes main at main c 29 0x0000026C Debug _c_int00 0x000008BA _c_int00 has only skeletal debug info Im4f120h5qr cmd main c startup ccs c 2 Stellaris LM4F120H5QR cexml Active eas i LED D TI Resource Explorer main c main c 33 startup ccs c oject Orbit Lab 4 ATE 1 0 2 20 2013 hor Brian Zufelt Craig Kief pany COSMIAC UNM nts his code shows how to
6. SYSCTL SYSDIV 5 SYSCTL USE PLL SYSCTL XTAL 16MHZ SYSCTL OSC MAIN Enable Peripheral ports for input output SysCtlPeripheralEnable SYSCTL PERIPH GPIOC PORTC GPIOPinTypeGPlIOOutput GPIO PORTC BASE GPIO PIN 6 GPIO PIN 7 LED 1 LED 2 SysCtiPeripheralEnable SYSCTL PERIPH GPIOB PORTB GPIOPinTypeGPlOOutput GPIO PORTB BASE GPIO PIN 5 LED 4 SysCtiPeripheralEnable SYSCTL PERIPH GPIOD PORT D GPIOPinTypeGPlOOutput GPIO PORTD BASE GPIO PIN 6 LED 3 GPIOPinTypeGPlOInput GPIO PORTD BASE GPIO PIN 2 BTN 1 SysCtiPeripheralEnable SYSCTL PERIPH GPIOF PORT F GPIOPinTypeGPlOOutput GPIO PORTF BASE GPIO PIN 1 GPIO PIN 2 GPIO PIN 3 RGB LED on Launchpad SysCtlPeripheralEnable SYSCTL_PERIPH GPIOA PORT A GPIOPinTypeGPlOInput GPIO PORTA BASE GPIO PIN 6 Switch 2 while 1 if GPIOPinRead GPIO PORTA BASE GPIO PIN 6 Listen for the switch GPIOPinWrite GPIO PORTF BASE GPIO PIN 1 GPIO PIN 2 GPIO PIN 3 4 LED Blue on Launchpad Cycle through the LEDs on the Orbit board GPIOPinWrite GPIO PORTC BASE GPIO PIN 6 GPIO PIN 7 0x40 LED 1 on LED 2 Off GPIOPinWrite GPIO PORTD BASE GPIO PIN 6 0x00 LED 3 off Note different PORT GPIOPinWrite GPIO PORTB BASE GPIO PIN 5 0x00 LED 4 off SysCtiDelay 2000000 Delay Replaces for LOOP Launchpad else lab activity GPIOPinWrite GPIO PORTC BASE GPIO PIN 6 GPIO PIN 7 0x80 LED 1 OFF LED 2 on SysCtIDelay 2000000 D
7. d clean the code is that what was used before What can be seen is if the switch two left hand on orbit board is thrown write to the LEDs on port F However not all the LEDs are being written to As can be seen in line 58 the three LEDs on the Tiva board are OR d together This is very similar to what is accomplished on line 61 Realize that 4 is the same as Ox4 in hex If you hover over GPIO_PIN_1 you can see that the register value is 2 0010 Green is 4 and blue is 8 Thus to turn the light white R G and B on it is necessary to change the 4 to an 11 or OxOE lab activity Another item to notice is the use of the SysCtlDelay function This is much cleaner than the massive for loop used in previous labs 111 while GPIOPinRead GPIO PORTD BASE GPIO PIN 2 1 Listen for BTN 1 112 113 All LED Blink 114 GPIOPinWrite GPIO PORTC BASE GPIO PIN 6 GPIO PIN 7 axFF 115 GPIOPinWrite GPIO PORTD BASE GPIO PIN 6 OxFF 11 GPIOPinWrite GPIO PORTB BASE GPIO PIN 5 8x20 117 GPIOPinWrite GPIO PORTF BASE GPIO PIN 1 GPIO PIN 2 GPIO PIN 3 xFF White Output 130 119 SysCtlDelay 2000000 12 121 GPIOPinWrite GPIO PORTC BASE GPIO PIN 6 GPIO PIN 7 0x00 122 GPIOPinWrite GPIO PORTD BASE GPIO PIN 6 0x00 123 GPIOPinWrite GPIO PORTB BASE GPIO PIN 5 0x00 124 GPIOPinWrite GPIO PORTF BASE GPIO PIN 1 GPIO PIN 2 GPIO PIN 3 0x00 White Output 125 126 SysCtlDelay 2000000 Figure 8 Blinky Lights
8. ects Lab 3 accomplished much of what needed to be accomplished through a very brute force methodology The ARM chip has thousands of functions built into it for making code cleaner and more efficient The key to remember when working with the ARM processor is that it is ultimately designed to be highly efficient and to be able to operate for months at a time on batteries To accomplish this the device is virtually powered down when it is turned on The device has a series of ports that then connect to external devices such as UARTS and I2C busses EVERY TIME that a new project is started the first thing than must be done is to first enable the ports and then set up the pins lab activity Enable Peripheral ports for input output SysCtlPeripheralEnable SYSCTL_PERIPH GPIOC PORTC GPIOPinTypeGPIOOutput GPIO PORTC BASE GPIO PIN 6 GPIO PIN 7 LED 1 LED 2 SysCtlPeripheralEnable SYSCTL PERIPH GPIOB PORTB GPIOPinTypeGPIOOutput GPIO PORTB BASE GPIO PIN 5 LED 4 SysCtlPeripheralEnable SYSCTL PERIPH GPIOD PORT D GPIOPinTypeGPIOOutput GPIO PORTD BASE GPIO PIN 6 LED 3 GPIOPinTypeGPIOInput GPIO PORTD BASE GPIO PIN 25 BIN 1 SysCtlPeripheralEnable 5YSCTL PERIPH GPIOF PORT F GPIOPinTypeGPIOOutput GPIO PORTF BASE GPIO PIN 1 GPIO PIN 2 GPIO PIN 3 RGB LED on Launchpad SysCtlPeripheralEnable 5YSCTL PERIPH GPIOA PORT A GPIOPinTypeGPIOInput GPIO PORTA BASE GPIO PIM 6 Switch 2 Figure 6 Enabling Po
9. elay Replaces for LOOP GPIOPinWrite GPIO PORTC BASE GPIO PIN 6 GPIO PIN 7 0x00 LED 1 off LED 2 off GPIOPinWrite GPIO PORTD BASE GPIO PIN 6 0x40 LED 3 on SysCtIDelay 2000000 Delay Replaces for LOOP GPIOPinWrite GPIO PORTD BASE GPIO PIN 6 0x00 LED 3 off GPIOPinWrite GPIO PORTB BASE GPIO PIN 5 0x20 LED 4 on SysCtiDelay 2000000 Delay Replaces for LOOP GPIOPinWrite GPIO PORTF BASE GPIO PIN 1 GPIO PIN 2 GPIO PIN 3 8 LED Green on Cycle through the LEDs on the Orbit board GPIOPinWrite GPIO PORTC BASE GPIO PIN 6 GPIO PIN 7 0x00 LED 1 off LED 2 Off GPIOPinWrite GPIO PORTD BASE GPIO PIN 6 0x00 LED 3 off Note different PORT GPIOPinWrite GPIO PORTB BASE GPIO PIN 5 0x20 LED 4 on SysCtiDelay 2000000 Delay Replaces for LOOP GPIOPinWrite GPIO PORTB BASE GPIO PIN 5 0x00 LED 4 off GPIOPinWrite GPIO PORTD BASE GPIO PIN 6 0x40 LED 3 on SysCtiDelay 2000000 Delay Replaces for LOOP GPIOPinWrite GPIO PORTC BASE GPIO PIN 6 GPIO PIN 7 0x80 LED 1 OFF LED 2 on GPIOPinWrite GPIO PORTD BASE GPIO PIN 6 0x00 LED 3 off SysCtiDelay 2000000 Delay Replaces for LOOP GPIOPinWrite GPIO PORTC BASE GPIO PIN 6 GPIO PIN 7 0x40 LED 1 on LED 2 Off SysCtiDelay 2000000 Delay Replaces for LOOP while GPIOPinRead GPIO PORTD BASE GPIO PIN 2 Listen for BTN 1 All LED Blink GPIOPinWrite GPIO PORTC BASE GPIO PIN 6 GPIO PIN 7 OxFF GPIOPi
10. ill a user ever really understand how to do projects For the sake of this activity the source code is provided at the end of the tutorial In Lab 4 open main c Then either type in all the code from attachment 2 or copy and paste in the code from Attachement 2 into main c lab activity Project Explorer 23 amp amp HD O Getting Started l main c 23 i Lab 2 1 SESTESESTESESESESSESESSESSESTETESSSSESSSTTESESSSESSESSSSESTTSTST 9 Lab 3 2 f 4 1 Lab 4 Active Debug 3 Project Orbit Lab 4 ATE Blink P Binaries 4Version 1 0 5 Date 2 20 2013 BP Includes 6Author Brian Zufelt Craig Kief Debug 7Company COSMIAC UNM targetConfigs 8 Comments main c 9This code shows how to use the Orbit daughter card tm4c123gh6pm startup ccs c 101It will allow the user to control the state of the LEDs b tm4c123gh6pm cmd E on state of the buttons and switches t Lab 5 lt 5 Lab 6 1 4L OEOOROOROR RO RO ROEOROEOROE RR OR OR IOROIOROOROOROEOROKO REO REO REO RoRookolorororolorooror iS Lab 7 15Chip type ARM TM4C123GH6PM 9 Lab 8 16Program type Firmware 15 Lab 9 17Core Clock frequency 80 000000 MHz 18 KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKKEK 19 20 include stdbool h 21 amp include stdint h 22 include inc hw ints h 23 include inc hw memmap h 24 include inc hw types h 25 include driverlib sysctl h 26 include driverlib interrupt h 27 include drive
11. nWrite GPIO PORTD BASE GPIO PIN 6 OxFF GPIOPinWrite GPIO PORTB BASE GPIO PIN 5 0x20 GPIOPinWrite GPIO PORTF BASE GPIO PIN 1 GPIO PIN 2 GPIO PIN 3 OxFF White Output SysCtlDelay 2000000 GPIOPinWrite GPIOPinWrite GPIOPinWrite GPIOPinWrite GPIO PORTC BASE GPIO PIN 6 GPIO PIN 7 0x00 GPIO PORTD BASE GPIO PIN 6 0x00 GPIO PORTB BASE GPIO PIN 5 0x00 GPIO PORTF BASE GPIO PIN 1 GPIO PIN 2 GPIO PIN 3 0x00 White Output Qe o Amm SysCtlDelay 2000000 10 lab activity G lab activity Attachment 2 Block Diagram of the Pins Used in Projects ri 2 2 402 2 21 2 Pin Number 7 6 5 3 7 1 O CORE Hex Binany 0 0o 020 0 06 0 PAT Part A Pin 7 To energize send Ox80 PA ORX IN CIRCUIT DEBUGGER HB L3 GPIO A PA ITX ICD LP 5 onBITSW2 EH DL ORBIT SW 1 C PB ORBIT LED 4 WEC PB 3 t 54k O od PB 2 ACCEL Device ID x1D GPIO C PCO ORBITLED 1 WR OKSA PC7 ORBITLED 2 RD Ox3B GPIO D PD6 ORBITLED 3 ORBIT PD2 ORBIT BTN 1 GPIO E PEO ORBIT BTN 2 PFO Tiva Launch pad BTN 2 PFI Tiva Launchpad LED RED PF2 Tiva Launchpad LED BLUE PF3 Tiva Launchpad LED GREEN Pra Tiva Launchpad BTN 1 11 12 lab activity G
12. rlib gpio h 28 include driverlib timer h 30 31 void main void Setting the internal clock 34 SysCt1ClockSet SYSCTL_SYSDIV_5 SYSCTL_USE_PLL SYSCTL_XTAL_16MHZ SYSCTL_OSC_MAIN Figure 5 Header Files Shown in Figure 5 is a collection of header files Header files contain all the functions that you will need to have available to do any project with the device From here until the end of time you should include these nine header files in every project that you do with this device Remember that inclusion of all these lines of code doesn t necessarily mean that all the code will be part of the final project The header files contain all the possible functions that will be necessary and when the compiler actually accomplishes the work then it will only include the functions that are actually required Now it is time to introduce come new concepts in C code syntax Here are three rules that the authors always follow If they are memorized it will make it easier to quickly work through new code when it is presented e Any time you see something where all letters are capitalized the authors will use this to identify a define statement for a preprocessor e If the first letter only is capitalized it is what is known as a function cell e If all of the letters are lower case it is known as a variable What is beginning to be accomplished in this tutorial is the additional use of cleaner and more elegant code functions in the proj
13. rts and Configuring Pins As shown in Figure 6 the first port to be enabled is port C GPIOC Once the port is enabled the next step is to configure the pins In this case pins 6 and 7 are enabled as output pins As can be shown by the bottom line Port A Pin 6 is configured as an input pin If you review the picture in attachment 2 you can see pictorially where all the ports and pins run to 28 GPIOPinWrite GPIO PORTF BASE GPIO PIN 1 GPIO PIN 2 GPIO PIN 3 4 LED Blue on Laun 68 Cycle through the LEDs on the Orbit board 61 GPIOPinWrite GPIO PORTC BASE GPIO PIN 6 GPIO PIN 7 8x48 LED 1 on LED 2 Off 62 GPIOPinWrite GPIO PORTD BASE GPIO PIN 6 0x60 LED 3 off Note different PORT 63 GPIOPinWrite GPIO PORTB BASE GPIO PIN 5 8x60 LED 4 off 65 SysCtlDelay 2000000 Delay Replaces for LOOP LU b GPIOPinWrite GPIO PORTC BASE GPIO PIN 6 GPIO PIN 7 0x88 LED 1 OFF LED 2 on 69 SysCtlDelay 2000000 Delay Replaces for LOOP 71 GPIOPinWrite GPIO PORTC BASE GPIO PIN 6 GPIO PIN 7 8x08 LED 1 off LED 2 off 72 GPIOPinWrite GPIO PORTD BASE GPIO PIN 6 6x40 LED 3 on 74 SysCtlDelay 20008000 Delay Replaces for LOOP b GPIOPinWrite GPIO PORTD BASE GPIO PIN 6 86x00 LED 3 off 77 GPIOPinWrite GPIO PORTB BASE GPIO PIN 5 8x20 LED 4 on 79 SysCtlDelay 2000000 Delay Replaces for LOOP 88 a E Figure 7 IF Work In Figure 7 it is possible to see how much more elegant an
14. tional References The Evaluation Board user s manual is on this web site http datasheet octopart com EK TM4C123GXL Texas Instruments datasheet 15542 121 and the manuals for the M ip orbit board are located at IVE L A 2 LaunchPad i Figure 1 ARM and ORBIT Combination This picture of the correct way to mate the Tiva LaunchPad and the Digilent Orbit boards together Please do so at this point and connect them as shown in Figure 1 T Ode OITIDOSerm Figure 2 Code Composer Icon Launch Code Composer and where prompted chose the workspaces location to store your project as shown in Figure 3 lab activity Select a workspace Code Composer Studio stores your projects in a folder called a workspace Choose a workspace folder to use for this session Workspace E amp Y ele i aa Browse _ Use this as the default and do not ask again Figure 3 Workspace Selection Since the installer for the workshop has been run prior to this the user will be presented with the following view Figure 4 where all lab projects exist File Edit View Navigate Project Scri TIERA mii i Project Explorer 53 E S i Lab 2 gt i Lab 3 i Lab 4 Active Debug gt S Lab 5 gt i Lab 6 gt i Lab 7 i Lab 8 gt i Lab 9 Figure 4 CCS Starting Point The laboratory material is created to have the students type in a lot of the code Only by typing the code and then debugging the errors w
Download Pdf Manuals
Related Search
Related Contents
TS-1 Time Code Slate - Audio Services Corporation (Canada) Ltd. TRDM-64CW Emos 1710000035 HI 3815-100 - Hanna Instruments Portugal SA−WM-250N 設置管理基準書 KING SERIE - sinclair air conditioners 3A1716G - Fine Finish Hand-Held Paint Sprayer Manuel d`utilisation Vigil II - Documentation parachutiste PDF:4385KB GE GDWF160 User's Manual Copyright © All rights reserved.
Failed to retrieve file