Making a 7 segment display driver out of an MSP430
It's sunday afternoon, snowing, and I want a simple project to kill time with. It will be documented here.
These drivers are nothing new, and preprogramed chips like this exist. However, I don't have any of them. I do have lots of MSP430s, though! This code can be useful for driving 7segment displays and numitrons alike.
So, to get started, here's a table showing what pins are used to activate what. These drivers typically use four bits of input (1, 2, 4, 8, and all off) for a maximum of 16 values. This allows for the characters 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, and F. Basically, everything needed for hex. Convenient, right?
I'll be using an MSP430g2553, with pins P2.0-3 as my inputs and P1.0-6 as my outputs. A-G here represent both pins P1.0-6 and the corresponding segments of the display.
Character | BIT2.0 (1) | BIT2.1 (2) | BIT2.2 (4) | BIT2.3 (8) | a | b | c | d | e | f | g |
---|---|---|---|---|---|---|---|---|---|---|---|
0 | H | H | H | H | on | on | on | on | on | on | off |
1 | L | H | H | H | off | on | on | off | off | off | off |
2 | H | L | H | H | on | on | off | on | on | off | on |
3 | L | L | H | H | on | on | on | on | off | off | on |
4 | H | H | L | H | off | on | on | off | off | on | on |
5 | L | H | L | H | on | off | on | on | off | on | on |
6 | H | L | L | H | off | off | on | on | on | on | on |
7 | L | L | L | H | on | on | on | off | off | off | off |
8 | H | H | H | L | on | on | on | on | on | on | on |
9 | L | H | H | L | on | on | on | off | off | on | on |
A | H | L | L | H | |||||||
B | H | L | H | H | |||||||
C | H | H | L | L | |||||||
D | L | H | L | L | |||||||
E | |||||||||||
F |