Chapter 1 Introduction 1

hello and welcome to the getting started with the stellaris EK lm4f 120 XL launchpad workshop my name is Scott bland and I’m a senior instructor with the technical training organization at Texas Instruments I’m also the author of the material in this workshop this workshop has been constructed to be extensively hands-on and the overwhelming majority of your time will be spent working with the tools and writing code if you don’t already have some experience with embedded microcontrollers and using the C programming language you need to acquire that experience before proceeding there are many resources online that you can use to obtain that knowledge in case you didn’t know it already this workshop is available at slash stellaris launchpad workshop as shown that wiki site has leaks to all of the material you’ll need to run this workshop let’s get started chapter 1 is an introduction to TI’s stellaris lm4f series microcontroller and its peripherals and tools in this chapter you’ll take a look at the stellaris roadmap and the wider TI embedded processor portfolio you’ll also examine the architecture and features of the device and the design of the launchpad board TI has an extensive embedded processing portfolio from the low end with our 16-bit ultra-low power microcontrollers like the msp430 all the way up to multi-core DSPs like the C 6000 and our ultra low power DSPs like to see 5000 in the middle we have our 32-bit real time microcontrollers like the C 2000 the Delfino concerto and piccolo which are very capable at motor control digital power lighting renewable energy I’ll skip the stellaris for a moment our Hercules devices are 32-bit arm safety directed microcontrollers containing m3s and cortex r4 F’s those are primarily used in safety transportation industrial and medical wear to Wars run in lockstep on the single piece of silicon next up is our 32-bit arm micro processors like the Satara a eight and a nine series these are for high end industrial automation portable data terminals places where you would be likely to see high end operating systems then we get to our very very high performance devices like the C 6000 the integra da Vinci and our C 6000 parts up to 10 Giga hor gigahertz multi-core devices with fixed and floating point and accelerators these are for video voice telecom medical base station lots of lots of amazing things you’ll notice that in the middle of the chart here are all of our arm microcontrollers Ti is one of the largest suppliers of arm microcontrollers in the world what we’ll be dealing with today is the stellaris arm cortex-m for F’s cortex m4 is a specification by arm the F is a floating-point unit that’s that is added to the device in the cortex m4 specification that’s optional but all of T is m4 devices are in for f’s all of them contain the floating-point device our parts are currently up to 80 megahertz our flash goes to 512 kilobytes we have peripherals like USB Ethernet Anza on many of these the Mei it’s the ethernet mac and phy can ports a DC’s pwms spy ports and lots of other serial connectivity these are being used in motion control human interface industrial automation smart grid robotics an amazing number of places a buck to eight bucks a solaris roadmap includes our legacy arm cortex-m three devices from the LM 3s 800 all the way up to the LM 3s 9000 these are all fixed point devices from the general-purpose devices with basically nope no major peripherals on them to some that contain can some that contain kin and USB host device and on-the-go ports and some may contain versions of that including ethernet mac and phy on them currently in in TM X or being released for sampling right now our our lm4f 1 1 X 1 2 X 2 1 X 1 3 x + 2 3 X devices the one that we’re dealing with today is the lm4f 120 h5q our that was released that will be released to production in

February 2013 80 megahertz devices 256 K a flash 30 K of SRAM low-power hibernate modes to 1 mega sample per second 12 bit ADC s as many as 2 can ports on them and they’re some of the devices have motion control modules on them as well the lm4f one 3x + 2 3 X also have USB ports that have host device and on-the-go and include canned ports on them 80 megahertz 256 K flash 32k of SRAM low-power hibernate to 1 mega sample per second 12 bit ADCs and motion control in development right now are our lm4f – 9 x series that have USB and can on them and they may also the parts can also have Ethernet USB and can with speeds – 120 megahertz flash sizes – 1 megabyte 256 K of SRAM up to 2 can ports on there they also include a nice wide 32 bit parallel bus interface and a cryptographic module on them as well the Solaris lm4f 120 series microcontrollers have a wide range of peripherals and capabilities we take a look at the diagram on the left hand side we can see the arm cortex-m for F core which sports JTAG access for taste test ability as well as serial wire debug for testability we have the N Vic method vectored interrupt controller we have the memory protection unit we have the floating-point unit and we have the embedded trace macro cell for extended testing on the device for memory we have 256 K a flash 20s are 32 K of SRAM we have an on-board ROM I’ll talk about the contents in a moment at 2k of double EEPROM on the analog side we have a LDO voltage regulator for regulating the CPU voltage on the device series of analog comparators we have 2 12 bit ADC s that’s up to 24 channels through 12 shared inputs 1 mega sample a 2 D conversion and a temperature sensor on board on the left bottom side there we have a series of serial interfaces depending on how you decide to use the i/o on the device you can have as many as 8 you arts for SSI spy ports a USB device port a canned port or as many as 6 I squared C ports for the system control we have the normal very flexible clock system reset and system control we also have a cystic timer on board that timer is many times used as a real-time operating system heartbeat timer although you can use it as a regular timer resource on the device we have 12 general-purpose timers capable of PWM and capture and compare there are six each 32-bit or two 16-bit six the other six are 64-bit or two 32-bit we also have two watchdog timers each of them driven by a separate clock domain for safety GPIO s we have I’ll talk more about GPIO s in a moment 32 channels of DMA a precision oscillator on board and a battery back hibernate module that offers real-time clock as well as battery backed SRAM so we offer best-in-class power consumption as low as 370 micro amps per megahertz 500 microseconds wake up from low power modes and real-time clock currents as low as 1.7 micro amps it’s a solid roadmap to higher speeds larger memory and ultra-low-power stellaris lm4f devices have a 32-bit ARM Cortex m4 core inside them the m4 core runs the thumb to instruction set that instruction set is 60 is a combination of 16 and 32-bit code combining those offers or allows you to use 26% less memory and is 25% faster than pure 32-bit code the system clock frequency on these devices is up to 80 megahertz at 80 megahertz we offer a hundred dry stone MIPS the device has very flexible clocking system onboard an internal precision oscillator an external main oscillator that can drive a phase lock loop an internal low frequency oscillator and a real-time clock through the hibernation module the instruction set and hardware offer saturated math for signal processing we have atomic bit manipulation or read-modify-write

