<?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>topic Read Data From flash or RAM in Kinetis Software Development Kit</title>
    <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Read-Data-From-flash-or-RAM/m-p/854639#M7916</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am using a define to read data from and write to flash or ram.&amp;nbsp;&lt;/P&gt;&lt;P&gt;#define REG_READ(address) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;((uint8_t)(*(vuint8_t *)(address)))&lt;/P&gt;&lt;P&gt;#define REG_WRITE(address, value)&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;(*(vuint8_t *)(address) = (value))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But I'm unable to understand&amp;nbsp;&lt;STRONG&gt;((uint8_t)(*(vuint8_t *)(address)))&amp;nbsp; and&amp;nbsp;(*(vuint8_t *)(address) = (value))&lt;/STRONG&gt; this.&lt;/P&gt;&lt;P&gt;Could you please help me out on this? How it is typecasted and what this typecasting actually means.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Harshitha C B&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 27 Feb 2019 11:09:04 GMT</pubDate>
    <dc:creator>harshitha_chiga</dc:creator>
    <dc:date>2019-02-27T11:09:04Z</dc:date>
    <item>
      <title>Read Data From flash or RAM</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Read-Data-From-flash-or-RAM/m-p/854639#M7916</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am using a define to read data from and write to flash or ram.&amp;nbsp;&lt;/P&gt;&lt;P&gt;#define REG_READ(address) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;((uint8_t)(*(vuint8_t *)(address)))&lt;/P&gt;&lt;P&gt;#define REG_WRITE(address, value)&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;(*(vuint8_t *)(address) = (value))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But I'm unable to understand&amp;nbsp;&lt;STRONG&gt;((uint8_t)(*(vuint8_t *)(address)))&amp;nbsp; and&amp;nbsp;(*(vuint8_t *)(address) = (value))&lt;/STRONG&gt; this.&lt;/P&gt;&lt;P&gt;Could you please help me out on this? How it is typecasted and what this typecasting actually means.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Harshitha C B&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Feb 2019 11:09:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Read-Data-From-flash-or-RAM/m-p/854639#M7916</guid>
      <dc:creator>harshitha_chiga</dc:creator>
      <dc:date>2019-02-27T11:09:04Z</dc:date>
    </item>
    <item>
      <title>Re: Read Data From flash or RAM</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Read-Data-From-flash-or-RAM/m-p/854640#M7917</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Welcome to the C programming language :-)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#define REG_READ(address) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;((uint8_t)(*(vuint8_t *)(address)))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you can use it as this:&lt;/P&gt;&lt;P&gt;uint8_t val = REG_READ(0x1000);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The macro takes the address (0x1000 in this case) and casts it to a pointer to volatile unsigned 8bit int ((vuint8_t*).&lt;/P&gt;&lt;P&gt;Then it dereferenciates the pointer (* operator) and casts the result to an unsigned 8bit int (uint8_t).&lt;/P&gt;&lt;P&gt;Finally, it assigns it to the variable val.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The WRITE macro is doing the same thing, must with assigning the value to that constant pointer cast.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You might see other examples of this in &lt;A class="link-titled" href="https://mcuoneclipse.com/2013/08/14/volatile-can-be-harmful/" title="https://mcuoneclipse.com/2013/08/14/volatile-can-be-harmful/"&gt;“Volatile” can be harmful… | MCU on Eclipse&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this helps,&lt;/P&gt;&lt;P&gt;Erich&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Feb 2019 11:20:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Read-Data-From-flash-or-RAM/m-p/854640#M7917</guid>
      <dc:creator>BlackNight</dc:creator>
      <dc:date>2019-02-27T11:20:13Z</dc:date>
    </item>
  </channel>
</rss>

