Lab 1 : Embedded System Intro
EEC 172: Lab #1 - Embedded System Intro
Author : Kelly Su, Tony Xiao
Intro
The objective of this lab was to learn the basics of Code Composer Studio, CCS Uniflash and the TI Pin Mux Tool. After setting up the workspace for CSS and settings/properties configuration for the needs of our projects and establishing the appropriate port connections, the CCS3200 device can communicate with the CCS development tool to run applications. Two example CCS project were used in this lab: the ‘blinky’ project and the ‘uart_demo’ project. The ‘blinky’ project was used as sample program where we learned to change the frequency of the LED lights that flashed. This project will then be modified in part II, as an exercise to configure the CC3200 LaunchPad with the CCS application using the TI Pin Mux tool to create the correct mapping code for the inputs and outputs. The ‘uart_demo’ project is used to demonstrate the use of the APIs to display the program responses from the circuit board onto the terminal emulator by establishing a serial connection. Finally, the last part of our lab is essentially a tutorial on how to use TI’s Uniflash to load an application onto the CCS3200 LaunchPad to allow the program to persist and execute without the CCS application.
Background
The CCS software is used to read signals from CC3200 LaunchPad that is connected to our computer through USB and runs user-defined code. Initially, a workspace environment and target configuration must be set up in order configure the environment for communication between the CC3200 LaunchPad and the software as well as setting up the correct port. Once a connection is set up, the program is loaded onto the RAM of the CC3200 LaunchPad, which can then simulate signals to the LEDs and detect inputs from the switches. A port connection between the CCS software and the terminal emulator can be set up in order to read the output of the program.
The TI Pin Mux tool is used to easily generate pin configuration code using the mapping between the the physical banks and pin numbers to virtual pin variables. This is called ‘PinMuxing’ and is useful because it provides an interface to be used with the GPIO API to easily detect input signals and control output signals using written application code. The generated code can be integrated into our CCS application. This tool is extremely helpful in order to map the correct input pins and output signals to the correct variables without the user having to write the code themselves, thereby avoiding errors that could be difficult to detect and time-consuming if detected late while coding the application.
The CCS Uniflash software is used to program the external flash memory on the CC3200 LaunchPad in order to have the program preserved without having to load the application using the CCS software. The program will live on the the launchpad between power cycles.
The UART module is a serial connection communication protocol between the transmitter and receiver (port 5 of the computer in our case and the circuit board). The baud rate can be modified to set the pace that the response signal is received from the board to our monitor (terminal) if a switch is pressed or if the transmitter triggers some signal to/from the board. The UART API handles all of this for the user and enables signal, flow and parity bit control and clock configuration.
The GPIO module is an API tool that allows input/output signals to be sent and detected given the correct bank and port. In this lab, two specific functions will be used: GPIOPinRead() and GPIOPinWrite(). GPIOPinRead() returns 0 or 1, depending on the state of the input signal of the device. When a switch is pressed on the launchpad, the function will return 1. GPIOPinWrite() does the opposite as it sends the correct signal to a pin, 1 to light up a LED or 0 to turn it off.
Goals
Part I: blinky example program
Make the LEDs blink two times faster than in the default program.
Part I: uart_demo
Make input echo on the terminal console
Part II:
Display message on console window with header and use instructions when program starts. When SW3 is pressed, the three LEDs start a binary counting sequence on the LEDs from 000 - 111 continuously, and print to console “SW3 pressed” When SW2 is pressed, the LEDs blink ON and OFF in unison, and print “SW2 pressed” instead of “SW3 pressed” Set the output signal P18 high whenever SW2 is pressed and low whenever SW3 is pressed
What we learned from these tasks:
How to set up a workspace environment in CCS Change the property configurations Debug and run an application Load the software onto the CC3200 LaunchPad using Uniflash Change the frequency of LEDS Learn to use PinMux Learn to use UART module and GPIO API Learn how to set up a port connection and baud rate Manipulate the LEDs to blink to a pattern of choosing, in addition to the response to a switch
Methods
Part I: blinky program
Inside the “void LEDBlinkyRoutine()” function, change the “MAP_UtilsDelay(8000000);” to “MAP_UtilsDelay(4000000);”
Increasing the value passed into the function increases the frequency of the blinks because it increases the delay time between the blinks.
Part I: uart_demo:
Using the Tera Term emulator, we could display the output of the application, use it as an interface to send/receive data from/to the launchpad. We learned that the baud rate (bps) determines the pulse width, or how much data to read per second.
Part II: Our implementation:
Using the same function (Report())as in uart_demo project to print out the message in the console.
Using the api GPIOPinRead() to read the value of SW2 and SW3. According to the manul SW3 is PIN 4, and check the pin_mux_config.c file, we find that SW3 is in GPIOA1_BASE port and the pin is 0x20. Also in the TI manual, the SW3 is in GPIO bits 5, so we shift the result from GPIOPinRead() to get the fifth bit(SW3). After getting SW3 is pressed, we print a message to the console, set the value of SW2 as 0 and P18 low by calling GPIOPinWrite(). We use a for loop to count from 0 to 7. By calling GPIO_IFLedOn(MCU_RED/ORANGE/GREEN_LED_GPIO), make the LEDs on according to the binary value of the counter. We keep the counting part inside a while loop to make sure it counting continuously and we break this while loop whenever it catches SW2 is pressed.
SW2 routine is basically the same idea.
P18 is in GPOIA3_BASE port, and ucPins is at 0x10, at bit 4, so we need to set that value to be high. Since bit 4 is at 5th position, we need left shift decimal value 1 by 4 places to assign bit 4 to be 1.
We used PinMux to get the GPIO interface of the pins and switches to reference in our program. We learned how to read and write to the pins and polling the switches in our program. Our program implementation uses a while(1) outer loop to constantly poll the input of the switches. Inside that loop after reading the input, we would check which switch is pressed and also a flag. The flag indicates the state of the program, whether switch 2 or switch 3 was pressed previously. If the same switch is pressed twice, the program would not react. When switch 2 was pressed and not previously pressed, we would make all the LEDs blink in unison repeatedly. When switch 3 is pressed and not pressed previously, an inner while loop would run that would make the LEDs count up from 0 to 7 in binary continuously. Our implementation requires that switch 2 be pressed at the end of the count (count 7) in the program in order to have switch 2 react since we do not poll after each count. Afterwards, we loaded this program onto the RAM of the launchpad to keep the application persistent using UniFlash and checked that the program ran without the CCS application.
Discussion
The most difficult challenge we ran into was figuring out port addresses and pin numbers in order to get the correct signal from the switches. We also had trouble writing the program code for part 2 as we had to set up a lot of breakpoints at different points in the program’s execution to see at which point in our program the signals were detected when using GPIOPinRead() and triggering a switch. This was important to figure out because we had to know precisely when to press SW2 and SW3 depending on where our GPIOPinRead() was called in our while loop to allow for continuously counting up to 111 and disabling a switch from executing twice in a row.
Conclusion
We learned how to set up the CCS projects and connect the configure the settings CCS software to connect with the CC3200 LaunchPad so the CCS application code can run on the circuit board. We also learned how to set the frequency of the blinks of the LED lights in the first part of the lab by adjusting the value of the delay function in the LEDBlinkyRoutine() function. We also learned to create a connection between computer port and the circuit board to have the terminal emulator display the program responses. We also learned to use the PinMux tool to generate the mapping of the physical banks and pins to the pin variables based on the GPIO interface. We made a sample application by modifying the blinky program to learn how to get the signal input and write the output onto the circuit board. Afterwards, we used Uniflash to program our board to save the program on the flash memory of the circuit board in order make it non-volatile so that it can run independently from the CCS software application.