{"id":107,"date":"2014-11-19T16:56:20","date_gmt":"2014-11-19T16:56:20","guid":{"rendered":"http:\/\/visualgdb.com\/w\/?p=107"},"modified":"2015-08-25T16:23:02","modified_gmt":"2015-08-25T23:23:02","slug":"arm-cc3200","status":"publish","type":"post","link":"https:\/\/visualgdb.com\/tutorials\/arm\/cc3200\/","title":{"rendered":"Creating a basic Wireless App for CC3200"},"content":{"rendered":"<p>This tutorial shows how to program the CC3200 microcontroller to create a WiFi access point that will allow connected users to control a LED from their browser. You will need:<\/p>\n<ul>\n<li>The <a href=\"http:\/\/www.ti.com\/ww\/en\/launchpad\/launchpads-connected-cc3200-launchxl.html\"> CC3200 LaunchPad<\/a> board from TI<\/li>\n<li>Visual Studio (including the free Community Edition)<\/li>\n<li>VisualGDB 4.3<\/li>\n<\/ul>\n<p>We will start with creating a basic &#8216;Blinking LED&#8217; firmware, use it to check the connection with the device and then proceed with a more complex HTTP-based LED control demo.<\/p>\n<ol>\n<li>Create a new VisualGDB Embedded project with Visual Studio:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/cc3200\/01-newprj.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/cc3200\/01-newprj.png\" alt=\"01-newprj\" width=\"800\" height=\"479\" \/><\/a><\/li>\n<li>Ensure that the first page of the wizard enables generation of a .bin file:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/cc3200\/02-bin.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/cc3200\/02-bin.png\" alt=\"02-bin\" width=\"702\" height=\"571\" \/><\/a><\/li>\n<li>On the next page select the ARM toolchain (if you don&#8217;t have it, VisualGDB will download it automatically), then click &#8220;Download support for more devices&#8221; and install the CC3200 package. The CC3200 chip comes in 2 variations: with 256 and 192 KBytes of SRAM (16KB are reserved for the bootloader). Select the chip that is installed on your Launchpad:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/cc3200\/03-devtype.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/cc3200\/03-devtype.png\" alt=\"03-devtype\" width=\"702\" height=\"571\" \/><\/a><span class=\"warning\">Warning! Older revisions of Launchpad come with the smaller XC3200HZ chip. If you are not sure which chip you have, select the smaller one and once you get it to work, change it to the bigger one.<\/span><\/li>\n<li>On the next page select the Blinky sample:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/cc3200\/04-blinky.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/cc3200\/04-blinky.png\" alt=\"04-blinky\" width=\"702\" height=\"571\" \/><\/a><\/li>\n<li>On the last page select OpenOCD as the debugging method. Connect your Launchpad via USB and press &#8220;Detect&#8221;. VisualGDB will detect it and select it automatically:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/cc3200\/05-detectjtag.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/cc3200\/05-detectjtag.png\" alt=\"05-detectjtag\" width=\"701\" height=\"570\" \/><\/a><\/li>\n<li>Press &#8220;Test selected OpenOCD settings&#8221; to check the connection to the board. Allow VisualGDB to install the Libusb driver for the debug interface (the TI SDK installs the original FT2232 driver that has been deprecated by OpenOCD):<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/cc3200\/06-driver.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/cc3200\/06-driver.png\" alt=\"06-driver\" width=\"701\" height=\"570\" \/><\/a><\/li>\n<li>Ensure that OpenOCD test succeeds:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/cc3200\/07-test.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/cc3200\/07-test.png\" alt=\"07-test\" width=\"663\" height=\"542\" \/><\/a><\/li>\n<li>Press &#8220;Finish&#8221; to generate the project. Then build it:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/cc3200\/08-build.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-8\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/cc3200\/08-build.png\" alt=\"08-build\" width=\"698\" height=\"562\" \/><\/a><\/li>\n<li>Start the project by pressing F5. The LEDs on the board should start blinking:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/cc3200\/09-led.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-9\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/cc3200\/09-led.jpg\" alt=\"09-led\" width=\"700\" height=\"314\" \/><\/a><\/li>\n<li>Select &#8220;Break All&#8221; in the Debug menu in Visual Studio. Ensure that you see the source code correctly:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/cc3200\/10-breakin.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-10\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/cc3200\/10-breakin.png\" alt=\"10-breakin\" width=\"698\" height=\"768\" \/><\/a><\/li>\n<li>Now that the basic project is working, use the VisualGDB Project Wizard to create another project based on the HTTPServer sample:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/cc3200\/11-http.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-11\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/cc3200\/11-http.png\" alt=\"11-http\" width=\"702\" height=\"571\" \/><\/a><\/li>\n<li>Before we can debug the HTTP Server, we need to upload the HTML files on the SPI FLASH on the board. The list of the uploaded files is stored in the CC3xxx_templates.xml file. Modify it to reference the debug version of your binary and build the project:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/cc3200\/12-xml.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-12\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/cc3200\/12-xml.png\" alt=\"12-xml\" width=\"698\" height=\"768\" \/><\/a><\/li>\n<li>Now we need to program the files into the serial FLASH. Set a jumper on row 2 (bottommost) of J15 and reset the board:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/cc3200\/13-progmode.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-13\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/cc3200\/13-progmode.jpg\" alt=\"13-progmode\" width=\"700\" height=\"340\" \/><\/a><\/li>\n<li>Make a note of the CCC3200 LaunchPad&#8217;s COM port number in the device manager. If it is not shown, install the drivers included in TI CC3200 SDK. If installing the drivers overrides the LibUSB driver we installed earlier, open debug properties and re-test OpenOCD connection to repair the driver:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/cc3200\/14-comport.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-14\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/cc3200\/14-comport.png\" alt=\"14-comport\" width=\"557\" height=\"524\" \/><\/a><\/li>\n<li>Download, install and launch the TI <a href=\"http:\/\/www.ti.com\/tool\/uniflash\">UniFlash tool<\/a>. Open the &lt;project dir&gt;\\HTML\\httpserver.ucf file, specify the COM port number you noted earlier and program the files to the FLASH memory:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/cc3200\/15-uniflash.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-15\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/cc3200\/15-uniflash.png\" alt=\"15-uniflash\" width=\"693\" height=\"610\" \/><\/a><\/li>\n<li>Go back to Visual Studio, right-click on the project in Solution Explorer, select VisualGDB Project Properties, go to the Raw Terminal page and enable the terminal on the COM port you noted before. Ensure the baud rate is set to 115200:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/cc3200\/16-terminal.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-16\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/cc3200\/16-terminal.png\" alt=\"16-terminal\" width=\"700\" height=\"554\" \/><\/a><\/li>\n<li>Remove the jumper from J15 and put it back between VCC and P58. Press F5 to start debugging your project. The firmware will output some basic status information to the terminal:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/cc3200\/17-run.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-17\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/cc3200\/17-run.png\" alt=\"17-run\" width=\"698\" height=\"768\" \/><\/a><\/li>\n<li>Use a computer or a phone with WiFi capability to connect to the WiFi network reported by the board. Then open <strong>mysimplelink.net\/main.html<\/strong> in a browser (just <strong>mysimplelink.net<\/strong> opens a page from a different project):<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/cc3200\/18-mainhtml.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-18\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/cc3200\/18-mainhtml.png\" alt=\"18-mainhtml\" width=\"637\" height=\"570\" \/><\/a><\/li>\n<li>Click the Demo link and then click the On and Off labels on the Demo page:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/cc3200\/19-ledctl.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-19\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/cc3200\/19-ledctl.png\" alt=\"19-ledctl\" width=\"637\" height=\"372\" \/><\/a><\/li>\n<li>See how the red LED on the board goes on and off:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/cc3200\/20-redled.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-20\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/cc3200\/20-redled.jpg\" alt=\"20-redled\" width=\"700\" height=\"342\" \/><\/a><\/li>\n<li>Put a breakpoint in the <strong> SimpleLinkHttpServerCallback() <\/strong>function in Visual Studio and click the ON or OFF label in the browser. The breakpoint will be triggered:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/cc3200\/21-callback.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-21\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/cc3200\/21-callback.png\" alt=\"21-callback\" width=\"698\" height=\"733\" \/><\/a><\/li>\n<li>Step through the method to see how the sample program extracts the data about the HTTP request:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/cc3200\/22-ledtoken.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-22\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/cc3200\/22-ledtoken.png\" alt=\"22-ledtoken\" width=\"699\" height=\"643\" \/><\/a><\/li>\n<li>The actual HTTP requests are handled by the second core of the CC3200 chip that is not directly exposed to our firmware. Instead, the firmware exchanges messages with the core by using the SImpleLink APIs included in the CC3200 SDK. We will now modify the sample to pass one additional message. First, add the following line to the <strong> led_demo.html<\/strong> file after the body tag:\n<pre>&lt;div&gt;__SL_G_TST&lt;\/div&gt;<\/pre>\n<p><a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/cc3200\/23-led-demo.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-23\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/cc3200\/23-led-demo.png\" alt=\"23-led-demo\" width=\"698\" height=\"646\" \/><\/a><\/li>\n<li>Reprogram the serial FLASH memory using the UniFlash tool (don&#8217;t forget to move the jumper to J15 and back):<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/cc3200\/24-reflash.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-24\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/cc3200\/24-reflash.png\" alt=\"24-reflash\" width=\"681\" height=\"580\" \/><\/a><\/li>\n<li>Then modify the C source accordingly. Find the call to <strong>memcmp(pSlHttpServerEvent-&gt;EventData.httpTokenName.data<\/strong> in main.cpp and add the following code before it:\n<pre>if (!memcmp(pSlHttpServerEvent-&gt;EventData.httpTokenName.data,\r\n       \"__SL_G_TST\", strlen(\"__SL_G_TST\")))\r\n{\r\n    constchar *pReply = \"Hello, World!\";\r\n    strcpy((char *)ptr, pReply);\r\n    pSlHttpServerResponse-&gt;ResponseData.token_value.len += \r\n                strlen(pReply);\r\n}<\/pre>\n<p><a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/cc3200\/25-hello.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-25\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/cc3200\/25-hello.png\" alt=\"25-hello\" width=\"698\" height=\"646\" \/><\/a><\/li>\n<li>Start debugging by pressing F5, update the page in the browser and see how &#8220;Hello, World&#8221; is now displayed on top of the page:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/cc3200\/26-newpage.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-26\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/cc3200\/26-newpage.png\" alt=\"26-newpage\" width=\"637\" height=\"372\" \/><\/a><\/li>\n<li>If you set a breakpoint in the new code and refresh the page again, you can explore the values of other fields of the message sent from the HTTP server to your firmware:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/cc3200\/27-bkpt.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-27\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/cc3200\/27-bkpt.png\" alt=\"27-bkpt\" width=\"699\" height=\"645\" \/><\/a><\/li>\n<\/ol>\n<p>Once you are done experimenting with the HTTP server, you can check out other samples available through the project wizard, like the TCP socket sample or the email sending sample.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial shows how to program the CC3200 microcontroller to create a WiFi access point that will allow connected users<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[53,55,56,102],"_links":{"self":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/107"}],"collection":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/comments?post=107"}],"version-history":[{"count":1,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/107\/revisions"}],"predecessor-version":[{"id":616,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/107\/revisions\/616"}],"wp:attachment":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media?parent=107"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/categories?post=107"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/tags?post=107"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}