[Evaluation and experience of Zhongke Yihaiwei EQ6HL45 development platform] +04.RTC board test and debug (zmj)
[Copy link]
This post was last edited by Qing Xiaoxiao on 2022-11-8 17:41
[Evaluation and experience of Zhongke Yihaiwei EQ6HL45 development platform] +04.RTC board test and debug (zmj)
The RTC test project of the Zhongke Yihaiwei EQ6HL45 development board implements the function of configuring DS1302-RTC and reading calendar time, and finally sending it to the PC through the serial port. The time information can be seen through the serial port debugging assistant.
In order to test the DEBUG function, I added the breathing light code breath.v to control LED4 in the project; Led1/LED2/LED3 are used as operating status indicators to flash. The serial port baud rate is 115200bps.
03_RTC_UART_LED
1. Introduction to RTC
The RTC (Real-Time Clock) provides a reliable time for the system, and in the event of a power outage, the RTC can also be powered by a battery to ensure that the RTC function continues to run.
The RTC design of the Zhongke Yihaiwei EQ6HL45 development board uses DALLAS's low-power real-time clock chip (model DS1302), which can provide calendar functions until 2099. RTC transmits 8-bit data (BCD code) to the FPGA through a SPI-like bus. The data includes seconds, minutes, hours, date, day, month and year. The RTC chip needs to be connected to a 32.768KHz passive crystal oscillator so that the RTC can accurately provide clock information. At the same time, in order to ensure that the real-time clock can still operate normally after the product loses power, it is generally necessary to provide a button battery (model CR1220, voltage is 3V) to power the clock chip, so as to ensure that DS1302 always operates normally and provides time information.
In the schematic diagram, VCC2 of DS1302 is the main power supply and VCC1 is the backup power supply.
//------RTC-DS1302 schematic diagram
2. Partial code analysis
The project framework is shown in the figure:
2.1 Port Declaration
The main thing added in the port declaration is led[3:0], which points to LED1~LED4 of the development board.
//------rts_top port declaration
//---system clock
input sys_clk ,//50MHz
input rst_n ,//KEY1_RST
//---RTC-ds1302
output rtc_sclk ,//spi_clk
output rtc_ce ,//spi_ce
inout rtc_data ,//spi_data
//---led
output wire [3:0] led ,//LED1~LED4
//---
input uart_rx ,
output uart_tx
2.2 Breathing light module instantiation
I have written a breathing light code breath.v before, which mainly controls the LED through variable PWM output to achieve the breathing effect.
Instantiate the breathing light module in the top-level module, which controls LED4 on the board to achieve a breathing and shining effect.
//------led[3]
//------breathe_led
breath u_breathe_led(
.clk (sys_clk ),
.led (led[3] )
);
2.3 Operation Status Indicator
Excluding the breathing light LED4, the remaining Led1/LED2/LED3 flash as operation status indicators to indicate the working status of the system.
//------led[2:0]
//------uart
uart_send uart_send_m0(
.clk (sys_clk ),
.rst_n (rst_n ),
//---
.led (led[2:0] ), //
//---
.read_second (read_second ),
.read_minute (read_minute ),
.read_hour (read_hour ),
.read_date (read_date ),
.read_month (read_month ),
.read_week (read_week ),
.read_year (read_year ),
.uart_rx (uart_rx ),
.uart_tx (uart_tx )
);
assign led = (state == WAIT)? 3'b111 : ((state == SEND)? 3'b000 : 3'b000);
3. Add Debug Signal
After the SYNTHESIS synthesis is completed, the project can add Debug signals through "SYNTHESIS/Set_Up_Debug". This step is basically the same as AMD-Xilinx's Vivado.
The detailed steps are as follows:
4. Functional testing
The detailed steps are as follows:
Make preparations, burn the program, and then observe the serial port signal through the serial port debugging assistant. Add ILA to the eLINX software to observe the Debug signal.
//------Preparation
Connect the serial port, JTAG, and power cables, and then power on.
//------Programming steps (similar to Quartus-II)
①.Auto-Detect: JTAG scan chain, find FPGA (EQ6HL45);
②. Select FPGA (eHiWay-EQ6HL45);
③.Add-File...: Add the burning file rtc_prj.jpsk;
④. Check □Program/Configure;
⑤.Click Start to burn.
//------Debug usage (similar to Vivado)
a.Debug path: Window/Dashboard/New-Dashboard.
b. The default is ila_0. Simply click OK to open the ILA to observe the signal.
c. Add signals, set trigger positions and trigger conditions, and observe signals.
//------Test results (pictures + videos)
a. Set the baud rate to 115200bps (8n1) in the serial port debugging assistant, and you can observe the time information sent by the FPGA (once per second).
b.ILA window: It can be observed that the time jumps from 15:07:28 on November 8, 2022 to 15:07:29.
c. Led1/LED2/LED3 flash as operating status indicators to indicate the working status of the system.
d.LED4 achieves breathing light effect.
//------Preparation
//------burning steps
//------Debug usage (similar to Vivado)
//------Test results (pictures + videos)
Attachment. Breathing light code breath.v
//------END
|