This lab builds on the PWM and RGB LED work we’ve done earlier. The goal is for you to be comfortable with SPI serial communications. This particular device will be one foundation of the Simon game.
Your commented rainbow_spi.c
, rainbow_spi.h
, and main.c
files. Specifically, the
comments should include any instructions that peer graders might need to compile and run your
code. Please include the proper interrupt compiler directives to ensure that both the TI and
gcc compilers will work.
Answers to the questions in a text or otherwise broadly-accessible format. [NOT FOR 2023]
In the old days, students would have to cut a piece of APA102 strip. Starting in 2021, use the prefabricated Simon PCB, which has 4 LEDs arranged in a circle.
(Not required starting in 2021!!!) If you are wanting to solder the LED strips here’s the
old instructions. Take care to leave as much of the perforation intact on the entry side of
the strip. (There are directional arrows which point in the direction of signal flow.) Solder
4 jumper wires to the exposed copper perforation holes as shown in the second picture to the
left. When looking from the front, the 4 perforations are VCC, CLK, DATA, GND
. I found that
the easiest way to solder was to first apply lots of flux and then melt solder onto the
perforations, making sure that it actually had flowed onto them. Then, I pre-tinned the exposed
ends of the jumper wires. Finally, I held the jumper wires in place on each of the
perforations and applied heat to reflow the solder. Once you get a good connection, you may
want to apply some epoxy resin over the wires.
Let’s review serial communications. Also take a look at the documentation for the APA102 device.
Now let’s review the characteristics of the serial control hardware block in your MSP430s, the USCI.
The Simon PCB has 4 APA102C RGB LEDs connected to a MSP430 using appropriate SPI clock and COPI lines. Three sample files are provide for you: main.c, rgb_interface.c, and rgb_interface.h. These files demonstrate configuration of the USCI module so that the SPI clock frequency is within the acceptable range for the APA102C, and the data communication clock edges are proper. These examples also serve as an example of how to do modular programing. The current interface for LED control should be abstracted at least one more level as part of this lab.
The goal for the lab is to achieve a moving, color cycling effect.
You should modify the API so that the main.c
function can simply call a
set_temperature(int LED1_temp, int LED2_temp, int LED3_temp, int LED4_temp)
function.
Here, the value of “temperature” should map to a color in the RGB space in a sensible way.
The wikipedia page on color temperature includes
the diagram to the right. The goal is that your function makes a nice 1-dimensional mapping
through 3-dimensional color space. (It doesn’t have to correspond to temperature in Kelvin
or wavelength or whatever other logical things might be imagined.)
This lab builds on the previous one in the sense that hopefully you already
figured out some RGB values that make a nice rainbow!
Special Case: The value 0 of temperature should mean the LED is off!
Then configure the logic in main.c
such that each LED should cycle one step behind the
previous one so that the rainbow appears to move upward. Use the _250ms
watchdog timer interrupt for timing, and increment
the temperature each time step. (This is already set in the current file!)
To accentuate the effect of rotating colors, make one LED off (i.e., temperature 0) each time step,
and have the LED which is off shift around the circle.
You should implement at least 32 levels of color. BUT, the color changes should be distinctly visible.
Note: We have noted that different generations
of the APA102 LEDs have different color order (GRB vs BRG). Make sure that your code works
for your LEDs. If you have different LEDs on your board, you can fix it programatically
or by resoldering.
Optional Once you have finished the rest of the lab, come back to rgb_interface.c
and
convert it to use th USCI TX interrupt.