<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>8-bit MicrocontrollersのトピックRe: How to read and write EEPROM on 68HC08 with Cosmic compiler?</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/How-to-read-and-write-EEPROM-on-68HC08-with-Cosmic-compiler/m-p/126163#M957</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;FONT size="3"&gt;&lt;FONT color="#000000"&gt;&lt;FONT face="Times New Roman"&gt;Thanks for the pointer to the app note.&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt; I've downloaded the code&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt; that comes with the app note, and it's mostly Assembly.&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt; I couldn’t find C code for writing Flash or EEPROM (there's some high-level C code, though).&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt; Do you know where it is?&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt; I also couldn’t identify the compiler that the AN2295 C code is written for; is it CodeWarrior or Cosmic?&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;&lt;FONT color="#000000"&gt;&lt;FONT face="Times New Roman"&gt;Cheers,&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;&lt;FONT color="#000000"&gt;&lt;FONT face="Times New Roman"&gt;Nick&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 15 Mar 2007 10:49:49 GMT</pubDate>
    <dc:creator>Kender</dc:creator>
    <dc:date>2007-03-15T10:49:49Z</dc:date>
    <item>
      <title>How to read and write EEPROM on 68HC08 with Cosmic compiler?</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/How-to-read-and-write-EEPROM-on-68HC08-with-Cosmic-compiler/m-p/126161#M955</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;SPAN style="color: #000000; font-family: 'Times New Roman'; font-size: 3;"&gt;Folks,&lt;/SPAN&gt; &lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: 'Times New Roman'; font-size: 3;"&gt;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.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: 'Times New Roman'; font-size: 3;"&gt;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:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: 'Times New Roman'; font-size: 3;"&gt;Code:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; color: #000000; font-size: 3; font-family: 'Times New Roman';"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class="msg_source_code"&gt;&lt;SPAN class="text_smallest"&gt;Code:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;char* pEeprom = (char*)MAKE16(receive_buffer[0], receive_buffer[1]);&amp;nbsp;&amp;nbsp; /* EEPROM location */ transmit_buffer[1] = *pEeprom;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: 'Times New Roman'; font-size: 3;"&gt;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&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: 'Times New Roman'; font-size: 3;"&gt;But after I write with this&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: 'Times New Roman'; font-size: 3;"&gt;Code:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;SPAN style="color: #000000; font-family: 'Times New Roman'; font-size: 3;"&gt;&lt;SPAN class="msg_source_code"&gt;&lt;SPAN class="text_smallest"&gt;Code:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;PRE&gt;char* pEeprom = (char*)MAKE16(receive_buffer[0], receive_buffer[1]);&amp;nbsp;&amp;nbsp; /* EEPROM location */ *pEeeprom = receive_buffer[2];&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* actually write too EEPROM */&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: 'Times New Roman'; font-size: 3;"&gt;and then read it, I still get 0xFF. That’s clearly a problem. Could you look at my code and identify the errors?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: 'Times New Roman'; font-size: 3;"&gt;To continue describing the same problem, the other parts of the code use the variables declared with &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/23898"&gt;@EEprom&lt;/a&gt;, as the only method of accessing EEPROM.&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt; That approach works.&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt; However, I need to write an R&amp;amp;D utility that would read/write the EEPROM based on the address, whether or not there is a variable declared at that address.&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt; So, in my code I’m trying to do the following:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Times New Roman';"&gt;&lt;SPAN style=": ; color: #000000;"&gt;&lt;SPAN style="font-size: 3;"&gt;-&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;SPAN style="color: #000000; font-size: 3;"&gt;Receive 2 bytes through a serial port&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Times New Roman';"&gt;&lt;SPAN style=": ; color: #000000;"&gt;&lt;SPAN style="font-size: 3;"&gt;-&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;SPAN style="color: #000000; font-size: 3;"&gt;Cast them into a pointer that would point to the EEPROM.&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt; I.e. the pointer is between 0x0600 and 0x0DFF.&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt; I’ve got this range from the memory map in the 68HC08’s datasheet.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Times New Roman';"&gt;&lt;SPAN style=": ; color: #000000;"&gt;&lt;SPAN style="font-size: 3;"&gt;-&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;SPAN style="color: #000000; font-size: 3;"&gt;Dereference the pointer to read or write&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: 'Times New Roman'; font-size: 3;"&gt;Do you think this approach can work?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: 'Times New Roman'; font-size: 3;"&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: 'Times New Roman'; font-size: 3;"&gt;Nick&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: 'Times New Roman'; font-size: 3;"&gt;P.S.&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt; Is there a forum dedicated to Cosmic compiler?&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Mar 2007 11:24:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/How-to-read-and-write-EEPROM-on-68HC08-with-Cosmic-compiler/m-p/126161#M955</guid>
      <dc:creator>Kender</dc:creator>
      <dc:date>2007-03-14T11:24:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to read and write EEPROM on 68HC08 with Cosmic compiler?</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/How-to-read-and-write-EEPROM-on-68HC08-with-Cosmic-compiler/m-p/126162#M956</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Consult App Note 2295 for the proper techniques for writing to Flash memory for the HC08 families. While the primary topic is programming Flash, it also explains programming EEPROM. The software for the programming code is located in AN2295SW.zip on this site. HTH.&lt;BR /&gt;&lt;BR /&gt;---Tom&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Mar 2007 22:51:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/How-to-read-and-write-EEPROM-on-68HC08-with-Cosmic-compiler/m-p/126162#M956</guid>
      <dc:creator>J2MEJediMaster</dc:creator>
      <dc:date>2007-03-14T22:51:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to read and write EEPROM on 68HC08 with Cosmic compiler?</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/How-to-read-and-write-EEPROM-on-68HC08-with-Cosmic-compiler/m-p/126163#M957</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;FONT size="3"&gt;&lt;FONT color="#000000"&gt;&lt;FONT face="Times New Roman"&gt;Thanks for the pointer to the app note.&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt; I've downloaded the code&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt; that comes with the app note, and it's mostly Assembly.&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt; I couldn’t find C code for writing Flash or EEPROM (there's some high-level C code, though).&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt; Do you know where it is?&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt; I also couldn’t identify the compiler that the AN2295 C code is written for; is it CodeWarrior or Cosmic?&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;&lt;FONT color="#000000"&gt;&lt;FONT face="Times New Roman"&gt;Cheers,&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;&lt;FONT color="#000000"&gt;&lt;FONT face="Times New Roman"&gt;Nick&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Mar 2007 10:49:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/How-to-read-and-write-EEPROM-on-68HC08-with-Cosmic-compiler/m-p/126163#M957</guid>
      <dc:creator>Kender</dc:creator>
      <dc:date>2007-03-15T10:49:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to read and write EEPROM on 68HC08 with Cosmic compiler?</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/How-to-read-and-write-EEPROM-on-68HC08-with-Cosmic-compiler/m-p/126164#M958</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;As I understand it, the Flash and EEPROM routines are written in assembly. The code was written for CodeWarrior tools.&lt;BR /&gt;&lt;BR /&gt;---Tom&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Mar 2007 01:48:41 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/How-to-read-and-write-EEPROM-on-68HC08-with-Cosmic-compiler/m-p/126164#M958</guid>
      <dc:creator>J2MEJediMaster</dc:creator>
      <dc:date>2007-03-16T01:48:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to read and write EEPROM on 68HC08 with Cosmic compiler?</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/How-to-read-and-write-EEPROM-on-68HC08-with-Cosmic-compiler/m-p/126165#M959</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;P&gt;&lt;FONT color="#000000" face="Times New Roman" size="3"&gt;I hate to be so negative (almost like a teenager). &lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;But the Assembly code doesn’t help me at all.&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt; 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.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000" face="Times New Roman" size="3"&gt;Is there a way to write to the EEPROM that used only C (Cosmic compiler) and avoids writing any Assembly code?&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000" face="Times New Roman" size="3"&gt;Best,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000" face="Times New Roman" size="3"&gt;Nick&lt;/FONT&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Mar 2007 05:02:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/How-to-read-and-write-EEPROM-on-68HC08-with-Cosmic-compiler/m-p/126165#M959</guid>
      <dc:creator>Kender</dc:creator>
      <dc:date>2007-03-16T05:02:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to read and write EEPROM on 68HC08 with Cosmic compiler?</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/How-to-read-and-write-EEPROM-on-68HC08-with-Cosmic-compiler/m-p/126166#M960</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Here's an update.&amp;nbsp; I have received some encouraging answers from the Cosmic tech support.&amp;nbsp; See below&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;_________________________________________&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Hi Nick,&lt;BR /&gt;&lt;BR /&gt;This syntax (unsigned char &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/23898"&gt;@EEprom&lt;/a&gt; *peech; ) puts the pointer variable&lt;BR /&gt;itself&lt;BR /&gt;in RAM, but specifies that the data it points to is located in EEPROM.&lt;BR /&gt;&lt;BR /&gt;Arithmetic operations with this kind of pointer are legal.&amp;nbsp; The code&lt;BR /&gt;you&lt;BR /&gt;gave below should work fine.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;John [support]&lt;BR /&gt;&lt;BR /&gt;_____________________________________&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;John,&lt;BR /&gt;&lt;BR /&gt;Thanks.&amp;nbsp; What you say sounds encouraging.&amp;nbsp; I was&lt;BR /&gt;missing &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/23898"&gt;@EEprom&lt;/a&gt; in the line that declares a pointer:&lt;BR /&gt;&lt;BR /&gt;unsigned char &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/23898"&gt;@EEprom&lt;/a&gt; *peech;&lt;BR /&gt;&lt;BR /&gt;However, you still have declared a variable with&lt;BR /&gt;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/23898"&gt;@EEprom&lt;/a&gt;.&amp;nbsp; That's something I would like to avoid.&lt;BR /&gt;&lt;BR /&gt;Are the arithmetic operations with the EEPROM pointer&lt;BR /&gt;legal?&amp;nbsp; Do you think, the following modified version&lt;BR /&gt;of your code could work:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class="msg_source_code"&gt;&lt;SPAN class="text_smallest"&gt;Code:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;PRE&gt;/* 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 = &amp;amp;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;&lt;/PRE&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Nick&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Mar 2007 05:24:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/How-to-read-and-write-EEPROM-on-68HC08-with-Cosmic-compiler/m-p/126166#M960</guid>
      <dc:creator>Kender</dc:creator>
      <dc:date>2007-03-16T05:24:01Z</dc:date>
    </item>
  </channel>
</rss>

