{"id":4114,"date":"2011-12-12T18:20:21","date_gmt":"2011-12-12T23:20:21","guid":{"rendered":"http:\/\/embedded-lab.com\/blog\/?p=4114"},"modified":"2012-07-30T09:29:14","modified_gmt":"2012-07-30T13:29:14","slug":"setting-up-the-ccs-v4-build-and-debug-environment-for-ti-msp430-launchpad","status":"publish","type":"post","link":"https:\/\/embedded-lab.com\/blog\/setting-up-the-ccs-v4-build-and-debug-environment-for-ti-msp430-launchpad\/","title":{"rendered":"Setting up the CCS v4 build and debug environment for TI MSP430 Launchpad"},"content":{"rendered":"<p>Last year, Texas Instruments (TI) released industry&#8217;s lowest cost (only $4.30) microcontroller development kit named <a href=\"http:\/\/processors.wiki.ti.com\/index.php\/MSP430_LaunchPad_%28MSP-EXP430G2%29\" target=\"_blank\"><strong>Launchpad<\/strong><\/a>. It is a complete development tool for rapid prototyping with TI&#8217;s ultra-low power MSP430 Value Line MCUs. I also bought a Launchpad kit several months ago but haven&#8217;t really looked into it. Last weekend, I spent a couple of hours reading about the MSP-EXP430G2\u00a0experimenter\u00a0board (that comes with the Launchpad kit) and the <a href=\"http:\/\/www.ti.com\/tool\/ccstudio\" target=\"_blank\">Code Composer Studio<\/a> (CCS) software tool. CCS is an integrated development environment (IDE) to develop and debug applications for TI&#8217;s embedded processor families.\u00a0As always, a &#8220;Hello World&#8221; program is the best thing to start with any new development platform. If you ran it successfully, it means you have setup the compiler and the programmer\/debugger correctly and you are all set to go. Here&#8217;s a step-by-step guide to set up the CCS v4 build and debug environment for the MSP-EXP430G2 experimenter\u00a0board.<\/p>\n<div id=\"attachment_4180\" style=\"width: 560px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/LaunchPadSetup.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-4180\" class=\"size-medium wp-image-4180\" title=\"LaunchPadSetup\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/LaunchPadSetup-550x350.jpg\" alt=\"\" width=\"550\" height=\"350\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/LaunchPadSetup-550x350.jpg 550w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/LaunchPadSetup.jpg 800w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" \/><\/a><p id=\"caption-attachment-4180\" class=\"wp-caption-text\">TI&#39;s MSP430 Launchpad board<\/p><\/div>\n<p><!--more--><strong>A brief introduction to MSP430 Launchpad<\/strong><\/p>\n<p>Launchpad is a low cost development solution to get started with TI&#8217;s MSP430 Value Line devices. The Launchpad kit includes a MSP430G2 experimenter board, two MSP430G2xx flash microcontrollers (MSP430G2231 and\u00a0MSP430G2211), a mini USB cable, four 10-pin headers (two male and two female), and a 32.768 KHz external crystal. The total cost of the kit is only <strong>$4.30<\/strong>. The experimenter board has an integrated DIP target socket that supports up to 20 pin devices. All of the pins are broken out to the header ports on either side of the board for easy access. The on-board flash emulation tool allows direct interface to a PC through an USB port for easy programming and debugging. The same interface can also be used by the MSP430G2xx device on the board to communicate with the host PC through a 9600 baud UART serial connection (virtual COM port).<\/p>\n<p>There are two LEDs (red and green) on the board that are connected to P1.0 and P1.6 I\/O pins. Similarly, two push buttons for user input and device reset are also available on the board.<\/p>\n<p>There are different development tools available to write, download, and debug applications for the MSP-EXP430G2 development\u00a0board. Code Composer Studio (CCS) is one of them and is also available in a free limited version that allows 16 KB of C-code compilation. This is just enough for experimenting with MSP-EXP430G2 board.<\/p>\n<div id=\"attachment_4119\" style=\"width: 568px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/MSP-EXP30G2.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-4119\" class=\"size-full wp-image-4119\" title=\"MSP-EXP30G2\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/MSP-EXP30G2.jpg\" alt=\"\" width=\"558\" height=\"500\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/MSP-EXP30G2.jpg 558w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/MSP-EXP30G2-550x492.jpg 550w\" sizes=\"auto, (max-width: 558px) 100vw, 558px\" \/><\/a><p id=\"caption-attachment-4119\" class=\"wp-caption-text\">MSP430 Launchpad<\/p><\/div>\n<p><strong>Installation of Code Composer Studio v4<\/strong><\/p>\n<p>Code Composer Studio\u2122 (CCS) is an integrated development environment (IDE) for developing and debugging embedded applications for TI&#8217;s various processor families. \u00a0It includes compilers for each of TI&#8217;s device families, source code editor, project build environment, debugger, profiler, simulators and many other features. There are many versions of CCS IDE, but I will be talking about CCS v4, which is a recommended version for MSP430 users. So first you need to go to the CCS download wiki by clicking the following link.<\/p>\n<p><a href=\"http:\/\/processors.wiki.ti.com\/index.php\/Download_CCS\" target=\"_blank\">http:\/\/processors.wiki.ti.com\/index.php\/Download_CCS<\/a><\/p>\n<p>Then scroll down a little bit and click on the download button, &#8220;<strong>Download latest production CCSv4 MSP430\/C28x code size limited image<\/strong>&#8220;, as shown below.<\/p>\n<div id=\"attachment_4152\" style=\"width: 560px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/DownloadButton.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-4152\" class=\"size-medium wp-image-4152\" title=\"DownloadButton\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/DownloadButton-550x60.jpg\" alt=\"\" width=\"550\" height=\"60\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/DownloadButton-550x60.jpg 550w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/DownloadButton.jpg 602w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" \/><\/a><p id=\"caption-attachment-4152\" class=\"wp-caption-text\">Download the FREE Code Size Limited Tools for MSP430 and C28x<\/p><\/div>\n<p>You will be directed to my.TI Account page where you need to log in. If you don&#8217;t have a TI account you can create one for free. The link to the installation zip file will be then sent to your email. Click on the link and download the zip file. Unzip it and double click on the file named <strong><em>setup_CCS_MC_Core_x.x.x.x.exe<\/em><\/strong>. Follow the installation instructions and select <strong><em>MSP430-only Core Tools<\/em><\/strong> option in the <strong><em>Product Configuration<\/em><\/strong> dialogue window and click <strong><em>Next<\/em><\/strong>. Use the default settings in the \u00a0<strong><em>Select Components<\/em><\/strong> dialog and click <strong><em>Next<\/em><\/strong>. Then click <strong><em>Next<\/em><\/strong> again in the <strong><em>Start Copying Files<\/em><\/strong> dialogue and wait till the installation completes.<\/p>\n<p><em><span style=\"color: #ff0000;\"><strong>Note:<\/strong><\/span><\/em>\u00a0<em>By default, Microsoft Windows Vista and Windows 7 do not allow user level accounts to write files in the\u00a0<strong>Program Files<\/strong> directory. This can prevent CCS from starting when installed in the <strong>Program Files<\/strong> or <strong>Program Files (x86)<\/strong> directory, because CCS stores configuration data by default in its install directory. So it is recommended to install CCS outside the <strong>Program Files or Program Files (x86)<\/strong> directory.<\/em><\/p>\n<p><strong>Writing a &#8220;Hello World&#8221; program<\/strong><\/p>\n<p>The Launchpad experimenter board includes a pre-programmed MSP430G2231 device which is already placed in the target DIP socket. When the board is powered through a USB cable, the preloaded demo program starts and the on-board red and green LEDs toggle in sequence. This is the\u00a0quickest way of verifying that the Launchpad board is working. But this is not our <strong>&#8220;Hello World&#8221;<\/strong> program. We will first explore the basic features of CCS and see how to create a new project, build the code, and eventually load the program into the flash memory of the MSP430 device on board. Our test program will make the MSP430G2231 device to continuously flash the on-board red LED connected to P1.0 pin.<\/p>\n<p><strong><em>Step 1:<\/em><\/strong>\u00a0Start CCS by double clicking the icon on the desktop or selecting it from the Windows Start menu. When CCS loads, the first thing it asks is to define a workspace &#8211; a directory that holds all elements (projects, links to projects, possibly source code) used in the development. Browse the directory path where you want it to be and do NOT check the\u00a0<em><strong>Use this as the default and do not ask again<\/strong><\/em> checkbox. Click <strong><em>OK<\/em><\/strong>.<\/p>\n<div id=\"attachment_4155\" style=\"width: 585px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/Step1.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-4155\" class=\"size-full wp-image-4155\" title=\"Step1\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/Step1.jpg\" alt=\"\" width=\"575\" height=\"351\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/Step1.jpg 575w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/Step1-550x335.jpg 550w\" sizes=\"auto, (max-width: 575px) 100vw, 575px\" \/><\/a><p id=\"caption-attachment-4155\" class=\"wp-caption-text\">Select Workspace folder<\/p><\/div>\n<p><em><strong>Step 2:<\/strong><\/em> If this is the\u00a0first time you have opened CCS then a\u00a0<em><strong>Welcome to Code Composer Studio v4<\/strong><\/em> page appears.<\/p>\n<div id=\"attachment_4156\" style=\"width: 560px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/Step2.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-4156\" class=\"size-medium wp-image-4156\" title=\"Step2\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/Step2-550x413.jpg\" alt=\"\" width=\"550\" height=\"413\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/Step2-550x413.jpg 550w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/Step2.jpg 1024w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" \/><\/a><p id=\"caption-attachment-4156\" class=\"wp-caption-text\">CCS Welcome screen<\/p><\/div>\n<p>Close the page by clicking the<em><strong> X<\/strong><\/em> on the <strong>Welcome<\/strong> tab. You should now see an empty CCS workbench with a C\/C++ icon in the upper right hand corner. This is called\u00a0the <strong>C\/C++ Perspective<\/strong> and is used to create or build C\/C++ projects. When you will be the debugging mode, it will automatically switch to the <em><strong>Debug Perspective<\/strong><\/em>. The layout views of the workbench windows,\u00a0tool-bars, and menus are different for code development and debugging. Therefore, the use of separate perspectives minimizes clutter to the user interface.<\/p>\n<div id=\"attachment_4157\" style=\"width: 560px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/Step3.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-4157\" class=\"size-medium wp-image-4157\" title=\"Step3\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/Step3-550x371.jpg\" alt=\"\" width=\"550\" height=\"371\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/Step3-550x371.jpg 550w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/Step3.jpg 849w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" \/><\/a><p id=\"caption-attachment-4157\" class=\"wp-caption-text\">Empty CCS workbench in C\/C++ Perspective<\/p><\/div>\n<p><strong><em>Step 3:<\/em><\/strong> Next step is to create a new project.\u00a0A project contains all the files you will need to develop an executable output file (.out) which can be run on the MSP430 hardware. To create a new project click:\u00a0<strong><em>File -&gt; New -&gt; CCS Project<\/em><\/strong><\/p>\n<p>In the Project name field type <strong><em>FlashLED<\/em><\/strong>. It will create a new directory called <strong><em>FlashLED<\/em><\/strong> inside the <strong><em>Workspace<\/em><\/strong> folder (if Use default location is checked), where all the project files will be stored. Click <strong><em>Next<\/em><\/strong>.<\/p>\n<div id=\"attachment_4158\" style=\"width: 560px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/Step4.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-4158\" class=\"size-medium wp-image-4158\" title=\"Step4\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/Step4-550x385.jpg\" alt=\"\" width=\"550\" height=\"385\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/Step4-550x385.jpg 550w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/Step4.jpg 689w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" \/><\/a><p id=\"caption-attachment-4158\" class=\"wp-caption-text\">Creating a new CCS project<\/p><\/div>\n<p><strong><em>Step 4:<\/em><\/strong>\u00a0The next window that appears selects the platform and configurations. The <strong><em>Project Type<\/em><\/strong> should be set to <em><strong>MSP430<\/strong><\/em> and the\u00a0<em><strong>Debug<\/strong><\/em> and\u00a0<em><strong>Release<\/strong><\/em> boxes should be checked in the <strong><em>Configurations<\/em><\/strong> box. Click <em><strong>Next.<\/strong><\/em><\/p>\n<div id=\"attachment_4159\" style=\"width: 560px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/Step5.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-4159\" class=\"size-medium wp-image-4159\" title=\"Step5\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/Step5-550x393.jpg\" alt=\"\" width=\"550\" height=\"393\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/Step5-550x393.jpg 550w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/Step5.jpg 680w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" \/><\/a><p id=\"caption-attachment-4159\" class=\"wp-caption-text\">Project type is MSP430<\/p><\/div>\n<p><strong><em>Step 5:<\/em><\/strong>\u00a0The next window is to define inter-project dependencies (if any). There are none now. So select <strong><em>Next<\/em><\/strong>.<\/p>\n<div id=\"attachment_4160\" style=\"width: 560px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/Step6.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-4160\" class=\"size-medium wp-image-4160\" title=\"Step6\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/Step6-550x390.jpg\" alt=\"\" width=\"550\" height=\"390\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/Step6-550x390.jpg 550w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/Step6.jpg 688w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" \/><\/a><p id=\"caption-attachment-4160\" class=\"wp-caption-text\">No inter-project dependencies for now<\/p><\/div>\n<p><strong><em>Step 6:<\/em><\/strong> The next step is to select the CCS project settings. Select the <em><strong>Device Variant<\/strong><\/em> using the pull-down list and choose <strong><em>MSP430G2231<\/em><\/strong> (target device on the Launchpad experimenter board). This will select the appropriate linker command file, runtime support library, set the basic build options for the linker and compiler, and set up the target configuration.<\/p>\n<div id=\"attachment_4161\" style=\"width: 560px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/Step7.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-4161\" class=\"size-medium wp-image-4161\" title=\"Step7\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/Step7-550x379.jpg\" alt=\"\" width=\"550\" height=\"379\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/Step7-550x379.jpg 550w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/Step7.jpg 735w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" \/><\/a><p id=\"caption-attachment-4161\" class=\"wp-caption-text\">Select MSP430G2231 for Device Variant<\/p><\/div>\n<p>Click <strong><em>Finish<\/em><\/strong> and a new project is created. You will now see\u00a0the <strong><em>C\/C++ Projects<\/em><\/strong> window contains <em><strong>FlashLED<\/strong><\/em> project which is set active.<\/p>\n<div id=\"attachment_4162\" style=\"width: 560px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/Step8.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-4162\" class=\"size-medium wp-image-4162\" title=\"Step8\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/Step8-550x374.jpg\" alt=\"\" width=\"550\" height=\"374\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/Step8-550x374.jpg 550w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/Step8.jpg 807w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" \/><\/a><p id=\"caption-attachment-4162\" class=\"wp-caption-text\">New project FlashLED added to the C\/C++ Projects window<\/p><\/div>\n<p><strong><em>Step 7:<\/em><\/strong> At this point, the project does not include any source files. The next step is to add the source files to the project.\u00a0To add a source file to the project, right-click on <em><strong>FlashLED<\/strong><\/em> in the <em><strong>C\/C++ Projects<\/strong><\/em> window and select:<strong><em>\u00a0New -&gt; Source File<\/em><\/strong>.\u00a0Name the source file <strong><em>main.c<\/em><\/strong> and click <strong><em>Finish<\/em><\/strong>.<\/p>\n<div id=\"attachment_4163\" style=\"width: 560px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/Step9.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-4163\" class=\"size-medium wp-image-4163\" title=\"Step9\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/Step9-550x367.jpg\" alt=\"\" width=\"550\" height=\"367\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/Step9-550x367.jpg 550w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/Step9.jpg 741w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" \/><\/a><p id=\"caption-attachment-4163\" class=\"wp-caption-text\">Add a new source file main.c<\/p><\/div>\n<p>Then\u00a0an empty window will open for the <strong><em>main.c<\/em><\/strong> code.<\/p>\n<div id=\"attachment_4164\" style=\"width: 560px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/Step10.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-4164\" class=\"size-medium wp-image-4164\" title=\"Step10\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/Step10-550x375.jpg\" alt=\"\" width=\"550\" height=\"375\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/Step10-550x375.jpg 550w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/Step10.jpg 807w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" \/><\/a><p id=\"caption-attachment-4164\" class=\"wp-caption-text\">Empty window for main.c<\/p><\/div>\n<p><strong><em>Step 8:<\/em><\/strong>\u00a0Next, we will add code to <strong><em>main.c<\/em><\/strong>. Type in or copy and paste the following code into the <strong><em>main.c<\/em><\/strong> window. This code is for flashing the red LED connected to P1.0.<\/p>\n<pre>#include &lt;msp430g2231.h&gt;\r\nvolatile unsigned int i;\r\nvoid main(void)\r\n{\r\n\tWDTCTL = WDTPW + WDTHOLD; \t\/\/ Stop watchdog timer\r\n\tP1DIR = 0x01; \t\t\t\/\/ P1.0 is output\r\n\tP1OUT = 0x00; \t\t\t\/\/ LED off\r\n\twhile(1)\r\n\t{\r\n\t\tP1OUT = ~P1OUT; \t\/\/ Complement output\r\n\t\t_delay_cycles(500000);  \/\/ Delay 50K clock cycles\r\n\t}\r\n}<\/pre>\n<p>The comments in the code pretty much explains each line of the code. The delay statement is a built-in intrinsic function for generating delays. The only parameter needed is the number of clock cycles for the delay. The <strong><em>while(1)<\/em><\/strong> loop repeats the next two lines for ever. After you finish typing the above code into <strong><em>main.c<\/em><\/strong> window, save your work.<\/p>\n<div id=\"attachment_4173\" style=\"width: 560px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/Step11.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-4173\" class=\"size-medium wp-image-4173\" title=\"Step11\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/Step11-550x331.jpg\" alt=\"\" width=\"550\" height=\"331\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/Step11-550x331.jpg 550w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/Step11.jpg 762w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" \/><\/a><p id=\"caption-attachment-4173\" class=\"wp-caption-text\">Save the main.c file after typing up the code<\/p><\/div>\n<p><strong><em>Step 9:<\/em><\/strong> Next click the <em><strong>Build<\/strong><\/em> button or select <strong><em>Project-&gt; Build Active Project<\/em><\/strong> and watch the tools run in the <strong><em>Console<\/em><\/strong> window. Check for any errors in the <strong><em>Problems<\/em><\/strong> window.<\/p>\n<div id=\"attachment_4175\" style=\"width: 535px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/BuildMenu.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-4175\" class=\"size-full wp-image-4175\" title=\"BuildMenu\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/BuildMenu.jpg\" alt=\"\" width=\"525\" height=\"200\" \/><\/a><p id=\"caption-attachment-4175\" class=\"wp-caption-text\">Build and Debug buttons in the toolbar<\/p><\/div>\n<div id=\"attachment_4166\" style=\"width: 560px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/Step12.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-4166\" class=\"size-medium wp-image-4166\" title=\"Step12\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/Step12-550x230.jpg\" alt=\"\" width=\"550\" height=\"230\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/Step12-550x230.jpg 550w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/Step12.jpg 653w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" \/><\/a><p id=\"caption-attachment-4166\" class=\"wp-caption-text\">Console and Problems windows<\/p><\/div>\n<p><strong><em>Step 10:<\/em><\/strong> If the build is successful, you are ready to load the program into the target MSP430 device. Make sure that the Launchpad board is connected to the PC. Then\u00a0click the <strong><em>Debug<\/em><\/strong> button (green bug). The <em><strong>Debug Perspective<\/strong><\/em> view should open, the program is loaded into the MSP430 device automatically, and you should now be at the start of <strong><em>main()<\/em><\/strong>.<\/p>\n<div id=\"attachment_4167\" style=\"width: 518px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/Step13.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-4167\" class=\"size-medium wp-image-4167\" title=\"Step13\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/Step13-508x650.jpg\" alt=\"\" width=\"508\" height=\"650\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/Step13-508x650.jpg 508w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/Step13.jpg 586w\" sizes=\"auto, (max-width: 508px) 100vw, 508px\" \/><\/a><p id=\"caption-attachment-4167\" class=\"wp-caption-text\">Debug Perspective<\/p><\/div>\n<p>In debug mode, you can run the application in either a single step mode using <strong><em>Step Into<\/em><\/strong> and <strong><em>Step Over<\/em><\/strong> function buttons or a free run mode by clicking on the <strong><em>Run<\/em><\/strong> button (see the picture below).<\/p>\n<div id=\"attachment_4179\" style=\"width: 505px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/DebugMenu1.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-4179\" class=\"size-full wp-image-4179\" title=\"DebugMenu\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/DebugMenu1.jpg\" alt=\"\" width=\"495\" height=\"192\" \/><\/a><p id=\"caption-attachment-4179\" class=\"wp-caption-text\">Debugging menu<\/p><\/div>\n<p>If you click on the <strong>Run<\/strong> button, the MSP430G2231 processor starts executing the program and the LED on board should blink continuously.<\/p>\n<p><strong><em>Step 11:<\/em><\/strong> At last, terminate the active debug session using the <strong><em>Terminate All<\/em><\/strong> button. This will close the debugger and return CCS to the <em><strong>C\/C++ Perspective<\/strong><\/em> view. CCS will remove the breakpoints and release the MSP430G2231 processor in the board so that it could execute freely the program without the need of the debugger.<\/p>\n<div id=\"attachment_4135\" style=\"width: 570px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/LaunchPadTitle.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-4135\" class=\"size-full wp-image-4135\" title=\"LaunchPadTitle\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/LaunchPadTitle.jpg\" alt=\"\" width=\"560\" height=\"379\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/LaunchPadTitle.jpg 560w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2011\/12\/LaunchPadTitle-550x372.jpg 550w\" sizes=\"auto, (max-width: 560px) 100vw, 560px\" \/><\/a><p id=\"caption-attachment-4135\" class=\"wp-caption-text\">Blinking LED at P1.2<\/p><\/div>\n<p><strong><span style=\"color: #ff0000;\">Note:<\/span> <\/strong>The\u00a0<strong><em>_delay_cycles(500000);\u00a0<\/em><\/strong>statement in the code creates a delay interval of 500000 clock cycles. If you want to convert it into time, you need to know the time period or frequency of the clock. MSP430 devices have multiple sources of clock including internally generated clocks (known as internal digitally controlled oscillator, DCO) and external source (using crystal). On power on reset, the default clock source comes from the internal DCO module. The default value of this clock is around 1.0 MHz (the internal oscillator is not very accurate). So, the <strong>\u00a0<em>_delay_cycles(500000);<\/em><\/strong>\u00a0statement should create a delay of approximately 0.5 sec interval.<\/p>\n<p><strong>References<\/strong><\/p>\n<p>Various documents and links available at <strong><a href=\"http:\/\/processors.wiki.ti.com\/index.php\/Getting_Started_with_the_MSP430_LaunchPad_Workshop\" target=\"_blank\">&#8220;Getting Started with the MSP430 LaunchPad Workshop&#8221;<\/a><\/strong>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Last year, Texas Instruments (TI) released industry&#8217;s lowest cost (only $4.30) microcontroller development kit named Launchpad. It is a complete development tool for rapid prototyping with TI&#8217;s ultra-low power MSP430 Value Line MCUs. I also bought a Launchpad kit several months ago but haven&#8217;t really looked into it. Last weekend, I spent a couple of hours reading about the MSP-EXP430G2\u00a0experimenter\u00a0board (that comes with the Launchpad kit) and the Code Composer Studio (CCS) software tool. CCS is an integrated development environment (IDE) to develop and debug applications for TI&#8217;s embedded processor families.\u00a0As always, a &#8220;Hello World&#8221; program is the best thing<\/p>\n","protected":false},"author":1,"featured_media":4119,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[379,348,183],"tags":[386,384,385,383],"class_list":["post-4114","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-msp430-launchpad","category-product-review","category-tips-and-tricks","tag-ccs-v4","tag-launchpad-kit","tag-msp430g2231","tag-ti-msp430"],"_links":{"self":[{"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/posts\/4114","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/comments?post=4114"}],"version-history":[{"count":29,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/posts\/4114\/revisions"}],"predecessor-version":[{"id":4205,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/posts\/4114\/revisions\/4205"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/media\/4119"}],"wp:attachment":[{"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/media?parent=4114"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/categories?post=4114"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/tags?post=4114"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}