capability using bit banding we have a single cycle multiply and Hardware divider onboard data access here is unaligned for more efficient memory usage we have both privileged and unprivileged modes the privileged mode can limit or excuse me the unprivileged mode limits the access to the mpu registers the Cystic the nested vectored interrupt controller and possibly some of the memory and peripherals primarily to promote safety in terms of thread access and sometimes our tosses real-time operating systems require that I Triple E 754 compliant single-precision floating-point unit is on all ti m4f devices we also have J tag and serial wire debugger access to the stellaris microcontrollers the embedded trace macro is currently accessible through the Kyl and IA our emulators the microcontroller on the launch pad is an lm4f 120 h5q are the man inside that device has 256k of flash memory single-cycle to 40 megahertz above 40 megahertz we have a prefetch buffer and speculative branching to improve the performance there’s 32 K of single cycle SRAM with bit banding will cover bit banding a little later all lm4f devices have an internal ROM those roms are loaded with stellaris where software they have the stellaris where peripheral driver library which can save you a significant amount of space when you’re writing your code they have a stellaris bootloader they have the AES cryptography tables in them and CRC error detection functionality we also have a 2k EE prom that’s where level at 500 thousand program array cycles 10 year data retention and there’s a 4 clock cycle read time on this in most designs designers or have to incorporate a double EEPROM on to the board in this case you don’t have to allow for that or pay for that if you look at the memory map over on the right hand side the flash memory starts at 0 the ROM memory starts at 1 million the SRAM starts at 20 million at 22 million is a bit banded mapping of the exact memory that’s sitting at 20 million the SRAM the peripherals and double EEPROM start at 40 million we’ve bit banded those peripherals at 42 million and there’s instrumentation the embedded trace macro and and some other stuff starting at E 0 million to continue the peripherals we have a battery backed hibernation module which offers internal and external power control through an external voltage regulator a separate real-time clock and power source the VDD 3 on mode can retain the GPIO States and its settings when we go into hibernation we can wake on the real-time clock or we can wake on a pin there are 16 32-bit words of battery backed memory for saving the processor state during hibernation we have a five microamp hibernate current with gpio retention 1.7 microamps without that’s very very low serial connectivity on these parts we have a USB 2.0 device port as many as eight you arts depending on what you use the pins for for I squared C for SSI spy ports and AK and port looking at some more of the peripherals there are two one mega sample per second 12 bit successive approximation A to D converters the two part share 12 shared inputs any of those inputs can be single ended or differential there’s an internal temperature sensor for programmable sample sequencers that we’ll talk about later very flexible trigger control you can trigger it with the processor through the software with the timer with an analog comparator or directly from a GPIO pin the voltage reference on this device since its cost reduced that we don’t have as many pins to put an external reference we’re using the analog voltage and ground there’s optional Hardware averaging we have two analog comparators per device and 16 total digital comparators in the ADCs and their DMA enabled on the GPIO aside depending on how you deal with the muxing of the pins if you’re using them for other purposes you can have anywhere between none and 43 GPIO any GPIO can be configured edge or level trigger to

