卿小小 发表于 2022-11-8 17:42

【中科亿海微EQ6HL45开发平台测评体验】+04.RTC上板测试与Debug(zmj)

本帖最后由 卿小小 于 2022-11-8 17:41 编辑

<p><strong>【中科亿海微EQ6HL45开发平台测评体验】+04.RTC上板测试与Debug(zmj)</strong></p>

<p>&nbsp;</p>

<p cid="n197" mdtype="paragraph">中科亿海微EQ6HL45开发板的RTC测试工程实现了配置DS1302-RTC并读取日历时间,最后通过串口发送到PC的功能,通过串口调试助手可以看到时间信息。</p>

<p cid="n420" mdtype="paragraph">为了测试DEBUG功能,我在工程中增加了呼吸灯代码breath.v控制LED4;Led1/LED2/LED3作为操作状态指示灯闪亮。串口波特率115200bps。</p>

<p cid="n420" mdtype="paragraph">04d7b8ed1c7db5ca10b70a9bb8dea486</p>

<p cid="n420" mdtype="paragraph">&nbsp;</p>

<h1 cid="n404" mdtype="heading">1. RTC简介</h1>

<p cid="n406" mdtype="paragraph">RTC( Real-Time Clock)实时时钟为系统提供一个可靠的时间,并且在断电的情况下,RTC实时时钟也可以通过电池供电,保证RTC功能一直运行下去。</p>

<p cid="n198" mdtype="paragraph">中科亿海微EQ6HL45开发板的RTC设计采用DALLAS公司的低功耗实时时钟芯片(型号DS1302),它可以提供到2099年内的日历功能。RTC通过类SPI总线向FPGA传送8位数据( BCD码),数据包括秒,分,小时,日期,天,月和年。 RTC芯片需要外接一个32.768KHz的无源晶振,这样才能让RTC可以准确的提供时钟信息。同时为了产品掉电以后,实时时钟还可以正常运行,一般需要另外配一个纽扣电池(型号CR1220,电压为 3V)给时钟芯片供电,这样保证DS1302始终正常运行提供时间信息。</p>

<p cid="n400" mdtype="paragraph">在原理图中DS1302的VCC2为主电源,VCC1为后备电源。</p>

<p cid="n402" mdtype="paragraph"><span style="background-color:#f1c40f;">//------RTC-DS1302原理图</span></p>

<p cid="n402" mdtype="paragraph">&nbsp;</p>

<p cid="n402" mdtype="paragraph"></p>

<p cid="n402" mdtype="paragraph">&nbsp;</p>

<h1 cid="n414" mdtype="heading">2. 部分代码解析</h1>

<p cid="n453" mdtype="paragraph">工程框架如图所示:</p>

<p cid="n453" mdtype="paragraph">&nbsp;</p>

<p cid="n453" mdtype="paragraph"></p>

<h2 cid="n456" mdtype="heading">&nbsp;</h2>

<h2 cid="n456" mdtype="heading">2.1 端口声明</h2>

<p cid="n423" mdtype="paragraph">端口声明中主要是添加了led,它指向了开发板的LED1~LED4。</p>

<pre style="background:#555; padding:10px; color:#ddd !important;">
//------rts_top的端口声明
&nbsp;//---system clock
&nbsp;input &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sys_clk &nbsp; &nbsp; &nbsp; &nbsp; ,//50MHz
&nbsp;input &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rst_n &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ,//KEY1_RST
&nbsp;//---RTC-ds1302
&nbsp;output &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;rtc_sclk &nbsp; &nbsp; &nbsp;,//spi_clk
&nbsp;output &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;rtc_ce &nbsp; &nbsp; &nbsp; &nbsp;,//spi_ce
&nbsp;inout &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rtc_data &nbsp; &nbsp; &nbsp;,//spi_data
&nbsp;//---led
&nbsp;outputwire led &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ,//LED1~LED4
&nbsp;//---
&nbsp;input &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; uart_rx &nbsp; &nbsp; &nbsp; &nbsp; ,
&nbsp;output &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;uart_tx&nbsp; &nbsp;</pre>

