Contents
1. Introduction
2. CC3200 Overview
3. What is a LaunchPad?
4. CC3200 LaunchPad Tour
5. CC3200 Example Applications
6. Getting Started: Installing Development Tools
7. What is UniFlash?
8. Service Pack Update
9. Building a Demo Program
10. Running the Demo Program
11. Working with Other Example Applications
12. Using General Purpose I/O
13. Using I2C
14. Summary
1. Introduction
The CC3200 has been a recent revolution; it is advertised as the first “internet-on-a-chip” solution with combined microcontroller and 802.11 (Wi-Fi) connectivity to easily connect to services on the Internet, all in a single integrated circuit.
It is available on the CC3200 LaunchPad board CC3200 LaunchPad board shown in the photo below, and is great for developing IoT solutions that need high levels of connectivity and compute performance yet need to run on tiny amounts of power.
This post is intended to provide a beginner’s tutorial on how to use the CC3200. It covers how to develop and compile software, and how to interface to hardware using general-purpose I/O (GPIO) and I2C serial interfaces. The next part will cover network connections and working with HTTP content.
The example application that will be covered is a Weather Monitor. This project just needs one component - an LCD displayLCD display - and some jumper wires.
2. CC3200 Overview
The CC3200 contains a variety of features including an in-built network processor to handle popular protocols such as TCP and UDP, secure connectivity including TLS/SSL, and a main ARM Cortex-M4 core for running applications. In fact the CC3200 is a multi-processor chip; the network processor subsystem inside contains another ARM core dedicated for that task.
The CC3200 has lots of in-built peripherals, and also in-built DC-DC converters so that it can operate with a very battery-friendly supply range of 2.1-3.6V. For a custom board, the bill-of-materials is tiny; just 19 different component types are needed to construct a typical application circuit.
The CC3200 would be useful for IoT devices including nodes and gateways.
The development board, called the CC3200 LaunchPad, is now possibly the lowest cost platform available with combined high-end microcontroller and 802.11 functionality on-board.
The CC3200 is ideal if you don’t need a Linux kernel, want to dramatically decrease power consumption but at the same time need something with a very good level of compute performance and microcontroller I/O.
For people that were considering Linux, the CC3200 programming interface looks very close to the standard BSD (or POSIX) socket application programming interface (API), and there is a real-time OS (RTOS) available.
For those that were considering SPI or other serial-interfaced wireless products connected to a microcontroller, the CC3200 offers familiar deep microcontroller-level control without needing Linux driver knowledge, and lots of built-in peripherals to explore and use.
Where the CC3200 shines in comparison with Linux based platforms is in low power consumption. Just tens of milliamps of current is consumed during sustained data transfer (higher for transmit) and when there is no data but the device needs to remain connected to the wireless access point, the current consumption can drop to as low as 120uA. This could be a huge competitive advantage for products designed with the CC3200.
Unlike many microcontrollers which contain built-in Flash memory for storing the code, the CC3200 has a large chunk of in-built Static RAM (SRAM) that is loaded with the code from an external 8-pin serial Flash chip. The external Flash chip has an entire file system and can be used to optionally store additional files (more on this later).
The main source for all information CC3200 related is the CC31xx and CC32xx Wiki page. It contains CC3100 and CC3200 information (scroll down for CC3200 on that page). It is an essential resource and you will probably want to bookmark it.
3. What is a LaunchPad?
LaunchPads are Texas Instruments (TI) microcontroller evaluation boards – similar to Arduino boards. Many add-on boards known as BoosterPacks are available too, for example to interface a display onto a LaunchPad.
The I/O connections on the LaunchPad are standard 2.54mm header pins/sockets, so they can be easily connected up to custom hardware too.
In terms of programming, there is an environment called Energia which allows Arduino enthusiasts to have a near-identical experience compared to their Arduino programming environment. There is also a more conventional integrated development environment (IDE) called Code Composer Studio (CCS) available for free, and commercial third party IDEs such as IAR Embedded Workbench are available too. This getting-started guide will use CCS.
4. CC3200 LaunchPad Tour
The CC3200 LaunchPad is feature-packed. It is about the size of a Raspberry Pi and contains two 20-pin headers that provide general purpose I/O, ADC channels, I2C, SPI, PWM and other functions. The board contains a built-in USB-to-JTAG interface intended for debugging and for FLASH memory programming; no additional programming hardware is needed and the interface can be optionally connected up to CC3200 devices on custom boards too.
There is a built-in 802.11 antenna, some general purpose switches and LEDs and a nice ‘sensor area’ which contains an accelerometer and ‘thermopile’ sensor which can measure temperature remotely by pointing it at an object.
The whole board can be powered from the USB port, or from a couple of AA batteries! Of course, the experimenters may attempt solar power too; this should be feasible given that there are some great low-power modes.
5. CC3200 Example Applications
The CC3200 would be great for IoT sensor nodes; it has standard SPI and I2C interfaces for sensors and can connect to existing 802.11 networks. It could also be used as part of a gateway, to connect other forms of wireless access (such as ISM band devices) to the Internet.
The CC3200 can operate as a wireless access point (AP) and therefore could find interesting mobile applications. It has built-in HTTP server functionality that could be used to offer a rich browser-based user interface (UI) for complex devices.
The CC3200 is backed up by over 50 application code examples available from TI; this is very comforting to see because it means that a lot of the work has already been done and code snippets can be copied to create custom solutions.
6. Getting Started: Installing Development Tools
Note: All the information here refers to Windows. If you use Linux or Mac desktop, you may need to search elsewhere for additional information (or run Windows in a virtual machine). CCS is available for Linux, but some other development tools may not be.
As mentioned earlier, there are several different development environments usable with the CC3200. This guide uses TI’s Code Composer Studio (CCS).
As well as CCS, quite a few other tools will also be needed; all install seamlessly, and the information is below.
The things that need installing are listed below:
Item | Description |
---|---|
Code Composer Studio (CCS) | Integrated Development Environment (IDE) – compiler, linker |
CC3200 Software Development Kit (SDK) | Source code for drivers, OS and example applications |
UniFlash (SimpleLink version) | A tool for transferring files from the PC to the Serial Flash on the LaunchPad |
CC3200 SDK Service Pack | A firmware update for the CC3200; it is uploaded using UniFlash |
PinMux Tool V3 | Windows software that is useful for GPIO configuration assistance |
If you already have CCS installed (it is used for other TI microcontrollers too) then click on Help->Getting Started and then select App Center.
Type cc3200 in the search box and install the two results (CC3200 Add-On and TI-RTOS for SimpleLink).
If you don’t already have CCS installed, it can be obtained from here.
6.1 CCS Install Notes
The guide to follow is the CC3200 Getting Started Guide (PDF). I installed it in a folder I called C:\ti (TI software is usually well-behaved and will all then install into the same top folder). At the Processor Support screen, select SimpleLink Wireless MCUs (and any others you may want). Once it has installed, when you run it for the first time it will ask for a Workspace folder, which will become the top-level folder into which projects can be created. You could select something like C:\work\ccs_workspace as an example. At the Getting Started screen, click on App Center, type CC3200 and select CC3200 Add-On and TI-RTOS for SimpleLink and click the Install Software button.
If you’ve not used CCS before, the hammer icon will be used to compile software, the bug icon will be used to transfer the code to the LaunchPad and run it, and the indication on the right which says CCS Edit (see screenshot below) will show when the view is switched a view more suitable for code entry to a view more suitable for debugging (you won’t ordinarily need to click here). A view is just a set of panes or sub-windows, so for code entry you can expect the view to show the source code folder pane, a text editor and a compile output pane; the debugger view will show variable and disassembly window panes. So, if things on the screen re-arrange themselves automatically when you click on the bug icon, it is a sign that the view has been switched.
You can close the CCS App Center and Getting Started windows by closing the tabs.
Once you do that, you’ll see the CCS Edit view is nicely divided up into a folder section, the code entry section and a problems/status type of area below:
Proceed to install the remainder software; the install notes below can be used as a guide.
6.2 CC3200 SDK Install Notes
Close CCS for now. Next install the CC3200 SDK (it should now automatically create a new sub-folder inside your C:\ti top-level folder). Click ‘Yes’ to install the FTDI driver when prompted.
6.3 UniFlash-SimpleLink, PinMux-V3 anf CC3200 SDK Service Pack Install Notes
These three pieces of software will also automatically install itself themselves into a sub-folder below C:\ti.
6.4 Review
At the end of all the software installation steps, the top-level C:\ti folder will look like this:
The Windows Start menu will have a Texas Instruments folder with lots of stuff. The items that will be used regularly are marked below. Also, the CC3200 SDK folder contains lots of useful documents that are worth referring to.
7. What is UniFlash?
As mentioned earlier, the CC3200 relies on a separate small Serial Flash device for storing files including the program to run. The Flash device contains all the data arranged in a file system. To transfer data to this file system from a PC, UniFlash is used. Note that it is not possible to extract files in the other direction (Flash to PC) using UniFlash, nor is it possible to see the file names of what is stored on the Flash. This implies that to delete content, you will need to know in advance the file name of what was stored on the Flash, or you would need to re-format it to get it back to a known state. UniFlash is not an entirely straightforward piece of software, but is very important to know how to use it.
When using UniFlash, there is a jumper that needs connecting on the CC3200. The jumper is supplied as shipped connected across a couple of pins, remove it and place it in the 'normal position' (shown in the diagram below as a white jumper), but move it to the ‘UniFlash position’ when using UniFlash or the debugger (don’t forget to move it back to the normal position afterwards). Note that this jumper is only read on reset, so if the position is changed, hit the RESET button on the LaunchPad (it is the closest one to the USB connector).
8. Service Pack Update
UniFlash as described above is also used to transfer service pack updates to the CC3200. To do this, click on New Target Configuration in UniFlash, then click OK. You should see a view as shown below.
The COM port number (30) shown in the screenshot above will need changing. Plug in the LaunchPad into the PC, and drivers will be installed. Then type ‘Device Manager’ after clicking on the Windows Start button, and check what COM port number the LaunchPad was allocated:
Once you know this, change the ‘30’ to the correct COM port number. Move the jumper to the UniFlash position. Then click on Service Pack Update and navigate to C:\ti\CC31xx_CC32xx_ServicePack_1.0.0.1 and select the servicepack_1.0.0.1.0.bin file (numbering may vary). During the update, if UniFlash prompts to ‘please restart the device’ at any time, click the RESET button on the LaunchPad. After the service pack update is complete, move the jumper back to the ‘normal’ position.
9. Building a Demo Program
The first step is to run an existing demo program (afterwards it can be modified into the desired program). The process to build a demo program is described in the Getting Started guide in section 3.1.3 and is well documented. At step 10, a file needs to be modified with your wireless network settings. Open with your favourite text editor and modify it as required.
Step 12 builds the demo project called wlan_station. Over time, as more projects are created, they will appear in the Project Explorer pane. To select any project, just click on it until it says Active, as shown below. It is good to just visually confirm like this, so that you’re on the correct intended project, before building a project.
Step 15 concerns creating a ‘target configuration’. If it fails (it did for me when I used an older CCS install, worked fine on a newer instal), the issue can be resolved by right-clicking and selecting New Target Configuration in CCS, giving it a name, and then double-clicking on it and configuring it as shown here; note that you will be able to save it, but ‘Test Configuration’ will remain grayed out; this is fine.
10. Running the Demo Program
The demo programs send text information to the PC using a virtual serial port over the USB connection. Software such as PuTTY is required, select the COM port as before and set the baud rate to 115200 and then select connect in PuTTY.
On the LaunchPad, ensure the jumper is in the UniFlash/Debugger position (this is not strictly needed on an off-the-shelf LaunchPad, but will be needed if you have flashed your own programs as will be seen later), and press RESET. Now, double-check that the wlan_station project is still selected in the Project Explorer, and then click the ‘bug’ icon. The view will now change to the debugger mode as shown below. The important controls are highlighted:
From this debug view, it is possible to start the program by clicking the green Run/Resume icon, and it is possible to stop the debug session (and revert back to the normal Edit view) by clicking the red Terminate icon (it doesn’t necessarily terminate the program as such, but it will put you back into the usual code editing view).
There are code stepping options and a pause button to temporarily suspend the program execution. Whenever these buttons are used, the Debug pane shows the stack trace from bottom-up; the example here shows a suspended program which is currently in a while() loop, and the stack trace shows that the function WlanStationMode called a function CheckLanConnection. There are extensive debug facilities but they are beyond the scope of this post. Application-level debugging is possible using print statements in the source code.
Time to run the program! When the green Run/Resume icon is clicked, the program will execute, and the terminal software (e.g. PuTTY) will display the following output:
11. Working with Other Example Applications
There is a wealth of example applications in the CC3200 SDK example folder. They can be added to the workspace if desired by selecting Project->Import CCS Projects and selecting the C:\ti\CC3200SDK_1.0.0\cc3200-sdk\example folder and then choosing one of the projects (however often it is not necessary to add a project to a workspace; just viewing the code can be sufficient to get some ideas).
12. Using General Purpose I/O
There are four 10-way single-in-line (or two DIL 20-way depending on how you see it) header pin and socket type connectors on the LaunchPad. Most of the pins on the CC3200 are overloaded, meaning that a choice often needs to be made for what function is desired for each pin. The connectors are labelled P1-P4.
Useful references are the CC3200 LaunchPad circuit diagram (which will show which pins are connected to LEDs, switches etc) and the LaunchPad Hardware Guide (PDF).
As an example, if it is desired to control the physical fifth pin on connector P1 as an output (e.g. to connect up an external LED), it can be looked up in the Hardware guide. As shown below, that fifth pin is a GPIO-capable pin, and the actual real pin number on the CC3200 integrated circuit it is wired to is pin 61.
The real pin number can be mapped to a logical internal GPIO number using the PinMux tool installed earlier. Start it up and select the CC3200 as shown below.
Hover over pin 61 in the chip view, and it will display the details about that pin; it can be seen that pin61 is internally wireable to GPIO06.
Next, select GPIO on the left under ‘Available Peripherals’, click Add and then deselect all the GPIO signals and then select just GPIO06, and click in the ‘Output’ column. All this is shown in the screenshot below:
Once you are done this, click Generate and select a temporary folder. In that folder, four files will be created. You can cut and paste that code into your project. Here is the bit of code that is needed; it is a function called PinMuxConfig:
void PinMuxConfig(void) { // // Enable Peripheral Clocks // MAP_PRCMPeripheralClkEnable(PRCM_GPIOA0, PRCM_RUN_MODE_CLK); // // Configure PIN_61 for GPIO Output // MAP_PinTypeGPIO(PIN_61, PIN_MODE_0, false); MAP_GPIODirModeSet(GPIOA0_BASE, 0x40, GPIO_DIR_MODE_OUT); }
If you’re working with a project based on one of the demo examples, then there may already be a function somewhere that does this for other pins, and so the three lines of actual code in the function above can be inserted into that function. The example projects have this in a file called pinmux.c. If the project does not have this file, just copy the pinmux.c and pinmux.h files from another example project into your project folder inside your workspace folder, and then edit them.
To make life a bit easier, the image below can be referred to, to check what each pin is capable of. Any pin marked with an asterisk is not connected by default but can be by using zero-ohm resistor links.
The information is also pasted here to make it easier to read:
Connector P1
PCB Ref | Signal | IC pin | Alternative Signals |
---|---|---|---|
1 | 3V3 | ||
2 | ADC_CH1 | 58 | UART1_TX, CAM_pDATA7, GPIO03 |
3 | UART0_RX | 4 | GPIO13, HSYNC, I2C_SDA, CCP04 |
4 | UART0_TX | 3 | GPIO12, VSYNC, McASP0_McACLK, I2C_SCL |
5 | GPIO06 | 61 | CAM_pDATA4, CCP06 |
6 | ADC_CH2 | 59 | GPIO04, CAM_pDATA6, UART1_RX |
7 | SPI_CLK | 5 | GPIO14, CAM_pDATA8, I2C_SCL, CCP05 |
8 | GPIO07 | 62 | UART0_TX, McASP0_McACLKX |
9 | I2C_SCL | 1 | GPIO10, PWM06, SDCARD_CLK, UART1_TX, CCP01 |
10 | I2C_SDA | 2 | GPIO11, PWM07, SDCARD_CMD, pXCLK, UART1_RX, CCP02, McASP0_McAFSX |
Connector P3
PCB Ref | Signal | IC pin | Alternative Signals |
---|---|---|---|
1 | 5V | ||
2 | GND | ||
3 | ADC_CH0 | 57 | GPIO02, UART0_RX, UART1_RX, CCP02 |
4 | ADC_CH3 | 60 | GPIO05, CAM_pDATA5, McASP0_McAXR1, CCP05 |
5 | ADC_CH1 | 58* | UART1_TX, CAM_pDATA7, GPIO03 |
6 | ADC_CH2 | 59* | GPIO04, CAM_pDATA6, UART1_RX |
7 | AUD_SYNC | 63 | GPIO08, SDCARD_IRQ, McASP0_McAFSX, CCP06 |
8 | AUD_CLK | 53 | GPIO30, McASP0_McACLK, CCP05, SPI_MISO, UART0_TX |
9 | AUD_DOUT | 64 | GPIO09, PWM05, SDCARD_DATA, McASP0_McAXR0, CCP00 |
10 | AUD_DIN | 50 | GPIO00, McASP0_McAXR0, McASP0_McAXR1, CCP00, SPI_CS |
Connector P4
PCB Ref | Signal | IC Pin | Alternative Signals |
---|---|---|---|
1 | PWM07 | 2* | GPIO11, SDCARD_CMD, pXCLK, UART1_RX, CCP02, McASP0_McAFSX, I2C_SDA |
2 | PWM06 | 1* | GPIO10, SDCARD_CLK, UART1_TX, CCP01, I2C_SCL |
3 | PWM00 | 17* | GPIO24, UART1_RX, CCP06, McASP0_McAFSX, I2C_SDA |
4 | PWM05 | 64* | GPIO09, SDCARD_DATA, McASP0_McAXR0, CCP00, AUD_DOUT |
5 | GPIO25 | 21* | McASP0_McAFSX, PWM02 |
6 | GPIO28 | 18* | |
7 | GPIO07 | 62* | UART0_TX, McASP0_McACLKX |
8 | GPIO05 | 60* | CAM_pDATA5, McASP0_McAXR1, CCP05, ADC_CH3 |
9 | GPIO23 | 16 | UART1_TX, I2C_SCL |
10 | GPIO24 | 17 | UART1_RX, CCP06, PWM00, McASP0_McAFSX, I2C_SDA |
Connector P2
PCB Ref | Signal | IC pin | Alternative Signals |
---|---|---|---|
1 | GND | ||
2 | GPIO28 | 18 | |
3 | SPI_CS | 8 | GPIO17, CAM_pDATA11, UART1_RX, SDCARD_CMD |
4 | GPIO31 | 45 | UART0_RX, McASP0_McAXR0, SPI_CLK, UART1_RX, McASP0_McAFSX |
5 | RESET_OUT | ||
6 | SPI_MOSI | 7 | GPIO16, CAM_pDATA10, UART1_TX, SDCARD_CLK, CCP07 |
7 | SPI_MISO | 6 | GPIO15, CAM_pDATA9, I2C_SDA, SDCARD_DATA, CCP06 |
8 | GPIO25 | 21 | McASP0_McAFSX, PWM02 |
9 | GPIO01 | 55 | PIXCLK, UART0_TX, UART1_TX, CCP01 |
10 | GPIO22 | 15 | CCP04, McASP0_McAFSX |
Once you have worked through the pin configuration detail and added it to the pinmux.c file, then the main code (e.g. main.c) needs this:
// only needed the include line if the project doesn’t already have this included: #include “pinmux.h” #define LED_GPIO 6 #define LED_PIN_LOW GPIO_IF_Set(LED_GPIO, my_led_port, my_led_pin, 0) #define LED_PIN_HIGH GPIO_IF_Set(LED_GPIO, my_led_port, my_led_pin, 1) unsigned int my_led _port; unsigned char my_led_pin; GPIO_IF_GetPortNPin(LED_GPIO, &my_led_port, &my_led_pin); LED_PIN_HIGH; // set pin high LED_PIN_LOW; // set pin low
The example above can control an output pin. To read a pin, use the PinMux program to get the input configuration code, and then the status of the pin can be read using the GPIO_IF_Get function, e.g. GPIO_IF_Get(SWITCH_GPIO, my_switch_port, my_switch_pin). A non-zero value means that the pin is high.
13. Using I2C
Using I2C again means visiting the PinMux oracle. In this case, select I2C as the desired peripheral on the left, add it, and then select the physical chip pins; from the LaunchPad connector diagram it was clear that connector P1 pins 9 and 10 (for SCL and SDA) were usable, and these are wired to the physical chip pins 1 and 2 respectively. Click on ‘Generate’.
The generated code looks like this:
void PinMuxConfig(void) { // // Enable Peripheral Clocks // MAP_PRCMPeripheralClkEnable(PRCM_I2CA0, PRCM_RUN_MODE_CLK); // // Configure PIN_01 for I2C0 I2C_SCL // MAP_PinTypeI2C(PIN_01, PIN_MODE_1); // // Configure PIN_02 for I2C0 I2C_SDA // MAP_PinTypeI2C(PIN_02, PIN_MODE_1); }
To use I2C, there is already existing I2C helper code in a file called i2c_if.c and it can be manually copied from one of the example folders (it can be found in cc3200-sdk/example/common) into your active project folder.
To use it:
#include “i2c_if.h” // 7-bit address: #define MY_DEVICE_ADDR 0x30 I2C_IF_Open(I2C_MASTER_MODE_FST); char data[5]={0x11, 0x22, 0x33, 0x44, 0x55}; I2C_IF_Write(MY_DEVICE_ADDR, data, 5, true);
Refer to i2c_if.h for the remainder functions in this library. To slow the I2C bus speed down (it is 400kHz by default) there is a constant in i2c_if.c that can be modified (higher value is a slower speed).
In a similar vein, there is lots of example code for controlling the other peripherals inside the CC3200 too, such as SPI, timers and PWM. Just explore the cc3200-sdk/example folder!
14. Summary
The CC3200 is excellent for IoT applications; it contains a low power high-performance Cortex-M4 processor and in-built 802.11 wireless capability.
The CC3200 LaunchPad is about the lowest cost microcontroller platform that exists with these features. This post investigated what software tools are needed for development, how to install them, how to access example code applicatons and build and run them, and how to control I/O pins for interfacing to hardware.
The schematic, tables and the PinMux utility are essential for making the most of the built-in peripherals in the CC3200.
Top Comments