interrupt you can initiate an ADC sample or a DMA transfer directly from a GPIO pin the toggle rate can be as high as the CPU clock speed on the advanced high performance bus ports on a standard port it’s half the CPU clock speed the inputs are 5 volt tolerant you can have a programmable drive strength of 2 4 or 8 milliamps in the eight milliamp setting you also get slew rate control and there’s a programmable weak pull-up and open train for every pin finishing out the peripherals we have a memory protection unit that generates a memory management fault on incorrect access to a Regents that you’ve configured we have a series of timers to watchdog timers with separate clocks and user enabled stalling Cystic timer it’s a 24 bit high speed timer that’s generally used for our tosses but it’s also available as a general-purpose timing resource there are six 32-bit and six 64-bit general-purpose timers all of those timers can be split in half and they all have PWM and capturing compare modes they can also be daisy chained or combined together to generate longer periods and all the timers listed there have user enabled stalling when you halt the processor in the debugger you can halt these timers as well the the micro DMA is a 32 channel DMA that offers basic ping-pong and scatter gather modes they have two priority levels on the transfers and they could be 8 16 or 32 bits in size the DMA can also generate interrupts when it finishes the transfer we have a nested vectored interrupt control around the device we offer seven level seven system level exceptions and 65 interrupts with eight programmable priority levels so your vector table is not set in stone you can go in and reprogram the priority levels if you choose we also offer an a very interesting feature called tail chaining that will describe later it’s deterministic it’s always 12 cycles for an interrupt or six with tail chaining and we have automatic system save and restore the stellaris launchpad board has some impressive features for a small price the on-board processor they’re in the middle of the board is a Texas Instruments stellaris lm4f 120 h5q our microcontroller it’s a version of the arm cortex-m 4f family with 64 pins and has a top speed of 80 megahertz the launch pad has two USB ports one at the top for emulation and one on the left side as a device mode user port the board can be powered through either port using the power switch in the upper left there are two user push buttons at the bottom of the board the one on the right is also connected to the wake pin on the microcontroller that will wake it from hibernation mode a reset button is provided in the emulator area of the board in the upper right just below the reset button is a tricolor LED that combines the red green and blue LEDs into a single package to the right of the device USB port are to test points where you can measure the current draw of the microcontroller they are currently connected by a jumper there are two crystals on the board a 16 megahertz one that drives the main oscillator and a 32,768 Hertz one that drives the real-time clock oscillator since many computer USB ports can deviate significantly from 3.3 volts an onboard voltage regulator is provided expandability is an important aspect of all TI’s launchpad boards the stellaris launchpad features the booster pack XL pin out which offers additional signals while still supporting existing booster packs all stellaris devices offer support for multiple integrated development environments or i des Mentor Graphics mentor embedded source recode bench ir systems embedded workbench arm Kyle micro vision IDE and Texas Instruments codes composer studio are all supported co composer studio or CCS will be our tool of choice in this video in lab 1 you’ll obtain and install all the needed hardware and software as well as test out the pre installed application software on the launchpad board since the installation steps are well documented and pretty straightforward let’s skip them and

start with examining the kit contents in step 25 of lab 1 the stellaris launchpad kit contains the following items a readme first car the lm4f 120 h5q our launchpad board and a USB a male 2 microbe email cable connecting the board to your laptop is very simple just connect the emulator port mark debug to a free USB port on your laptop the driver installation is covered in steps 26 27 and 28 don’t forget to write down the port number that windows the science to your stellaris virtual comport when you get to that step do the applicable steps and we’ll pick up the video at step 29 your launchpad board came pre-programmed with a QuickStart application once you’ve powered the board this application runs automatically you probably already noticed it running as you install the drivers in step 29 make sure that the power switch in the upper left-hand corner of your board is in the right-hand debug position shown in step 30 the software on the lm4f 120 h 5qr uses the timers as pulse width modulator x’ pwm to vary the intensity of all three colors on the RGB LED red green and blue individually by doing so your eye will perceive many different colors created by combining those primary colors the two push buttons at the bottom of the board are mark SW 1 and SW 2 I’ll press and hold switch SW 1 here to move toward the red end of the color spectrum press and hold SW 2 to move toward the violet end of the color spectrum if no button is pressed for five seconds the software returns automatically changing the color display in step 31 press and hold both SW 1 and SW 2 for 3 seconds to enter hibernate mode in this mode the last color will blink on the LEDs for a half a second every 3 seconds tween the blinks the device is in the vdd 3 on hibernate mode with the real-time clock running pressing SW 2 and any time we’ll wake the device and return to automatically changing the color display in step 32 we can communicate with the board through the UART the UART is connected as a virtual serial port through the emulator USB connection you will need the comm port number that you wrote down in either step 23 or step 24 in the following steps I’m going to show you how to use the connection to the board using putty on this board if you’re using Windows XP you could also use hyper terminal double-click on putty dot exe on your desktop make the settings shown in step 34 and then click open your comm port number will be the one that you noted earlier so here we’re going to use comm 34 as speed of 115200 and the settings are 8-1 none and none so when your terminal window opens press ENTER once and the launchpad board will respond with a with a caret indicating that communication is open in step 35 you can communicate to the board by typing the following commands and pressing enter go ahead and type help if you type help the board will generate a list of commands and information and things that it can do among them are intensity so we’ll try intensity one here this will adjust the LED brightness between zero and a hundred percent so we should be able to notice on the board that the LED is very dim so go ahead and send intensity 100 to the board and you’ll notice now it’s very bright in step 36 go ahead and close your terminal program