<p cid="n416" mdtype="paragraph">&nbsp;</p>

<h2 cid="n429" mdtype="heading">2.2 呼吸灯模块例化</h2>

<p cid="n431" mdtype="paragraph">以前写了一个呼吸灯代码breath.v,主要是通过可变PWM输出控制LED实现呼吸效果。</p>

<p cid="n437" mdtype="paragraph">在顶层模块中例化呼吸灯模块,它控制板卡上的LED4实现呼吸闪亮效果。</p>

<pre style="background:#555; padding:10px; color:#ddd !important;">
//------led
&nbsp;//------breathe_led
&nbsp;breath &nbsp; &nbsp;u_breathe_led(
&nbsp;.clk   &nbsp; &nbsp; &nbsp;(sys_clk &nbsp; &nbsp; &nbsp; &nbsp; ),
&nbsp;.led &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(led &nbsp; &nbsp; &nbsp; &nbsp;)
&nbsp;);</pre>

<p cid="n418" mdtype="paragraph">&nbsp;</p>

<h2 cid="n443" mdtype="heading">2.3 操作状态指示灯</h2>

<p cid="n445" mdtype="paragraph">除去呼吸灯LED4,剩下的Led1/LED2/LED3作为操作状态指示灯闪亮,用来标识系统的工作状态。</p>

<pre style="background:#555; padding:10px; color:#ddd !important;">
//------led
&nbsp;//------uart
&nbsp;uart_send uart_send_m0(
    .clk &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(sys_clk &nbsp; &nbsp; &nbsp; &nbsp; ),
    .rst_n &nbsp; &nbsp; &nbsp; &nbsp;(rst_n &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ),
&nbsp;//---
&nbsp;.led &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(led &nbsp; &nbsp; &nbsp;),//
&nbsp;//---
    .read_second &nbsp;(read_second &nbsp; &nbsp; ),
    .read_minute &nbsp;(read_minute &nbsp; &nbsp; ),
    .read_hour &nbsp; &nbsp;(read_hour &nbsp; &nbsp; &nbsp; ),
    .read_date &nbsp; &nbsp;(read_date &nbsp; &nbsp; &nbsp; ),
    .read_month &nbsp; &nbsp; (read_month &nbsp; &nbsp;),
    .read_week &nbsp; &nbsp;(read_week &nbsp; &nbsp; &nbsp; ),
    .read_year &nbsp; &nbsp;(read_year &nbsp; &nbsp; &nbsp; ),
    .uart_rx &nbsp; &nbsp; &nbsp;(uart_rx &nbsp; &nbsp; &nbsp; &nbsp; ),
    .uart_tx   &nbsp;(uart_tx   &nbsp; &nbsp; )
&nbsp;);

&nbsp;assign led = (state == WAIT)? 3&#39;b111 : ((state == SEND)? 3&#39;b000 : 3&#39;b000);</pre>

<p>&nbsp;</p>

<h1 cid="n451" mdtype="heading">3. 添加Debug信号</h1>

<p cid="n457" mdtype="paragraph">工程在SYNTHESIS综合完成后可以通过&ldquo;SYNTHESIS/Set_Up_Debug&rdquo;添加Debug调试信号,该步骤与AMD-Xilinx的Vivado基本完全相同。</p>

<p cid="n458" mdtype="paragraph">详细步骤如下所示:</p>

<p cid="n458" mdtype="paragraph">&nbsp;</p>

<p cid="n458" mdtype="paragraph"><br />
</p>

<p cid="n458" mdtype="paragraph">&nbsp;</p>

<p cid="n453" mdtype="paragraph"></p>

<p cid="n453" mdtype="paragraph">&nbsp;</p>

<p cid="n402" mdtype="paragraph"></p>

