<?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>LPC Microcontrollers中的主题 Re: CRC32 with LPC1788</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/CRC32-with-LPC1788/m-p/1290546#M45404</link>
    <description>&lt;P&gt;Hi,&lt;BR /&gt;First of all, thank you for your answer.&lt;BR /&gt;I think I already tried that, I will double check this afternoon.&lt;/P&gt;&lt;P&gt;But if I understand the documentation clearly, what BIT_RVS_WR is doing is reversing the bits order (and not the bytes).&lt;BR /&gt;So, 0x1234 5678 will be treated as 0x1E6A 2C48, am I right ?&lt;/P&gt;&lt;P&gt;(in binary)&lt;BR /&gt;00010010 00110100 01010110 01111000 --&amp;gt; 00011110 01101010 00101100 01001000&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 10 Jun 2021 07:46:52 GMT</pubDate>
    <dc:creator>erenaud</dc:creator>
    <dc:date>2021-06-10T07:46:52Z</dc:date>
    <item>
      <title>CRC32 with LPC1788</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/CRC32-with-LPC1788/m-p/1290034#M45379</link>
      <description>&lt;P&gt;Hello everyone !&lt;/P&gt;&lt;P&gt;I am currently trying to compute CRC32 checksum with a LPC1788.&lt;/P&gt;&lt;P&gt;Here is the functions I am using :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;#define u32      unsigned long

void Reg_InitCRC()
{
/* Standard CRC32 */
   CRC_MODE = 0x00000036;
/* CRC32 MPEG-2 */
//   CRC_MODE = 0x00000002;
   CRC_SEED = 0xFFFFFFFF;
}

