在对sd卡初始化的时候,复位成功,但是收不到00.
我吧接收到的数据用串口输出,如下:
红线划的部分是复位之后保持不变的部分,后面的每次复位会有变化。
部分代码:
case(sdinit_cstate)
SDINIT_RST: begin
if(delay_done) sdinit_nstate <= SDINIT_CLK; //上电后40us延时完成,进入74+CLK状态
else sdinit_nstate <= SDINIT_RST; //等待上电后40us延时完成
end
SDINIT_CLK: begin
if(cmd_rdy) sdinit_nstate <= SDINIT_CMD0; //74+CLK完成
else sdinit_nstate <= SDINIT_CLK;
end
SDINIT_CMD0: begin
if(cmd_rdy && (spi_rx_dbr == 8'h01)) sdinit_nstate <= SDINIT_CMD55;
else sdinit_nstate <= SDINIT_CMD0;
end
SDINIT_CMD55: begin
if(cmd_rdy && (spi_rx_dbr == 8'h01)) sdinit_nstate <= SDINIT_ACMD41;
else sdinit_nstate <= SDINIT_CMD55;
end
SDINIT_ACMD41: begin
if(retry_rep == 8'hff) sdinit_nstate <= SDINIT_CMD55; ///////////响应超时,返回IDLE重新发起命令
else if(cmd_rdy && spi_rx_dbr == 8'h01) sdinit_nstate <= SDINIT_CMD55;
else if(cmd_rdy && spi_rx_dbr == 8'h00) sdinit_nstate <= SDINIT_CMD16;
else sdinit_nstate <= SDINIT_ACMD41;
end
/* SDINIT_CMD1: begin
if(cmd_rdy) sdinit_nstate <= SDINIT_CMD16;
else sdinit_nstate <= SDINIT_CMD1;
end*/
SDINIT_CMD16: begin
if(cmd_rdy && (spi_rx_dbr == 8'h00)) sdinit_nstate <= SD_IDLE;
else sdinit_nstate <= SDINIT_CMD16;
end
SD_IDLE: sdinit_nstate <= SD_RD_PT;
SD_RD_PT: begin
if(cmd_rdy) sdinit_nstate <= SD_RD_BPB;
else sdinit_nstate <= SD_RD_PT;
end
SD_RD_BPB: begin
if(cmd_rdy && arg == arg_r+P_MEM-32'h0000_0200) sdinit_nstate <= SD_DELAY;
else sdinit_nstate <= SD_RD_BPB;
end
SD_DELAY: begin
if(done_5s) sdinit_nstate <= SD_IDLE; //显示下一幅图片
else sdinit_nstate <= SD_DELAY;
end
default: sdinit_nstate <= SDINIT_RST;
endcase
|