1. Lab 1
EENG 3910: Project V - Digital Signal
Processing System Design
9/14/2015
Joseph Chandler
University of North Texas
College of Engineering
Electrical Engineering
2. Introduction
Lab 1 introducesthe TivaTM
C SeriesEK-TM4C123GXL. Code ComposerStudio(CCS) isusedforsoftware
supportand boththe hardware and software are productsof TexasInstruments.
Results and Discussion
Problem 1
The firstproblemisan introductiontoCCS.It explainshow toconfigure the TivaTM
CSeriesEK-
TM4C123GH6XL. Afterthe hardware parametersare set,a sample programisaddedto the new project
for analysis.The buildfunctionisshownandthe debuginterface isshown.
Problem 2
#include <stdint.h>
Thisline containsthe headerfile for variabledefinitions.The headerfileisalreadydefinedinthe CCS
software.Examplesof the valuesare bitsize,precision,andsignedorunsignedintegers.
#include <stdbool.h>
Thisline containsthe headerfile forBooleandefinitions.The headerfile isalreadydefinedinthe CCS
software.The file definitionsare usedforoperations,comparingvariables,andprogramcontrol flow.
#include "inc/hw_memmap.h"
Thisline containsthe headerfile forthe TivaCSeriesdevice memorymapdefinitions.The headerfile
containsmanyof the same definitionsusedfordirectregisteraccess.The headerfilecontainsmacros
and definitionstosimplifyprogrammingthe peripheral'sregistersandinterruptcontrol.The definitions
are usedbydriverlibrariesandare hiddenfromthe programmer.
#include "inc/hw_types.h"
Thisline containsthe headerfile forcommontypesandmacros.The headerfile containsmanyof the
same definitionsusedfordirectregisteraccess.The valuesare awide varietyof general use for items
such as arithmetic,clocktiming,file recognition,anddevicerecognition.
#include "driverlib/sysctl.h"
Thisline containsthe headerfile forthe SystemControl APIdefinitionsandmacros.The headerfile isin
the directory"driverlib"of the CCS software.The driversprovideguidedcontrol of the peripheralsand
allowsforquickapplication.Enablingperipheralsisanexampleof thiscontrol.
#include "driverlib/gpio.h"
3. Thisline containsthe headerfile forGPIOAPIdefinitionsandmacros.The headerfile isinthe directory
"driverlib"of the CCSsoftware.The driverprovidesasetof functionstocontrol the inputand output
module.
int main(void){
The main processcalls andacts on variables,macros,definitions,andothersystemfunctions.
uint8_t pin_data=2;
An unsigned 8-bitintegervariable isinitializedto2
uint32_t delay_count=2.66e7;
An unsigned 32-bitvariable isinitialized to2.66e7
SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
SystemControl ClockSet setsthe clockingof the device. Osc_Mainconfiguresthe oscillatorsource.
XTAL_16MHZ usesa 16 MHZ crystal clock. USE_PLL is a phase lockedloopat 400 MHz. SYSDIV_5divides
the clock bythe numberspecifiedgivingcontrol of the frequency
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
Enablesthe peripheral forthe general purpose input/outputportF
GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3);
Thisline configurespinsforuse asGPIOoutputs.The firstparameteristhe base addressof the GPIO
port. Inthisapplicationthatwouldbe portF. The nextparameteristhe bit-packedrepresentationof the
pins. Thisfunctionprovidesproperconfigurationof the pinswithoutprogramming registers.Type of
outputwill be the three onboardLEDs that use portF.
while(1) {
The while loopprovidesa continuousloop whensetto"1".
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, pin_data);
Thisline writesavalue tothe specifiedpins. The valueiscontainedinthe variable"pin_data".The initial
state of "pin-data"is2. Therefore,the value2is giventoall of the pins.Yet,onlyone of the pinswill
correspondtothe givenvalue due toa pre-setconditionof 2mA,4mA,and 8mA.
SysCtlDelay(delay_count);
Thisline providesadelay.The variable "delay_count"holdsthe value of the delayloop. The constantis
2.66e7. The loopiterates3 times.
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, 0);
4. Thisline writes avalue tothe specifiedpins. Therefore,the value0is giventoall of the pins. This
essentiallyclearsthe LEDsof all "high"input.NoLED action.
SysCtlDelay(delay_count);
Thisline providesadelay.The variable "delay_count"holdsthe value of the delayloop.The constantis
2.66e7. The loopiterates3 times.
if(pin_data == 8)
The "if"statementischeckingif the current value of the pinvariable isequal to8.
pin_data = 2;
The value of the pinvariable issetto2.
else
The "else"statementisusedwhenthe currentvalue of the pinvariable isnotequal to8.
pin_data = pin_data*2;
The value of the pinvariable ismultipliedby2.
Problem 3
The EK-TM4C123GXL LED clock rates are increasedwhenthe numberof systemdivisionsare decreased.
SysCtlClockSet(SYSCTL_SYSDIV_10|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
20 MHz
SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
40 MHz
SysCtlClockSet(SYSCTL_SYSDIV_4|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
50 MHz
SysCtlClockSet(SYSCTL_SYSDIV_2_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
80 MHz
Next,the valuesof the variable "delay_count"weredeterminedfor1secondaccordingto the rise in
frequency. The desiredfrequencywasdividedby3 cpu cyclesto determinethe time delayinterval
neededinthe systemvariable"delay_count".
uint32_t delay_count=0.66e7; // For about 1s delay at 20 MHz clock rate.
20MHZ/3 = 0.67e7
uint32_t delay_count=1.33e7; // For about 1s delay at 40 MHz clock rate.
40MHZ/3 = 1.33e7
5. uint32_t delay_count=1.66e7; // For about 1s delay at 50 MHz clock rate.
50MHZ/3 = 1.67e7
uint32_t delay_count=2.66e7; // For about 1s delay at 80 MHz clock rate.
80MHZ/3 = 2.67e7
Finally,the variable"delay_count"waschangedtothe resultsabove.The resultof the LED displayis 1
seconddelay.
Problem 4
An Introductiontothe TivaC SeriesPlatformof Microcontrollerswasanoverview of TI'snextgeneration
of ARM Cortex M4 processors.The reportonthe new microprocessorsboastedof the new 32-bit
architecture andhighprecision.The serieshasalarge instructionset andbetterresolutionforcapturing
samplesof analogsignalsandconvertingthemtodigital.Multi-taskingandreal-time applicationhas
greatlyimproved.Also,the durabilityhasimprovedalongwithlow energyconsumption.
TivaWare Peripheral DriverLibraryisa setof driversthatmake the TIVA C Serieseasiertoprogram.They
are writteninCfor the most part and efficient.There are multiplesoftwarepackagesthatare available
to use all the driversare mappedout fordirectregisteraccess.The driverlibrarycanbe usedalongwith
directregisteraccessformore efficientprogramming.The generalpurpose input/outputmodule has8
pinsthat can be configuredasan inputor an outputwithdifferentcapabilities.Also,more thanone pin
can be operatedonat one time.The systemcontrol givesmore flexibilitywithabilitiestochange
frequency,timing,clock-type,energyuse,andthree differentoperatingmodes.
The TM4C123GH6PM MicrocontrollerOverview givesdetailedinformationaboutthe Core,
Performance,Flash,SystemSRAM,EEPROM,Internal ROM,Security,CommunicationInterfaces,System
Integration,AdvancedMotionControl,AnalogSupport,andhardware layout.
The three LEDs are connectedthroughportF of the GPIO module.The schematicshowsthe three LEDs
have diodescontrollingthe input.The diodesturnonfor the gatesthat correspondto2, 4, and 8. This
referstothe mA that activateseachLED. If itdoesnot containthe right amountof mA the transistoris
not activated. Eachiterationof the loopsends a "0" or "off" to all the gatesbefore the new loop
iterationiscalculated.
Summary and Conclusion
The Tiva C SeriesTM4C123G MicrocontrollerwasattachedbyUSB to the CPU and there were notany
problemswithpowering onorcompatibilitywithWindows7.CCS wasveryuserfriendlyandoffered
differenthardware implementation.The programswere builtwithouterrorandran accordingto plan.
CCS programsusedsoftware driverstomapmostof the hardware and applications.
References
TexasInstruments.(2014).TivaWarePeripheral Driver Library: User'sGuide. Austin,Texas:TI.