<p cid="n402" mdtype="paragraph">&nbsp;</p>

<h1 cid="n209" mdtype="heading">4. 功能测试</h1>

<p cid="n460" mdtype="paragraph">详细操作步骤如下:</p>

<p cid="n476" mdtype="paragraph">做好准备工作,烧录程序,然后通过串口调试助手观察串口信号,eLINX软件添加ILA观察Debug信号。</p>

<p cid="n478" mdtype="paragraph">&nbsp;</p>

<pre style="background:#555; padding:10px; color:#ddd !important;">
//------准备工作
连接串口、JTAG和电源线,然后上电。
//------烧录步骤(类似Quartus-II)
①.Auto-Detect:JTAG扫链,找到FPGA(EQ6HL45);
②.选中FPGA(eHiWay-EQ6HL45);
③.Add-File...:添加烧录文件rtc_prj.jpsk;
④.勾选□Program/Configure;
⑤.点击Start进行烧录。
//------Debug使用(类似Vivado)
a.Debug路径:Window/Dashboard/New-Dashboard。
b.默认ila_0,直接点击OK即可打开ILA观察信号。
c.添加信号,设置触发位置以及触发条件,观察信号。
//------测试结果(图片+视频)
a.串口调试助手设置波特率115200bps(8n1),可以观察到FPGA发送的时间信息(每秒一次)。
b.ILA窗口:可以观察到时间2022年11月08日15:07:28跳变到15:07:29。
c.Led1/LED2/LED3作为操作状态指示灯闪亮,用来标识系统的工作状态。
d.LED4实现呼吸灯效果。</pre>

<p cid="n210" mdtype="paragraph"><span style="background-color:#f1c40f;">//------准备工作</span></p>

<p cid="n210" mdtype="paragraph">&nbsp;</p>

<p cid="n210" mdtype="paragraph"></p>

<p cid="n210" mdtype="paragraph">&nbsp;</p>

<p cid="n402" mdtype="paragraph"><span style="background-color:#f1c40f;">//------烧录步骤</span></p>

<p cid="n402" mdtype="paragraph">&nbsp;</p>

<p cid="n402" mdtype="paragraph"></p>

<p cid="n402" mdtype="paragraph">&nbsp;</p>

<p cid="n402" mdtype="paragraph"><span style="background-color:#f1c40f;">//------Debug使用(类似Vivado)</span></p>

<p cid="n402" mdtype="paragraph">&nbsp;</p>

<p cid="n402" mdtype="paragraph"></p>

<p cid="n402" mdtype="paragraph"><span style="background-color:#f1c40f;">//------测试结果(图片+视频)</span></p>

<p cid="n402" mdtype="paragraph">&nbsp;</p>

<p cid="n402" mdtype="paragraph"></p>

<p cid="n402" mdtype="paragraph"></p>

<h1 cid="n528" mdtype="heading">附. 呼吸灯代码breath.v</h1>

<div></div>

<p cid="n402" mdtype="paragraph">&nbsp;</p>

<p cid="n402" mdtype="paragraph">//------END</p>

Jacktang 发表于 2022-11-12 09:20

<p>观看了楼主的测试结果,图片和视频,呼吸灯效果不错</p>

<p>串口调试助手观察串口信号,必须要用eLINX软件添加ILA观察Debug信号么</p>

卿小小 发表于 2022-11-14 16:26

Jacktang 发表于 2022-11-12 09:20
观看了楼主的测试结果,图片和视频,呼吸灯效果不错

串口调试助手观察串口信号,必须要用eLINX软件添加I ...

<p>如果想观察内部信号的状态,只能用eLINX软件观察;</p>

<p>如果通过串口或者其他IO接口进行状态监测,则无需ILA。</p>

<p>&nbsp;</p>

<p>选择自己合适的调试debug方式。</p>
页: [1]
查看完整版本: 【中科亿海微EQ6HL45开发平台测评体验】+04.RTC上板测试与Debug(zmj)