Hi all, Doe's anyone know how to write a union type to external parallel EEPROM (AT28C64)? The union type is: typedef union { uchar handle :1; uchar input_status; uchar intrnl_event; uchar rcv_data[8]; uint measurement; Time time; Date date; } rcvMSG; I know how to write byte by byte but not this one. I also configured the external pointer to be rcvMSG instead of char but without luck.
There is no way OTHER than writing byte-by-byte on the 8051. So, if you know how to write byte-by-byte to the external EEPROM, create a function that writes multiple bytes one after the other. For example:
void write_to_EEPROM ( void *buffer, unsigned EEPROM_address, unsigned buffer_len) { unsigned char *bp; for (bp = buffer; buffer_len; buffer_len--, bp++, EEPROM_address++) { // Write *bp to EEPROM_address } }
rcvMSG union_var; write_to_EEPROM (&union_var, 0x1000, sizeof (rcvMSG));
Thanks a lot Jon. U R the best!
Most EEPROMs have a write buffer. You can take advantage of that to accelerate block writes to EEPROM. However if speed is not an issue it's not worth the effort. Regards, - Mike