Nick Alexeev

How to read and write EEPROM on 68HC08 with Cosmic compiler?

Discussion created by Nick Alexeev on Mar 14, 2007
Latest reply on Mar 15, 2007 by Nick Alexeev

 

 

Folks,

 

I’m not new to microcontroller programming. But I’m very new to 68HC08 and the Cosmic compiler. I normally use PICs and CCS compiler.

 

What’s the correct way to read and write the EEPROM on 68HC08? As far as I understand, the Cosmic compiler allows pointers to EEPROM and Flash. I have tried reading with this:

Code:

 

     Code:

char* pEeprom = (char*)MAKE16(receive_buffer[0], receive_buffer[1]);   /* EEPROM location */ transmit_buffer[1] = *pEeprom;


 

 

I’m getting 0xFF from every EEPROM location. It’s a little suspicious, but it’s conceivable that the whole EEPROM is initialized with 0xFF

 

But after I write with this

Code:

 

 

 

Code:
char* pEeprom = (char*)MAKE16(receive_buffer[0], receive_buffer[1]);   /* EEPROM location */ *pEeeprom = receive_buffer[2];               /* actually write too EEPROM */


 
 

and then read it, I still get 0xFF. That’s clearly a problem. Could you look at my code and identify the errors?

 

To continue describing the same problem, the other parts of the code use the variables declared with @eeprom, as the only method of accessing EEPROM.  That approach works.  However, I need to write an R&D utility that would read/write the EEPROM based on the address, whether or not there is a variable declared at that address.  So, in my code I’m trying to do the following:

-         Receive 2 bytes through a serial port

-         Cast them into a pointer that would point to the EEPROM.  I.e. the pointer is between 0x0600 and 0x0DFF.  I’ve got this range from the memory map in the 68HC08’s datasheet.

-         Dereference the pointer to read or write

 

Do you think this approach can work?

 

Thanks,

Nick

 

P.S.  Is there a forum dedicated to Cosmic compiler?

Outcomes