- Review experiment 1, proficient in PLL configuration, frequency division design, and project verification;
- Learn the BCD code counter;
- Digital display decoding design;
- Learn to program the project into the serial FLASH of the development board;
- The segment display has two lower digits to display seconds, the middle two digits to display minutes, and the highest two digits to display hours.
- The decimal point remains off and will not be considered for the time being.
One type of segment display is a semiconductor light-emitting device. The segment display can be divided into a seven-segment display and an eight-segment display. The difference is that the eight-segment display has one more unit for displaying the decimal point, the basic unit is a light-emitting diode. The on-board segment display is a six-in-one eight-segment display as shown in Figure 3.1, and its structure is shown in Figure 3.2.
Figure 3.1 Segment display physical picture
Figure 3.2 Single segment display structure
Common anode segment displays are used here. That is, the anodes of the LEDs are connected. See Figure 3.3. Therefore, the FPGA is required to control the cathode of the LED to be low level, illuminate the diode, and display the corresponding information. The six-digit common anode eight-segment display refers to the signal that controls which one is lit, which is called the bit selection signal. The content displayed by each digital segment is called the segment selection signal. The corresponding truth table is shown in Table 3.1.
Figure 3.3 Schematics of common anode LEDs
Table 3.1 8-segment display truth table
Static display: Each display segment is connected with an 8-bit data line to control and maintain the displayed glyph until the next segment selection signal arrives. The advantage is that the driver is simple, and the disadvantage is that it takes up too much I/O resources.
Dynamic display: Parallel the segment selection lines of all segment display, and the digit selection line controls which digit is valid and lights up. Through the afterglow effect of the LED and the persistence effect of the human eye, the segment display appears to be continuously lit at a certain frequency. The advantage is to save I / O resources, the disadvantage is that the driver is more complicated, the brightness is not static display high.
In this experiment, the digital tube was driven by dynamic scanning.
The schematics of the segment display is shown in Figure 3.4. The anode is connected to VCC through the P-channel field effect transistor. Therefore, when the bit selection signal SEG_3V3_D[0:5] is low level 0, the FET is turned on, the anode of the segment display is high level; the cathode (segment selection signal) SEG_PA, SEG_PB, SEG_PC, SEG_PD, SEG_PE, SEG_PF, SEG_PG, SEG_DPZ are directly connected to the FPGA and directly controlled by the FPGA. Therefore, when the bit selection signal is 0, and the segment selection signal is also 0, the segment display is lit.
Figure 3.4 Schematics of the segment display
18.104.22.168 Introduction of the Program
The first step: the establishment of the main program framework (interface design)
The input signal has a clock and a reset signal, and the output signals are a segment selection signal seven_seg and a new signal scan.
Step 2: System Control Module
In the first sub-module (system control module), the input clock is the system 50 MHz clock, and a 100MHz is output through the phase-locked loop as the working clock of the other sub-modules. The phase-locked loop lock signal is inverted as the system reset signal. The button is reset to be used as an external hardware reset signal.
The third step: the frequency division module
Referring to Experiment 1, a millisecond pulse signal and a second pulse signal are output as input signals of the segment display driving module.
The fourth step: segment display driver module
- Counting section
The counting part is similar to the frequency dividing module. It is timed by the second pulse signal for 60 seconds, 60 minutes, 24 hours, and when the time reaches 23 hours, 59 minutes and 59 seconds, the counters are all cleared, which is equivalent to one day.
- Segment display dynamic scanning part
The dynamic scanning of the segment display is realized by the state machine. A total of six segment display require six states. The state machine scan_state[2:0] is defined, and the corresponding content count_sel is displayed in different states. At reset, all six segment display are extinguished and jump to the 0 state. The segment display is dynamically scanned in 1 millisecond time driven by a millisecond pulse:
In the 1 state, the first segment display is lit, and the tens digit of the second is displayed;
In the 2 state, the second segment display is lit, and the ones digit of the minute is displayed;
In the 3 state, the third segment display is lit, and the tens digit of the minute is displayed;
In the 4 state, the fourth segment display is lit, and the ones digit of the hour is displayed;
In the 5 state, the fifth segment display is lit, and the tens digit of the hour is displayed;
Part 5: segment display segment code section
Referring to Table 3.1, the characters to be displayed are associated with the segment code, the decimal point is set high, and then the final segment selection signal output is composed in a spliced form.
The first step: pin assignment
Pin assignments are shown in Table 3.2.
Table 3.2 Segment display pin mapping
|Signal Name||Network Label||FPGA Pin||Port Description|
|scan||SEG_3V3_D0||F14||Bit selection 0|
|scan||SEG_3V3_D1||D19||Bit selection 1|
|scan||SEG_3V3_D2||E15||Bit selection 2|
|scan||SEG_3V3_D2||E13||Bit selection 3|
|scan||SEG_3V3_D4||F11||Bit selection 4|
|scan||SEG_3V3_D5||E12||Bit selection 5|
The second step: compilation
The third step: solidify the program to Flash
Onboard Flash (N25Q128A) is a serial Flash chip that can store 128Mbit of content, which is more than enough for the engineering process in the learning process. The schematics of the Flash is shown in Figure 3.7.
Figure 3.7 Schematics of FLASH
The function of Flash is to save the program on the development board. After the power is off, the program will not disappear. The next time the development board is powered on, it can be used directly. It is more practical in the actual learning life. Driven by the SPI_CLK clock, the FPGA Flash is programmed through the SPI_ASDO line. After power-on, the FPGA re-reads the program to the FPGA through SPI_XDATA for testing.
The specific configuration process of Flash is as follows:
- Menu File -> Convert programming files, as shown in Figure 3.8;
- Option settings
- Select JTAG Indirect configuration File(*.Jic)
- Configuration Device: EPCQ 128A (Compatible with development board N25Q128A)
- Mode: Active serial
Figure 3.8 *.jic file setting
- Click the Advanced button and set it as shown in Figure 3.9.
Figure 3.9 Advanced option setting
- Add a conversion file, as shown in Figure 3.10.
Figure 3.10 Add conversion file
- Add a device, as shown in Figure 3.11.
Figure 3.11 Add devices
- Click Generate to generate the BCD_counter.jic file
- Consistent with previous program verification operations, select the correct file (*.jic) to program the development board
Figure 3.12 Experiment result