Cascading Dot Matrix and STM32
Some time ago, we did interface a dot matrix display with STM32. Today in this tutorial I am going to show you guys How to program Dot matrix displays in cascade using STM32. I will also show you guys how to scroll a single character or the entire string in different direction. I am using STM32f103c8 microcontroller and FC16 MAX7219 Dot matrix Displays, which I found using MD_MAX72XX library for arduino.
In order to connect the displays in cascading mode, the data output pin (Dout) of one is connected to data input pin (Din) of the other display. All the displays are connected to the same CS pin. Now to write data to the display I have written a library and in this tutorial, I am going to go through some functions and their usage.
Ok so after generating the code through CubeMx, next step is to include the library and to do that, put the max_matrix_stm32.h in the inc folder and put max_matrix_stm32.c in the src folder.
First of all we need to change few details in the max_matrix_stm32.h file and they are as follows
maxport : is the common port for all the pins that are being used in the display
data_pin : the pin, Data pin is connected to
and same for the cs_pin and clock_pin
num : the number of displays connected in cascade
Now let’s initiate the displays. The following function initialises the connected displays with the brightness varying from 1-15.
Next we are going to write a character on the display and to do that we have the following function
It takes 2 parameters:
‘c’ : is the character to write
‘max’ : is the number of the dot matrix display, where you want to write the character. This should start with 1.
In order to write a character with left scroll or right scroll effects, the following function is used.
It takes three parameters:
‘c’ : is the character which you want to shift
‘speed’ : is the time delay in ms between each shift
‘direction’ : is the direction of the shift. This value can only be either left or right
Scrolling the entire string is also same as shifting a character.
The above function takes 3 parameters:
‘*string’ : Pointer to the string that you want to shift on the display. If you want to input the string directly, you have to type convert it eg- (uint8_t *) “string here”.
speed and direction are mentioned above.
You can check the rest of the functions in the **.h file and the **.c file itself. The code is commented properly so that you guys can understand it.
. . . . . DOWNLOAD . . . . .
You can buy me acontrollerstech
coffeeSensor by clicking DONATE OR Just click DOWNLOAD to download the code
- WavePlayer using STM32 Discovery January 16, 2021
- How to use SPI in LPC2148 December 26, 2020
- STM32 ADC MULTI CHANNEL WITHOUT DMA December 24, 2020
- Send and Receive data to PC without UART (STM32 USB COM) December 10, 2020
- STM32 GPIO INPUT Configuration December 4, 2020
- STM32 GPIO OUTPUT Config using REGISTERS November 24, 2020