The Subtle Art of Bit Banging (Driving Monochromatic 5x7 Dot Matrix LED Displays via the MAX6952)

Senal Chandrasekara
14 min readNov 27, 2020

Majority of the microcontrollers in the market have relatively similar architectures and means of operation. A generic understanding regarding the operation and their architecture can be attained through thoroughly studying the operation of one such micro controller. In this article, the operation and the methods of implementation of a MSP430 microcontroller, a suitable display driver, and use of dot matrix LED displays were thoroughly explored. A panel of displays consisting of four 5x7 dot matrix LED displays driven by the MAXIM 4-wire interfaced, MAX6952 display driver were manipulated via the MSP430F2272 by means of executing a bit-banging technique so as to display the letters SLII on the panel of four dot matrix LED displays once simulated via the PCB design and circuit simulation software, Proteus ISIS Professional Design Suite.

A display driver is an integrated circuit which facilitates a communication medium between a microcontroller and a particular type of display device. It provides the function of generating signals with required voltage, current, timing and demultiplexing facilities according to a serial or parallel interface data input so as to output a desired figure on the prespecified display device. The driver device itself may also be constructed as a microcontroller by incorporating certain types of memories such as the RAM and flash memory.

Numerous other microcontrollers including Arduino and majority of the other MSP430 family microcontrollers could havebeen utilized to operate the MAX6952 and some of the most commonly used include the Arduino UNO by Smart Projects, MSP430 family microcontrollers such as the MSP430F2272, MSP430F5529 by Texas Instruments and PIC18F2455, PIC18F2550, PIC18F4455, and PIC18F4550 high-performance, enhanced flash, USB microcontrollers by Microchip.

Similarly, numerous driver ICs are also available for the 5x7 dot matrix display apart from the MAX6952. MAX6953, TB62713F, MAX7219 and STLED524 are among some of the most commonly used. The selection of the MAX6952 over the others was supported by multiple factors.

  • A main reason which contributed to the selection of the MAX6952 driver was the method in which data can provided to it from the microcontroller. Although SPI and serial data communication methods were available within the MSP430 microcontrollers, the bit banging data transmission would have helped beginner level users to attain a better intuition regarding register wise operations available within a master-slave arrangement of two ICs. Bit banging is a technique where the data transmission is carried out by means of employing an internal software as a substitute for a prespecified hardware of the master IC to generate signals to be transmitted to the slave IC.
  • When comparing the prices of the drivers, the MAX6952 offers a relatively profitable outcome. When compared with MAX7219, the MAX6952 driver is relatively less expensive.
  • The power consumption was also considered when selecting the most suitable driver. According to the datasheet of each driver, the values for the supply voltages were observed as depicted in Table 01.
  • From Table 01 it was evident that MAX6955 and MAX6952 drivers required a relatively low amount of supply voltage ranging from 2.7V to 5.5V and the remaining drivers required a supply voltage between the range of 4V to 5.5V. This operation of the MAX6952 under low power conditions gave it predominance over the other ICs during the selection process.
  • The MAX7219 can control up to 64 discrete LEDs and if implemented on an array of four 5x7 LED dot matrix displays, four drivers would have been required to drive the four displays. This would prove less profitable and the probability for the occurrence of human errors in the programming phase would have been more prominent. The MAX6952 had the capability to cascade up to four 5x7 LED displays. This resulted in a relatively profitable outcome with less room for errors.

The Source Code

The source code can be found in my git repository.

https://github.com/Senal-Chandrasekara/C-Source-Code-for-MSP430F2272.git

Through the repeated utilisation of an if condition, sixteen times to be exact, bit tests were executed for all sixteen bits of data passed to the transfer function from the main function. First, the eight bits from the address byte was tested and transferred into the driver. Then the eight bits of the data byte, to be sent to above fed address, were tested and fed into the driver. The basic operation of the if condition can be depicted as follows.

if (logical AND value of the eight bit address and the considering bit is a non-zero positive value){

One is fed into the driver register

}else{

Zero is fed into the driver register

}

The Source Code in C

Prior to the construction of the schematic, the C program required to be simulated was written.

  • Initially the MSP430 hex utility was enabled and the output format was set to generate the hex file for simulations.
  • The MSP430 header file was called as follows.

