smallembedded

[Hangshun Training Camp] Digital tube display based on HK32F030MF4P6

 
Overview

1 Introduction


  1. The main controller is Hangshun’s HK32F030MF4P6. It's cheap, easy to solder and has a built-in crystal oscillator.
  2. The digital tube display module is MAX7219. Four 8-segment digital tubes are cascaded. Each one can be controlled independently, which is very free!
  3. Each piece can be displayed independently and the brightness can be adjusted individually. There are a total of 16 levels of brightness that can be adjusted. You don’t have to worry about the usage scenario, it will hurt your eyes in dark places, or you won’t be able to see clearly in bright places!
  4. It can be displayed in non-decoding mode or in BCD decoding mode. There are four decoding methods, see the principle chapter.
  5. Added RX, TX status indicators, power indicator lights, and LED lights connected to PA2. Four 0805 LEDs display status, allowing you to know the current status at all times!
  6. Add debugging interface to enable you to quickly debug and develop!
  7. The 0.56-inch super large digital tube used in the digital tube allows you to see clearly even if you take off your glasses!
  8. From chip devices to EDA, all domestic chip software is used, including MAX7219 chips and resistors and capacitors, etc., to help the development of domestic MCUs!

2.Static picture display


Full display

1617005194520.jpg Single chip lights up 12345678 (repeat) 1617030135712.jpg

All four pieces show different numbers

1617076529980.jpg

Show JLC words

1617088297335.jpg

The static display is completed and the dynamic display is shown in the attached video.

3. Principle code analysis


MAX7219 timing diagram:

QQ screenshot 20210330140415.png

This is the timing diagram in the MAX7219 data sheet. You can see that there are 3 signals. Only 3 signals are needed to control the display of different chips. One is CS chip select, one is CLK clock signal, and one is DIN data signal.

Chip select pulls CS low to enable, and after pulling CS low, read the data given by DIN on the rising edge of CLK .

The CLK script is connected to PC7, the CS (LOAD) pin is connected to PC6, and the DIN pin is connected to PC3.

QQ screenshot 20210330142152.png

QQ screenshot 20210330142430.png

According to the timing diagram, CS is best pulled up and CLK is best pulled down.

QQ screenshot 20210330140910.png

The core code is as above, and the steps for writing byte code are as follows

  1. Pull CS chip select low
  2. Pull CLK low
  3. Do the AND operation between the data DAT to be written and 0x80, that is, take the highest binary bit
  4. Then shift the result to the right by 7 bits to get 0 or 1
  5. Determine if it is 0, then DIN is set to 0, if 1, then 1
  6. Shift DIN to the left by 1 bit, which is its next bit
  7. Pull CLK high and read the DIN level on the rising edge
  8. Repeat the operation 8 times and write 0xXX
  9. CS chip selection pulls high and ends

Unlike the STM32F10X series, there is no bit band operation, so the same effect can be achieved using shifting. There are 4 ways to encode

QQ screenshot 20210330140350.png

The register is 0xX9, corresponding to 0x00 is the non-decoding mode, and 0xff is the BCD decoding mode. These two are commonly used.

QQ screenshot 20210330140344.png

The JLC used in the dynamic display at the beginning is the non-decoding method. Each bit corresponds to the following figure:

QQ screenshot 20210330140356.png

Therefore, displaying J means BCDE is displayed. If converted to binary, it will be 00111100. If converted to hexadecimal, it will be 0x3c.

QQ screenshot 20210330141340.png

In the same way, L is 0x0e, C is 0x4e, just 0 if not displayed. Careful students may find that HPPO is displayed after JLC is displayed , because here I changed the decoding method to BCD decoding of 0xff.

QQ screenshot 20210330141534.png

D7, the highest digit of BCD decoding, displays the decimal point. D6-4-D4 have no effect, and D3-D0 decode. Therefore, when converted without decoding, J is H without decimal point. Therefore, when you see the word HPPO, you still need to adjust the brightness of the display. I only wrote a few gears here

QQ screenshot 20210330141737.png

The following is the data sheet description. Just write 0xX0 to 0xXf at the 0xXa address. There are a total of 16 gears to choose from.

QQ screenshot 20210330141805.png

4. Summary


It was the first time I used Lichuang EDA to make the whole thing. I was not very familiar with the software and the use of the CH330N chip, which caused the TX and RX pins of the serial port chip to be connected in reverse (of course it has been corrected). This was a big mistake. Secondly, because the bit strip operation was not used, the software development was not done after the board welding was completed, and it was only done in a hurry the day before the job was handed in (sweat). In addition, Lichuang EDA hopes that right-angle routing can also be done (I still don’t know how to use it... anyway, it seems that there are only wires and holes, not wires and wires). Finally, I would like to thank Hangshun and Lichuang for giving us such a good opportunity. Finally, I also hope that domestic products will do better and better in all aspects.

参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2024-11-22 13:16:56

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号