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