#include <msp430.h>

  • It was determined the use of preprocessor directives to process address and data bytes prior to the compilation process would prove efficient in the debugging process and the delivery of a well-organised source code.
  • The addresses and the states of the configuration, scan-limit, and intensity registers were defined via the use of preprocessor directives.

#define config_address 0X04

//Address byte of configuration register

#define config_value 0X01

//Data byte for configuration register

#define scanlimit_address 0X03

//Scan-limit register address byte

#define scanlimit_value 0X01

//Specifies that 4 digits are to be driven

  • Intensity address for plane 0 and plane 1 were the same and was defined using the following line.

#define intensity_address10 0x01

  • Intensity addresses for plane 2 and plane 3 were the same and was defined accordingly.

#define intensity_address32 0x02// Register address byte

  • Intensity of each digit was defined maximum utilising the following syntax.

#define intensity_value 0XFF//Set max intensity for all

  • Addresses of each display were defined via preprocessor directives.

#define digit0_address 0X20 //Address referring to the display 0

#define digit1_address 0X21 //Address referring to the display 1

#define digit2_address 0X22 //Address referring to the display 2

#define digit3_address 0X23 //Address referring to the display 3

  • By referring to the character map provided, the letters to be displayed were defined using the following lines of syntax.

#define letterS 0b01010011 //Letter S will be displayed

#define letterL 0b01001100 //Letter L will be displayed

#define letterI 0b01001001 //Letter I will be displayed

  • A function prototype with two arguments was declared as ‘transfer’ and was utilised to manipulate the outputs of the MSP430F2272 which in turn implemented a bit-wise transfer of data to the MAX6952. The two arguments were used to receive the address byte and the data byte from the main method.

void transfer (char address, char data)

  • Within the function, the procedure for the bit-wise transfer of data to the relevant registers were executed.
  • The if condition was implemented by utilising bit clear and bit set double operand instructions to set the data input pin and the clock pin as low or as high, respectively, when prompted by the outcome of the if condition. Syntax block demonstrating this operation for the first three bits of the eight-bit address is given in Appendix C.
  • Within the main method, the direction of the pins in port one was set. The following syntax was used.

P1DIR |= 0X07 //Setting the directions of the pins of port 1

  • Pins of the first port were initialised as follows.

P1OUT |= 0X02 //Initializing the pins of the msp430F2272

  • Calling the transfer function, the address and the values of the configuration register, scan-limit register and the intensity register were passed to be transferred to the MAX6952.

transfer(config_address,config_value);

transfer(scanlimit_address,scanlimit_value);

transfer(intensity_address10,intensity_value);

transfer(intensity_address32,intensity_value);

  • The values of the digits to be displayed and the relevant address of each digit’s display, when passed to the transfer function was fed bit by bit to the MAX6952. Following syntax passed sixteen bits to the transfer function.

transfer(digit0_address,letterS);

transfer(digit1_address,letterL);

transfer(digit2_address,letterI);

transfer(digit3_address,letterI);

Implementation of the Schematic

Figure 01: Typical Application Circuit given in the MAX6952 Datasheet

In Figure 01, the number indicated in the tags extended from each pin in each plane, illustrated the manner in which the pins C1 to C5 and pins R1 to R7 available in each plane were to be connected to the relevant pins, labelled similarly, in the MAX6952.

Figure 02: The Constructed Circuit

By observing the source code, the clock, chip select, and data input pins of the driver were connected to the first three pins in the first port of the MSP430F2272 respectively in that order and directions of operation of the pins were set as output in the source code. The circuit was constructed as illustrated in Figure 02.

Results

The circuitry was designed and successfully simulated without the utilisation of SPI or any serial communication methods via the circuit simulation software.

Figure 03: Functionality of the simulation

The four letters SLII were displayed, single letter per plane, by means of cascading the four planes as depicted in Figure 03. No additional features such as scrolling or blinking were implemented.

MAX6952 LED Display Driver

The MAX6952 is a serially interfaced display driver with the capability to drive either four monocolor digits or two bicolor digits of 5x7 cathode-row dot-matrix displays. The driver contains a 128-character font map which consists of 104 predefined character and 24 user defined characters as portrayed in Table 06. To attain a better comprehension of the registers available and techniques for register manipulation, a manual transmission of data was carried out.

