Lab #3: Timers, PWM, and Logic

The goals of this lab are two-fold. First, we aim for you to continue gaining experience understanding active and low power modes. Second, the goal is to begin to do more complex software design involving multiple digital IO pins interacting and multiple interrupts.

This assignment is due Wednesday, Febrary 8, 2023.

Display PCB

Lab 3 35-LED display PCB.

The PCB has been largely pre-soldered for you, but you will need to attach the LED module and a programming header. If you want to add the battery pack or side-connection headers, you can also do that.

In order to do the lab, you will need to reference the board and/or schematic files in order to know how the LEDs are connected to the MSP430. These PCB design files are done in EAGLE cad, which you can download from the Autodesk website for free. You will need to learn how to use this software later in the course, so it’s a good idea to begin familiarizing yourself with it. In the meantime, a screen shot of the schematic can also be found here.

  1. (Not scored!) Either examine the PCB closely or look at the schematic for the display. Which GPIO pins are connected to LEDs?

  2. (Not scored!) In a normal, canonical (i.e., atomic), forward operating (i.e., not-breaking-down) diode, which terminal does positive (conventional) current flow out of, cathode or anode? In the display circuit, which pin(s) is this terminal connected to?

  3. (Not scored!) What values for the rows and columns (0 or 1) will result in the bottom left and top right diodes turning on?

Precise modeling of the current/voltage characteristic of a diode is complicated, but important for a number of applications (such as detecting light with a photo diode). A very simple model of a diode switches from infinite resistance to zero resistance at the “threshold voltage”. Thus, when on, the current through the diode must be limited. A resistor in series with the diode serves to limit the current, and you will see such a resistor in the display schematic. In order to find the proper value of this resistance, you need to know something about the LED and also something about the rest of the circuit.

Here is a helpful video:

Lab Specification

The first part of the design is to implement an incrementing numeric display using the PCB. The numbers should increment once per second.

The final part of the lab is that you should have another variable that determines whether your PCB is displaying the numbers 0-2 (i.e., hours), the numbers 0-6 (i.e., tens of minutes or seconds), or the numbers 0-9.

Save your code as display.c. You will need to demonstrate your device running and walk through your code comments and modifications for one of the course staff by the due date. Upload your answered questions to the Google doc, and the code to Canvas.

Details

Pursuant to helping you doing the lab, the skeleton code will set up the MSP430 so that the ACLK is being driven by the VLO (which you remember runs ~12 kHz), and TimerA0 is being driven by the ACLK. These two conditions are required for the Timer to continue to function when the device is in LPM3 (CPU and DCO off!). The display PCB is designed as a matrix - each LED is addressed by a row and a column. Each row and column in turn are connected to a GPIO pin: the rows are connected to P1.0 - P1.6 and the columns are connected to pins P2.0 - P2.4. If you look at the datasheet for the LED array, you’ll see that the individual LEDs are set up to flow current from the row input to the column out. This means two things:

First, to turn on an individual pixel, the relevant row pin must be set to a high level and the column pin to a low level – the row pin is a current source and the column pin is a current sink. To turn off that LED, you can make both row and column pin have the same level (either high or low) or you can also change the direction of one of them from input to output.

Second, an arbitrary pattern across the whole display cannot be displayed simultaneously. Rather, the LEDs will have to be rapidly scanned, and rely on the eye to integrate the result into a static image.

The skeleton code presents a simple design in which the display is operated by cycling through each column of LEDs, but you’ll need to fit in three key pieces for the first specification.