首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 嵌入开发 > 单片机 >

关于EEPROM(I2C mini2440)的随机读取数据有关问题

2013-07-09 
关于EEPROM(I2C mini2440)的随机读取数据问题flag2buf0x0locate0x10rIICDS0xa0//伪写第一阶段,写

关于EEPROM(I2C mini2440)的随机读取数据问题

   
     flag=2;buf=0x0;locate=0x10;
        rIICDS=0xa0;//伪写第一阶段,写从机地址
        delay(1000);
        rIICCON=0xe1;
        rIICSTAT=0xf0;
        return 0;
}
void irq_process()
{
        int puts(unsigned char*);
        int printx(unsigned long);
        int i;
        rSRCPND=~0;
        rINTPND=~0;
        if(flag==1)//NO ACK
        {
                puts("flag 1\r\n");
                buf=rIICDS;
                printx(rIICDS); puts("  ");printx(rIICCON);puts("  ");printx(rIICSTAT);
                rIICCON=0x61;//no ACK
                flag=0;
        }
        else if(flag==2)//伪写的第二个阶段,发送数据起始地址
        {
                puts("flag 2\r\n");
                printx(rIICDS); puts("  ");printx(rIICCON);puts("  ");printx(rIICSTAT);
                puts("\r\n");
                rIICDS=locate;//想读的数据起的始地址
                delay(1000);
                printx(rIICDS); puts("  ");printx(rIICCON);puts("  ");printx(rIICSTAT);
                rIICCON=0xe1;
                flag=3;
        } 
        else if(flag==3)//M_R restart
        {
                puts("flag 3\r\n");
                printx(rIICDS); puts("  ");printx(rIICCON);puts("  ");printx(rIICSTAT);
                puts("\r\n");
                rIICDS=0xa0;//以主读方式再次发送开始信号


                delay(1000);
                rIICSTAT=0xb0;
                rIICCON=0xe1;
                printx(rIICDS); puts("  ");printx(rIICCON);puts("  ");printx(rIICSTAT);
                flag=1;
        }
        else if(!flag)
        {
                puts("flag 0\r\n");
                buf=rIICDS;
                //printx(buf);//读取数据
                printx(rIICDS); puts("  ");printx(rIICCON);puts("  ");printx(rIICSTAT);
                flag=4;
                rIICSTAT=0x90;
        }
        else
                puts("flag 4 \r\n");
        puts("INT\r\n");
}


运行结果如下:[img=http://][/img] EEPROM?2440?I2C?IIC C
[解决办法]
你用中断来弄的?
[解决办法]
直接IO操作简单一些,中断容易出错

热点排行