1、在调试之前先要通过串口调试助手与网络调试助手对ESP8266进行配置,但是根据AT指令集对其进行配置调试的时候,发现串口调试助手传输不了配置的指令集。对此,选择对ESP8266先进行固件烧入。
再将上述的ESP8266模块和USB转串口模块相互连接,进行烧录固件。
注意 VCC接USB转串口上的3.3v,将IO_0接地,将RST也要连接,在烧录过程中,将RST接地复位一下,然后断开,这样才能烧录成功。(具体也可能不需要复位也可以烧入成功)。
在烧入成功后就可以通过串口调试助手对ESP8266进行配置了。将其配置为TCP server。还要保持重新上电后仍可直接传输数据。波特率为115200.
这是配置的AT指令设置。对此ESP8266的配置就暂时完成了。接下来就是将FPGA开发板生成的数据如何通过ESP8266传输到网络调试助手。
设计UART的tx模块即可,将tx输出端口与ESP8266上的rx连接即可。ESP8266上的3.3v与开发板上的3.3v电源连接,接地与接地连接。
module uart_tx(
input clk,
input rst_n,
// input [7:0] i_data,
// input start,
output reg rs232_tx
);
reg [7:0] cnt;
reg en;
reg start;
always @ (posedge clk or negedge rst_n) begin
if(!rst_n) begin
cnt <= 8'd0;
start <= 1'b0;
end
else if((en ==1'b0) && (start == 1'b0)) begin
cnt <= cnt + 1'b1;
start <= 1'b1;
end
else begin
start <= 1'b0;
end
end
reg [7:0] tx_data;
always @ (posedge clk or negedge rst_n) begin
if(!rst_n) begin
tx_data <= 8'b0;
end
else if(start) begin
tx_data <= cnt;
end
end
reg [3:0] num;
always @ (posedge clk or negedge rst_n) begin
if(!rst_n) begin
en <= 1'b0;
end
else if(start) begin
en <= 1'b1;
end
else if(num==4'd11) begin
en <= 1'b0;
end
end
//---------------------------------波特率 115200----
reg [8:0] cnt_bps;
always @ (posedge clk or negedge rst_n) begin
if(!rst_n) begin
cnt_bps <= 9'd0;
end
else if((cnt_bps==9'd433) || (en==1'b0)) begin
cnt_bps <= 9'd0;
end
else begin
cnt_bps <= cnt_bps + 1'b1;
end
end
reg clk_bps;
always @ (posedge clk or negedge rst_n) begin
if(!rst_n) begin
clk_bps <= 1'b0;
end
else if(cnt_bps==9'd216) begin
clk_bps <= 1'b1;
end
else begin
clk_bps <= 1'b0;
end
end
always @ (posedge clk or negedge rst_n) begin
if(!rst_n) begin
num <= 4'd0;
rs232_tx <= 1'b1;
end
else if(en) begin
if(clk_bps) begin
num <= num + 1'b1;
case(num)
4'd0 : rs232_tx <= 1'b0;
4'd1 : rs232_tx <= tx_data[0];
4'd2 : rs232_tx <= tx_data[1];
4'd3 : rs232_tx <= tx_data[2];
4'd4 : rs232_tx <= tx_data[3];
4'd5 : rs232_tx <= tx_data[4];
4'd6 : rs232_tx <= tx_data[5];
4'd7 : rs232_tx <= tx_data[6];
4'd8 : rs232_tx <= tx_data[7];
4'd9 : rs232_tx <= 1'b1;
default : rs232_tx <= 1'b1;
endcase
end
else if(num==4'd11) begin
num <= 4'd0;
end
end
end
endmodule
测试代码
`timescale 1ps/1ps
module tb();
reg clk;
reg rst_n;
wire rs232_tx;
uart_tx uart_tx_inst(
.clk(clk),
.rst_n(rst_n),
.rs232_tx(rs232_tx)
);
initial begin
clk = 0;
rst_n = 0;
#22;
rst_n = 1;
end
always #5 clk = ~clk;
endmodule
通过signal tap进行板级调试采集到数据如图:
对此,该模块的设计就可以暂停一段时间了,现在的问题就是如何将网络传输助手接收到的数据保存到一个excel表中,或者其他文件中。在网络调试助手中设置的接收转向文件,发现并没有保存到数据。
接下来就是解决这个问题,为此打算使用matlab或者别的方法解决这个问题。