请大家帮我看看MCU和CPLD通信的程序哪里有问题
在AVR程序中在外部SRAM地址处写入一字节,AVR通过CPLD和外部SRAM相连,一个字节的读写通过以下程序证明是可以的,现在想实现多字节读写,不知道在CPLD程序中应该怎样修改?还有我实现32个字节的读写时就有9个错误,而且是固定的。请大家帮我看看,谢谢。AVR单片机程序如下:
#define ext_PORT1 ((volatile unsigned char *)0x1100)
unsigned char *p=(unsigned char *)ext_PORT1;
*p=0x7f;
DATA = *p;
if(DATA!=0x7f)
sendchar1(DATA);
else
sendstring1("ok");
cpld中程序如下:
assign sram_data=(!sram_we) ? mcu_data_reg : 8'hz;//sram write
assign mcu_data = (!ale&!rd) ? sram_data_reg: 8'hz;//mcu read
assign sram_addr=sram_addr_reg;
always @(negedge ale)
begin
sram_addr_reg<={mcu_addr,mcu_data};
end
always @ (negedge wr or negedge rd)
begin
if(!wr)begin
sram_we <=1'b0;
sram_oe <=1'bz;
mcu_data_reg<=mcu_data;
end
if(!rd)begin
sram_we <=1'b1;
sram_oe <=1'b0;
sram_data_reg<=sram_data;
end
end
页:
[1]