u32 REG_Calculate_CRC(u32 u32_Data)
{
   u32 u32_CRC;
   CRC_WR_DATA = u32_Data;
   u32_CRC = CRC_SUM;
   return u32_CRC;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Then, I am testing those function with this code :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;u32 u32_data[4];
   u32_data[0] = 0xAAAAAAAA;
   u32_data[1] = 0x69686968;
   u32_data[2] = 0x69686869;
   u32_data[3] = 0x12345678;

   u32 u32_res = 0;

   Reg_InitCRC();
   u32_res = REG_Calculate_CRC(u32_data[0]);
   CRC_SEED = 0xFFFFFFFF; // Not really needed, just for safety
   u32_res = REG_Calculate_CRC(u32_data[1]);
   CRC_SEED = 0xFFFFFFFF;
   u32_res = REG_Calculate_CRC(u32_data[2]);
   CRC_SEED = 0xFFFFFFFF;
   u32_res = REG_Calculate_CRC(u32_data[3]);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So when doing this, I am observing a really strange behavior. When the input data is an u32 composed of identicals u8 (example : 0xAAAAAAAA) or "symetrical" u8 (0x12343412 and 0x69686869) the CRC output is correct (for both CRC32 and CRC32-MPEG2).&lt;BR /&gt;But when the data input is made of differents u8 (example : 0x12345678), the output is not what I am expecting at all.&lt;/P&gt;&lt;P&gt;Here's a table summing up my situation :&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="21.804511278195488%" height="47px"&gt;Input&lt;/TD&gt;&lt;TD width="18.195488721804512%" height="47px"&gt;My CRC32 output&lt;/TD&gt;&lt;TD width="20%" height="47px"&gt;Real CRC32 output&lt;/TD&gt;&lt;TD width="20%" height="47px"&gt;My MPEG2 output&lt;/TD&gt;&lt;TD width="20%" height="47px"&gt;Real MPEG2 output&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="21.804511278195488%" height="30px"&gt;0xAAAAAAAA&lt;/TD&gt;&lt;TD width="18.195488721804512%" height="30px"&gt;0xb596e05e&lt;/TD&gt;&lt;TD width="20%" height="30px"&gt;&lt;FONT color="#008000"&gt;&lt;SPAN&gt;0xB596E05E&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/TD&gt;&lt;TD width="20%" height="30px"&gt;0x42fc4b29&lt;/TD&gt;&lt;TD width="20%" height="30px"&gt;&lt;FONT color="#008000"&gt;&lt;SPAN&gt;0x42FC4B29&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="21.804511278195488%" height="30px"&gt;0x12343412&lt;/TD&gt;&lt;TD width="18.195488721804512%" height="30px"&gt;0xb0a58ffb&lt;/TD&gt;&lt;TD width="20%" height="30px"&gt;&lt;FONT color="#008000"&gt;&lt;SPAN&gt;0xB0A58FFB&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/TD&gt;&lt;TD width="20%" height="30px"&gt;0x9db25e0f&lt;/TD&gt;&lt;TD width="20%" height="30px"&gt;&lt;FONT color="#008000"&gt;&lt;SPAN&gt;0x9DB25E0F&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="21.804511278195488%" height="30px"&gt;0x69686869&lt;/TD&gt;&lt;TD width="18.195488721804512%" height="30px"&gt;0xb8e4c55e&lt;/TD&gt;&lt;TD width="20%" height="30px"&gt;&lt;FONT color="#008000"&gt;&lt;SPAN&gt;0xB8E4C55E&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/TD&gt;&lt;TD width="20%" height="30px"&gt;0xff43f3da&lt;/TD&gt;&lt;TD width="20%" height="30px"&gt;&lt;FONT color="#008000"&gt;&lt;SPAN&gt;0xFF43F3DA&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="21.804511278195488%" height="30px"&gt;0x12345678&lt;/TD&gt;&lt;TD width="18.195488721804512%" height="30px"&gt;0xaf6d87d2&lt;/TD&gt;&lt;TD width="20%" height="30px"&gt;&lt;FONT color="#FF0000"&gt;0x4A090E98 &lt;/FONT&gt;&lt;/TD&gt;&lt;TD width="20%" height="30px"&gt;0xad37d056&lt;/TD&gt;&lt;TD width="20%" height="30px"&gt;&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;0xDF8A8A2B &lt;/FONT&gt;&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When looking at this table, I finnally understood : if I want to have the "expected" CRC32, I have to reverse bytes (and not bits) in my input. So for the last line :&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="20%"&gt;0x78563412 in my code (but actually computing CRC32 for 0x12345678)&lt;/TD&gt;&lt;TD width="20%"&gt;0x4a090e98&lt;/TD&gt;&lt;TD width="20%"&gt;&lt;FONT color="#008000"&gt;&lt;SPAN&gt;0x4A090E98&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/TD&gt;&lt;TD width="20%"&gt;0xdf8a8a2b&lt;/TD&gt;&lt;TD width="20%"&gt;&lt;FONT color="#008000"&gt;&lt;SPAN&gt;0xDF8A8A2B&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;So my question is : why do I have to switch the endianess of my u32 to find the expected result ?&lt;BR /&gt;&lt;BR /&gt;Note : I am using &lt;A href="http://www.sunshine2k.de/coding/javascript/crc/crc_js.html" target="_self"&gt;this website&lt;/A&gt; to check CRC32.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Jun 2021 16:19:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/CRC32-with-LPC1788/m-p/1290034#M45379</guid>
      <dc:creator>erenaud</dc:creator>
      <dc:date>2021-06-09T16:19:52Z</dc:date>
    </item>
    <item>
      <title>Re: CRC32 with LPC1788</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/CRC32-with-LPC1788/m-p/1290387#M45394</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;How about using the init function:&lt;/P&gt;
&lt;LI-CODE lang="c"&gt;void Reg_InitCRC()
{
/* Standard CRC32 */
   CRC_MODE = 0x00000032; //instead of 0x36
/* CRC32 MPEG-2 */
//   CRC_MODE = 0x00000002;
   CRC_SEED = 0xFFFFFFFF;
}&lt;/LI-CODE&gt;
&lt;P&gt;I think that the BIT_RVS_WR should be cleared rather than being set.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="xiangjun_rong_0-1623296166526.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/146781i7AFFF5282EA9DEEB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="xiangjun_rong_0-1623296166526.png" alt="xiangjun_rong_0-1623296166526.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Hope it can help you&lt;/P&gt;
&lt;P&gt;BR&lt;/P&gt;
&lt;P&gt;XiangJun Rong&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jun 2021 03:37:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/CRC32-with-LPC1788/m-p/1290387#M45394</guid>
      <dc:creator>xiangjun_rong</dc:creator>
      <dc:date>2021-06-10T03:37:16Z</dc:date>
    </item>
    <item>
      <title>Re: CRC32 with LPC1788</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/CRC32-with-LPC1788/m-p/1290546#M45404</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;First of all, thank you for your answer.&lt;BR /&gt;I think I already tried that, I will double check this afternoon.&lt;/P&gt;&lt;P&gt;But if I understand the documentation clearly, what BIT_RVS_WR is doing is reversing the bits order (and not the bytes).&lt;BR /&gt;So, 0x1234 5678 will be treated as 0x1E6A 2C48, am I right ?&lt;/P&gt;&lt;P&gt;(in binary)&lt;BR /&gt;00010010 00110100 01010110 01111000 --&amp;gt; 00011110 01101010 00101100 01001000&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jun 2021 07:46:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/CRC32-with-LPC1788/m-p/1290546#M45404</guid>
      <dc:creator>erenaud</dc:creator>
      <dc:date>2021-06-10T07:46:52Z</dc:date>
    </item>
    <item>
      <title>Re: CRC32 with LPC1788</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/CRC32-with-LPC1788/m-p/1290648#M45409</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I suppose that the CRC module of LPC1788 uses big endian format.&lt;/P&gt;
&lt;P&gt;With PC CRC tools, if you input 0x78563412, the CRC32 output will be 0xaf6d87d2&lt;/P&gt;
&lt;P&gt;With LOPC1788, if you input 0x12345678, the CRC32 output will be 0xaf6d87d2.&lt;/P&gt;
&lt;P&gt;In conclusion, the CRC module of LPC1788 use big endian.&lt;/P&gt;
&lt;P&gt;Hope it can help you&lt;/P&gt;
&lt;P&gt;BR&lt;/P&gt;
&lt;P&gt;XiangJun Rong&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jun 2021 10:01:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/CRC32-with-LPC1788/m-p/1290648#M45409</guid>
      <dc:creator>xiangjun_rong</dc:creator>
      <dc:date>2021-06-10T10:01:42Z</dc:date>
    </item>
  </channel>
</rss>

