关于374模拟并口的时序问题~~

偶用374模拟并口方式和计算机通信,芯片用DSPIC的现在程序遇到点麻烦,读写时序冲突,当WR为低时,RD也有低电平,打电话后按你们的方式做还是有读写冲突,而且和网上帖子给我的关于时序的处理方法的 建议(hcn给的)有出入,特把程序贴出来,望帮忙看看:: D端口有12个引脚,低8位数据连374并口,高4位连信号线! #define CH374_DATA_DAT_OUT(d) (LATD=(LATD&&0XFF00)+d)//数据输出 #define CH374_DATA_DAT_IN() (LATD&&0X00FF)//数据输出 #define CH374_DATA_DIR_OUT() (TRISD&=0X0000)//设置口为输出 #define CH374_DATA_DIR_IN() (TRISD|=0X00FF)//设置口为输入 [ 1] WRITE374indeX( UINT8mindex) { //DSP复位后引脚能输出高电平 CH374_RD=1; CH374_DATA_DIR_OUT(); CH374_DATA_DAT_OUT(d); ch374_A0=1; CH374_CS=0; CH374_WR=0; mDelayus(1);//125ns CH374_WR=1; CH374_CS=0; CH374_DATA_DIR_IN(); ch374_A0=0; } //=========================================================================== [2] WRITE374DATA( UINT8 mdata) { CH374_RD=1; CH374_DATA_DIR_OUT();//设置为输出 CH374_DATA_DAT_OUT(d);//输出数据 ch374_A0=0; CH374_CS=0; CH374_WR=0; mDelayus(1);//125ns CH374_WR=1; CH374_CS=0; CH374_DATA_DIR_IN(); //ch374_A0=1; } //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ [3] READ374DATA(VOID) { UINT8 mDATA; //CH374_WR=1; CH374_DATA_DIR_IN(); CH374_A0=0; CH374_CS=0; CH374_RD=0; mDelayus(1);//125ns mDATA=CH374_DATA_DAT_IN(); CH374_RD=1; CH374_CS=1; } 这是按照你们的提示做的,示波器上WR/RD信号有冲突,374的指示灯亮,PC没有发现未知硬件提示!没有用4通道测CS/A0????? 谢谢---------------------!

[b]文字[/b]

你的程序应该这样写: [ 1] WRITE374indeX( UINT8mindex) { //DSP复位后引脚能输出高电平 CH374_RD=1; CH374_DATA_DIR_OUT(); CH374_DATA_DAT_OUT(d); ch374_A0=1; CH374_CS=0; CH374_WR=0; mDelayus(1);//125ns CH374_WR=1; CH374_CS=1; // CH374_DATA_DIR_IN(); ch374_A0=0; } //=========================================================================== [2] WRITE374DATA( UINT8 mdata) { CH374_RD=1; CH374_DATA_DIR_OUT();//设置为输出 CH374_DATA_DAT_OUT(d);//输出数据 ch374_A0=0; CH374_CS=0; CH374_WR=0; mDelayus(1);//125ns CH374_WR=1; CH374_CS=1; // CH374_DATA_DIR_IN(); //ch374_A0=1; } //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ [3] READ374DATA(VOID) { UINT8 mDATA; //CH374_WR=1; CH374_DATA_DIR_IN(); CH374_A0=0; CH374_CS=0; CH374_RD=0; mDelayus(1);//125ns mDATA=CH374_DATA_DAT_IN(); CH374_RD=1; CH374_CS=1; }


只有登录才能回复,可以选择微信账号登录