- /************************************************************************/
- /* 宏定义一些引脚 */
- /************************************************************************/
- #define DATA_OUT_EN P1DIR=0xff
- #define DATA_OUT P1OUT
- #define DATA_IN_EN P1DIR=0x00
- #define DATA_IN P1IN
- #define CS_HIGH P2OUT|=BIT0
- #define CS_LOW P2OUT&=~BIT0
- #define AS_HIGH P2OUT|=BIT1
- #define AS_LOW P2OUT&=~BIT1
- #define RW_HIGH P2OUT|=BIT2
- #define RW_LOW P2OUT&=~BIT2
- #define DS_HIGH P2OUT|=BIT3
- #define DS_LOW P2OUT&=~BIT3
- ************************************************************************/
- /* 设置参数程序定义 */
- /************************************************************************/
- void Data_Write(BYTE add,BYTE dat)
- {
- AS_LOW;
- DS_HIGH;
- RW_HIGH;
- CS_HIGH;
- DATA_IN_EN;//初始化
- DS_LOW;
- __no_operation();
- AS_HIGH;
- CS_LOW;
- DATA_OUT_EN;
- DATA_OUT=add;
- AS_LOW;
- __no_operation();
- delay_int(0x10);
- DS_HIGH;
- RW_LOW;//写入模式
- __no_operation();
- DATA_OUT=dat;
- delay_int(0x10);
- DS_LOW;
- AS_HIGH;
- }
- /************************************************************************/
- /* 读取程序定义 */
- /************************************************************************/
- void Data_Read(BYTE add)
- {
- DATA_OUT_EN;
- AS_LOW;
- DS_HIGH;
- RW_LOW;
- CS_HIGH;
- DS_LOW;
- __no_operation();
- AS_HIGH;
- CS_LOW;
- DATA_OUT=add;
- AS_LOW;
- delay_int(20);
- DATA_IN_EN;
- DS_HIGH;
- RW_HIGH;
- delay_int(100);
- t_dat=DATA_IN;
- DS_LOW;
- __no_operation();
- }
时序貌似没错啊,每次读出来的数据都是给定的地址,而不是时间啊,求各位大大帮忙啊……