完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
使用的FLASH是SST39VF3201 按照芯片手册编写了写编程程序和擦除程序,发现擦除或写编程10多次才偶尔有一次擦除成功,哪位高手知道是什么原因吗?
程序代码为: assign Flash_data=(FLASH_STATE==F_S4||FLASH_STATE==F_S8)?Flash_data_IN:16'hzzzz; //只有在写编程操作和擦除操作中,Flash_data=Flash_data_IN,其余状态为高阻 always@(posedge clk_100MHZ) begin case(FLASH_STATE) F_S0:begin CNT_RST<=1'b0; //复位信号计数清零 CNT_READ<=1'b0; //读计数清零 CNT_ERASE<=1'b0; //擦除计数清零 CNT_FEED<=1'b0; //反馈数据读取计数清零 Flash_OE<=1'b0;Flash_CE<=1'b1; case(s_reg) 6'b000000:FLASH_STATE<=F_S1; //读模式 6'b100000:FLASH_STATE<=F_S2; //复位模式 6'b010000:begin FLASH_STATE<=F_S3; Flash_addr_r<=21'h000000;end //字编程算法 6'b001000:FLASH_STATE<=F_S5; //读标定值1 6'b000100:FLASH_STATE<=F_S6; //读标定值2 6'b000010:FLASH_STATE<=F_S7; //读标定值3 6'b000001:FLASH_STATE<=F_S8; //擦除模式 default: FLASH_STATE<=F_S0; //初始状态 endcase end F_S3:begin //数据等待 CNT_WRITE<=1'b0 if(jx_wr) //接收到写数据,每组数据间隔时间为26us FLASH_STATE<=F_S4; //字编程时间最大为10us,不需要DQ7查询? else if(S_C1) //接收其他FLASH操作信号 FLASH_STATE<=F_S0; //指令判断状态,没有指令则进入FLASH读状态 else FLASH_STATE<=F_S3; end F_S4:begin //字编程算法及数据写编程 Flash_OE<=1'b1; CNT_WRITE<=CNT_WRITE+1'b1; case(CNT_WRITE) 16'd0: begin Flash_addr<=21'h005555;Flash_data_IN<=16'h00aa;end 16'd10: begin Flash_WE<=1'b0;Flash_CE<=1'b0;end 16'd20: begin Flash_WE<=1'b1;Flash_CE<=1'b1;end 16'd30: begin Flash_addr<=21'h002aaa;Flash_data_IN<=16'h0055;end 16'd40: begin Flash_WE<=1'b0;Flash_CE<=1'b0;end 16'd50: begin Flash_WE<=1'b1;Flash_CE<=1'b1;end 16'd60: begin Flash_addr<=21'h005555;Flash_data_IN<=16'h00a0;end 16'd70: begin Flash_WE<=1'b0;Flash_CE<=1'b0;end 16'd80: begin Flash_WE<=1'b1;Flash_CE<=1'b1;end 16'd90: begin Flash_addr<=Flash_addr_r;Flash_data_IN<=DATA_WRITE;end //初始地址为000000 16'd100: begin Flash_WE<=1'b0;Flash_CE<=1'b0;end 16'd110: begin Flash_WE<=1'b1;Flash_CE<=1'b1;end 16'd115:Flash_addr_r<=Flash_addr_r+1'b1; //数据地址+1 16'd120:FLASH_STATE<=F_S3; //返回上一状态,等待下一组数据来临 default:FLASH_STATE<=F_S4; endcase end F_S8:begin //数据擦除 Flash_OE<=1'b1; CNT_ERASE<=CNT_ERASE+1'b1; case(CNT_ERASE) 24'd0: begin Flash_addr<=21'h005555;Flash_data_IN<=16'h00aa;end 24'd10: begin Flash_WE<=1'b0;Flash_CE<=1'b0;end 24'd20: begin Flash_WE<=1'b1;Flash_CE<=1'b1;end 24'd30: begin Flash_addr<=21'h002aaa;Flash_data_IN<=16'h0055;end 24'd40: begin Flash_WE<=1'b0;Flash_CE<=1'b0;end 24'd50: begin Flash_WE<=1'b1;Flash_CE<=1'b1;end 24'd60: begin Flash_addr<=21'h005555;Flash_data_IN<=16'h0080;end 24'd70: begin Flash_WE<=1'b0;Flash_CE<=1'b0;end 24'd80: begin Flash_WE<=1'b1;Flash_CE<=1'b1;end 24'd90: begin Flash_addr<=21'h005555;Flash_data_IN<=16'h00aa;end 24'd100: begin Flash_WE<=1'b0;Flash_CE<=1'b0;end 24'd110: begin Flash_WE<=1'b1;Flash_CE<=1'b1;end 24'd120: begin Flash_addr<=21'h002aaa;Flash_data_IN<=16'h0055;end 24'd130: begin Flash_WE<=1'b0;Flash_CE<=1'b0;end 24'd140: begin Flash_WE<=1'b1;Flash_CE<=1'b1;end 24'd150: begin Flash_addr<=21'h005555;Flash_data_IN<=16'h0010;end 24'd160: begin Flash_WE<=1'b0;Flash_CE<=1'b0;end 24'd170: begin Flash_WE<=1'b1;Flash_CE<=1'b1;end 24'd171: begin FLASH_STATE<=F_S9;CNT_ERASE<=1'b0;end default: FLASH_STATE<=F_S8; endcase end F_S9: begin //DQ7查询 CNT_ERASE<=CNT_ERASE+1'b1; case(CNT_ERASE) 24'd0: begin Flash_OE<=1'b1;Flash_CE<=1'b1;Flash_addr<=21'h000fff;end 24'd5: begin Flash_OE<=1'b0;Flash_CE<=1'b0;end 24'd15: begin if(Flash_data[7]) FLASH_STATE<=F_S0; else begin CNT_ERASE<=1'b0;FLASH_STATE<=F_S9;end end default:FLASH_STATE<=F_S9; endcase end |
|
相关推荐
2 个讨论
|
|
只有小组成员才能发言,加入小组>>
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-22 12:34 , Processed in 0.592721 second(s), Total 51, Slave 39 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号