Registers in the MAX6952 Display Driver

Prior to writing the source code required to display the four characters, three registers which prepared the driver and the displays to receive the data were configured.

Table 02: Register Address Map of the MAX6952

Table 02 depicts the Register Address Map as provided in the MAX6952 datasheet. It specifies the 8-bit address values that are assigned to each register available in the driver. The most significant bit (D15) sets the mode of the register as either write or read. According to this datasheet, when this bit is set 0, the register will operate in the write mode. Referring to this, the following registers were manipulated.

Writing Device Registers

The MAX6952 houses a 16-bit shift register into which data are clocked on the rising edge of the clock pulse. The chip select was required to be set low prior to the clocking of data. The chip select pin is to be set high only after the transmission of all the 16 bits of data into the driver. Upon setting the chip select high will parallel load the data into a 16-bit latch which will decode and execute the procedure relevant to the transferred data.

The MAX6952 was written to according to the following sequence:

01) Clock pin was set low.

02) Chip select pin was set low.

03) 16 bits of data were clocked into the device, most significant bit to least significant bit.

The most significant bit was set low throughout the entire process to indicate that data is being written.

04) Set the chip select pin high.

05) Set the clock pin low.

Figure 04: 4-bit wire transmission to the MAX6952

Figure 04 illustrates the sequence followed when the 16 bits of data were written to the MAX6952 via the MSP430F2272. Special attention was given to setting the clock low prior to setting the chip select low and to setting the chip select high prior to setting the clock low at the end of the data transmission. Delays were also to be used when carrying out this task.

Timing Diagram

The timing diagram given in Figure 05 illustrates how the delays were to be implemented between the transmission of each bit. Certain values were assigned for these delays.

Table 03: Timing Characteristics

Table 03 portrays the thresholds of the values applicable for the delays defined in Figure 05. Application of more practical values, for instance, in the range of milliseconds would have also resulted the expected output.

These delays were to be defined in the source code when triggering the pins of the microcontroller but was deemed unnecessary due to the time taken by the clock cycles taken to execute the if conditions present in the transfer function exceeding the thresholds specified in Table 03. This was yet another factor which contributed to minimising the length of the source code.

Initial Power-Up

When initialising the initial power-up of the device, the following factors were taken into consideration.

  • All control registers were reset
  • The display is blanked
  • Intensities were set to a minimum
Table 04: Initial Power-Up Register Status

Table 04 depicts the data byte available in each register for the initial power-up condition. Prior to performing any operation on the MAX6952, these registers were arranged according to the required status.

The Configuration Register

The configuration register consists of eight bits and also possesses a predefined address. The predefined address, as specified in Table 01, is represented by the hex code, 0x04. Following syntax was used to defined the address of the configuration register.

#define config_address 0x04

According to the manner in which the bits for the register data was assigned, the MAX6952 performed a number of different functions.

Table 05: Configuration Register Format of MAX6952

Table 05 depicts the configuration register format of the MAX6952 driver. By altering the relevant bits, the normal operation state was set. The data bits represented by X (as in D1 and D6) could have been set to any value as these bits were considered to be overlooked by the driver when operating. Hence D7 to D1 bits were set as 0.

The only bit considered for the proper implementation of the experiment was the S data bit D0. The operations carried out by the other bits were not required and those bits were set as 0.

Table 06: Shut Down Control (S Data Bit D0) Format

Table 06 illustrates how the shutdown feature was controlled by altering the least significant bit in the register data. The S bit in the configuration register selects shutdown or normal operation mode according to the specified bit. The driver was programmed in the shutdown mode and was overridden when testing the displays. The S bit was set to 1 when the displays were lit. Hence the following syntax defined the register data.

#define config_value 0x01

Scan-limit Register

The scan-limit register specified how many monocolor digits were to be displayed. It was important that the scan-limit registers were changed only when in shutdown state. The multiplexing scheme of the MAX6952 drove the first two digits and the last two digits simultaneously but the last two digits (3 and 2) after the first two (1 and 0).

Table 07: Scan Limit Register Format

