RainKing 发表于 2013-8-18 23:00:34

关于Protues里面仿真PIC单片机

Protues支持仿真PIC单片机里面的EEPROM存储器的读写吗?如果支持,那么我这个问题是指的啥:Modification of EECON1 whilst a read or write is in progress is not ambiguous and not supported .EECON1 is unmodified.这个是在Protues
里面提示的。我自己的翻译是:EECON1的修改,同时在读或写的过程中是明确的和不被支持的,EECON1没有被修改。

RainKing 发表于 2013-8-19 09:11:05

没有人回答么.............自己顶...............

millwood0 发表于 2013-8-19 09:23:43

我自己的翻译是

Your translation is wrong, by a mile and some.

the message says that you cannot modify EECON1 when a read/write has not finished. Try to modify EECON1 when there is action no eeprom operation

lixianghappy 发表于 2013-8-19 15:21:01

- -没用过仿真中读取EEPROM,静待大神,帮顶                     

yklstudent 发表于 2013-8-19 16:35:54

PICC自带的EEPROM_ROUTINES文件内的函数 就可以用的啊 proteus仿真pic内部EEPROM 可以的

RainKing 发表于 2013-8-19 21:39:29

yklstudent 发表于 2013-8-19 16:35 static/image/common/back.gif
PICC自带的EEPROM_ROUTINES文件内的函数 就可以用的啊 proteus仿真pic内部EEPROM 可以的
...

没有懂你的意思....是需要用另外的函数么.....可以具体点么....

RainKing 发表于 2013-8-19 21:43:34

millwood0 发表于 2013-8-19 09:23 static/image/common/back.gif
Your translation is wrong, by a mile and some.

the message says that you cannot modify EECON1 whe ...

你的意思我懂了......

这个是写的函数:

void WriteData(uchar Data,uchar Address)
{
        //EECON1bits.FREE=1;
        EECON1bits.EEPGD=0;
        EECON1bits.CFGS=0;
        EECON1bits.WREN=1;
//        EEADRH=0;
        Cout=0;
        EEADR=Address;
        EEDATA=Data;
        EECON2=0x55;
        EECON2=0x0AA;
        EECON1bits.WR=1;
        while(1)            
        {
                if(EECON1bits.WRERR==0)      //这里是检测是否写完成
                {
                        break;
                }
                if(Cout==200)          //这里是限制等待的时间。。。。
                {
                        break;
                }
                ++Cout;
        }
        EECON1bits.WREN=0;
}

这个是读的函数:
void ReadData(uchar *Data,uchar Address)
{
//        EEADRH=0;
        Cout=0;
        EECON1bits.EEPGD=0;
        EECON1bits.CFGS=0;
        EEADR=Address;
        EECON1bits.RD=1;
        /*while(1)
        {
                if(EECON1bits.RD==0)   //这里是检测是否读完成,不知道用这种方式可以不...不太了解
                {
                        break;
                }
        }*/


        *Data=EEDATA;
}


以上是我的两个函数...不知道写错了没.....

RainKing 发表于 2013-8-19 21:44:33

这个是写的函数:

void WriteData(uchar Data,uchar Address)
{
        //EECON1bits.FREE=1;
        EECON1bits.EEPGD=0;
        EECON1bits.CFGS=0;
        EECON1bits.WREN=1;
//        EEADRH=0;
        Cout=0;
        EEADR=Address;
        EEDATA=Data;
        EECON2=0x55;
        EECON2=0x0AA;
        EECON1bits.WR=1;
        while(1)            
        {
                if(EECON1bits.WRERR==0)      //这里是检测是否写完成
                {
                        break;
                }
                if(Cout==200)          //这里是限制等待的时间。。。。
                {
                        break;
                }
                ++Cout;
        }
        EECON1bits.WREN=0;
}

这个是读的函数:
void ReadData(uchar *Data,uchar Address)
{
//        EEADRH=0;
        Cout=0;
        EECON1bits.EEPGD=0;
        EECON1bits.CFGS=0;
        EEADR=Address;
        EECON1bits.RD=1;
        /*while(1)
        {
                if(EECON1bits.RD==0)   //这里是检测是否读好,不知道用这种方式可以不...不太了解
                {
                        break;
                }
        }*/


        *Data=EEDATA;
}


以上是我的两个函数...不知道写错了没.....

yklstudent 发表于 2013-8-20 20:42:13

// This header file should not be included directly
// Inclusion of this file is provided indirectly by including htc.h

/***********************************************************************/
/****** EEPROM memory read/write macros and function definitions *******/
/***********************************************************************/
/* NOTE WELL:

   The macro EEPROM_READ() is NOT safe to use immediately after any
   write to EEPROM, as it does NOT wait for WR to clear.This is by
   design, to allow minimal code size if a sequence of reads is
   desired.To guarantee uncorrupted writes, use the function
   eeprom_read() or insert
        while(WR)continue;
   before calling EEPROM_READ().
*/
#if        EEPROM_SIZE > 0

#ifdef        __FLASHTYPE
        // macro versions of EEPROM write and read
#define        EEPROM_WRITE(addr, value) \
do{ \
        while(WR)continue;EEADR=(addr);EEDATA=(value); \
        EECON1&=0x3F;CARRY=0;if(GIE)CARRY=1;GIE=0; \
        WREN=1;EECON2=0x55;EECON2=0xAA;WR=1;WREN=0; \
        if(CARRY)GIE=1; \
}while(0)
        #define        EEPROM_READ(addr) ((EEADR=(addr)),(EECON1&=0x3F),(RD=1),EEDATA)
#else        // else doesn't write flash
#define        EEPROM_WRITE(addr, value) \
do{ \
        while(WR)continue;EEADR=(addr);EEDATA=(value); \
        CARRY=0;if(GIE)CARRY=1;GIE=0; \
        WREN=1;EECON2=0x55;EECON2=0xAA;WR=1;WREN=0; \
        if(CARRY)GIE=1; \
}while(0)
        #define        EEPROM_READ(addr) ((EEADR=(addr)),(RD=1),EEDATA)
#endif

/* library function versions */
extern unsigned char eeprom_write(unsigned char addr, unsigned char value);
extern unsigned char eeprom_read(unsigned char addr);
extern void eecpymem(volatile unsigned char *to, eeprom unsigned char *from, unsigned char size);
extern void memcpyee(eeprom unsigned char *to, const unsigned char *from, unsigned char size);
#endif        // end EEPROM routines


现成的东西不知道怎么用吗????

RainKing 发表于 2013-8-20 23:08:51

yklstudent 发表于 2013-8-20 20:42 static/image/common/back.gif
// This header file should not be included directly
// Inclusion of this file is provided indirectly ...

谢谢你了.......
页: [1]
查看完整版本: 关于Protues里面仿真PIC单片机