This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Write/Read Flash into W77e58

I'm trying to write and read internal RAM with w77e58 but without success.

I'm using the following code.

#include<string.h>
#include<W77E58.h>


unsigned char xdata xdata_buffer [1];


void main(void){
TA = 0xAA; /*W77e58 Time Accessed Functions*/
TA = 0x55;
memcpy (xdata_buffer, "2", sizeof (xdata_buffer));
}

It does not work.

Any suggestion?

Thanks in advance.

Parents
  • This sequence of statements:

    TA = 0xAA; /*W77e58 Time Accessed Functions*/
    TA = 0x55;
    memcpy (xdata_buffer, "2", sizeof (xdata_buffer));

    cannot possibly make any sense. If you do need timed access for that xdata byte (which would rather surprise me, but I don't know that particular chip), then you'll have to write directly to that byte, not waste time in a function call to memcpy(). In timed access protection schemes, the protected instruction must follow the TA accesses immediately, or the access will fail just as if you hadn't written to TA at all.

    In other words, make that

    TA = 0xAA; /*W77e58 Time Accessed Functions*/
    TA = 0x55;
    xdata_buffer[0] = '2';

    and it might actually start doing something sensible. But odds are you'll have to code this in assembly, because the compiler doesn't know about timed access.

Reply
  • This sequence of statements:

    TA = 0xAA; /*W77e58 Time Accessed Functions*/
    TA = 0x55;
    memcpy (xdata_buffer, "2", sizeof (xdata_buffer));

    cannot possibly make any sense. If you do need timed access for that xdata byte (which would rather surprise me, but I don't know that particular chip), then you'll have to write directly to that byte, not waste time in a function call to memcpy(). In timed access protection schemes, the protected instruction must follow the TA accesses immediately, or the access will fail just as if you hadn't written to TA at all.

    In other words, make that

    TA = 0xAA; /*W77e58 Time Accessed Functions*/
    TA = 0x55;
    xdata_buffer[0] = '2';

    and it might actually start doing something sensible. But odds are you'll have to code this in assembly, because the compiler doesn't know about timed access.

Children
  • Sorry, I'm not explain my problem well because I just started to use microC few months ago.

    I'm creating an application that need some configuration parameters that I would like to store in a non volatile memory area in order to read it or save it as default configuration.

    I made some test using AT89S8252 from Atmel with this code a I have no problem,

    /*
    * Return EEPROM Byte at address 'adr'
    */
    unsigned char ReadEEPROM (unsigned int adr) {
    unsigned char v;

    WMCON |= EEMEN_; // enable EEPROM
    v = XBYTE[adr]; // read value
    WMCON &= ~EEMEN_; // disable EEPROM
    return (v);
    }


    /*
    * Write EEPROM Byte 'val' at address 'adr'
    */
    void WriteEEPROM (unsigned int adr, unsigned char val) {
    WMCON |= (EEMEN_ | EEMWE_); // enable EEPROM and set write bit
    XBYTE[adr] = val; // write value
    while ((WMCON & EERDY_) == 0); // wait until value programmed
    WMCON &= ~(EEMWE_ | EEMEN_); // disable EEPROM and write strobe
    }

    What I want to use is the Winbond W77E58 non volatile memory to store the configuration values.

  • Does this Winbond device actually have any EEPROM?

  • "Does this Winbond device actually have any EEPROM?"

    As far as I'm aware no, the code space is flash but I don't think any of it can be configured as xdata for runtime storage. There is some internal volatile xdata though, but there's an SFR bit that needs to be set if that's what he's trying to access.

    Stefan

  • That'll be why he can't get it to work, then!

  • Sorry, you're right. The W77e58 have not EEPROM, just 32Kb Flash EProm.

    As far as I khow, I think that it's possible to use the Flash Eprom to store non volatile information. That's right??

  • "Sorry, you're right. The W77e58 have not EEPROM, just 32Kb Flash EProm.

    As far as I khow, I think that it's possible to use the Flash Eprom to store non volatile information. That's right??"

    Everything I know about this chip has been gleaned from 5 minutes looking at the datasheet. It's your turn now.

    Stefan