Table 07 illustrates how the data bits were set in the scan-limit register. Only the least significant bit was considered for the operation of the driver. Since the first two digits were driven at the same time, only one bit was required to set the scan limit. If set 0, only the first two digits would have been driven. If set 1, all four digits were driven. Hence the syntax to specify the use of four digits were written as follows.

#define scanlimit_value 0x01

The address of the scan-limit register was retrieved from Table 04 and its hexadecimal code (0X03) was defined via a preprocessor directive.

#define scanlimit_address 0x03

Intensity Registers

Utilising four pulse width modulators, one for each display, the option to change the brightness of each display was provided. To ensure that all digits are visible, the brightness was set to the maximum value.

Table 08: Intensity Register Format for Digit 0 (Address 0X01) and Digit 2 (Address 0X02)
Table 09: Intensity Register Format for Digit 1 (Address 0x01) and Digit 3 (Address 0x02)

Table 08 and Table 09 illustrates how the current supplied to each segment varied according to the data fed into the registers. Addresses of the registers for digits 0, 2 and 1,3 were not the same and only four data bits out of the eight were specified for each level of intensity. This indicated that the intensity of two displays included in the same table were not to be set at once and that the displays were to be interchanged when setting the intensity as specified in the columns of the two tables.

Digits 0 and 1 shared one address and digits 2 and 3 shared another address. Hence the address of the register utilised for digit 0 and digit 1 were specified by the hex code, 0X01 and that of digit 2 and digit 3 by the hex code 0X02. This was defined using the following block of syntax.

#define intensity_address10 0x01

#define intensity_address32 0x02

From the eight bits of data stored in the register specified by the address 0X01, the first four bits indicated the intensity of digit 1 and the last four bits, the intensity of digit 0.

Similarly, from the eight bits of data stored in the register specified by the address 0X02, the first four represented the intensity of digit 3 and the last four bits, the intensity of digit 2.

In the experiment, all eight bits of both registers of all four digits were set 1 as that resulted the maximum brightness as indicated in Table 08 and Table 09. The following syntax implemented this.

#define intensity_value 0xFF

Plane Registers

Plane register were used to store the data bytes which referred to the letters to be displayed on the planes. Each letter had its own command byte as depicted in the character map.

Table 10: The Character Map Provided in the MAX6952 Datasheet

Table 10 depicts the character map provided in the MAX6952 datasheet. Columns of the map indicated the first four bits of its data byte and the rows indicates the last four bits. By locating the required character in the map, the relevant indices were used to formulate the data byte and transfer it into the driver.

The plane which the hence selected letter should be displayed in were specified by mentioning the addresses of the relevant plane. These addresses were included in Table 02. Hence when transferring the data to the driver, the first eight bits contained the address byte of the plane register to be used and the last eight bits, the data byte of the character to be displayed.

Appendix

A few essential register bits and their methods of configuration and contribution to the operation of the device can be illustrated.

Table 03: Configuration Register Format of MAX6952

Apart from the shutdown control bit (S data bit D0), few other bits contribute to certain other tasks.

Blink Rate Selection (B Data Bit D2) Format

This bit is used to select the blink rate, which is the speed at which the segment alternates between plane P0 and P1 refresh data. The Blink rate is determined by the frequency of the multiplex clock in addition to setting the bit as depicted in Table 11.

Table 11: Blink Rate Selection Format

Global Blink Enable/Disable (E Data Bit D3) Format

This bit enables and disables the blink feature of the device.

Table 12: Global Blink Enable/Disable Format

Table 12 depicts the setting of the global blink enable bit to the required state.

Global Blink Timing Synchronisation (T Data Bit D4) Format

When multiple MAX6952 ICs are daisy-chain connected, setting this bit synchronises the blink timing for every IC.

Table 13: Global Blink Timing Synchronisation (T Data Bit D4) Format

Global Clear Digit Data (R Data Bit D5) Format

When set, digit data for both planes P0 and P1 for all digits is cleared.

Table 14: Global Clear Digit Data (R Data Bit D5) Format

Blink Phase Readback (P Data Bit D7) Format

Upon reading the configuration register, the P bit represents the state f the blink output pin at that instance.

Table 14: Blink Phase Readback (P Data Bit D7) Format

--

--