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?
/* Declarations */@eeprom unsigned char eech1 @0x0600; /* 0x0600 is theaddress of the 1st byte of the 1st EEPROM bank in68HC08 */unsigned char @eeprom *peech;unsigned int iOffset;unsigned char ch;/* Code inside some routine */eech1 = 75;peech = &eech1;peech += iOffset; /* arithmetic on a pointer. Assumethat (peech + iOffset) is still within EEPROM bank,but it's unknown what resides at that offset, */ch = *peech;
Thanks for the pointer to the app note. I've downloaded the code that comes with the app note, and it's mostly Assembly. I couldn’t find C code for writing Flash or EEPROM (there's some high-level C code, though). Do you know where it is? I also couldn’t identify the compiler that the AN2295 C code is written for; is it CodeWarrior or Cosmic?
Cheers,
Nick
I hate to be so negative (almost like a teenager). But the Assembly code doesn’t help me at all. I don’t know the Freescale assembly, I don’t have time to learn it, and I don’t have a desire to learn it.
Is there a way to write to the EEPROM that used only C (Cosmic compiler) and avoids writing any Assembly code?
Best,
Nick