<?xml-stylesheet type="text/xsl" href="https://community.element14.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Implementing a CRC on an ST micro</title><link>/members-area/personalblogs/b/michael-kellett-s-blog/posts/implementing-a-crc-on-an-st-micro</link><description>This blog is about implementing an 8 bit CRC on an STM32G071xx micro. Several other ST micros have the same CRC hardware system so it will apply directly to them. There is also some discussion of CRC in general. Pretty much all this stuff is on the w</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Implementing a CRC on an ST micro</title><link>https://community.element14.com/members-area/personalblogs/b/michael-kellett-s-blog/posts/implementing-a-crc-on-an-st-micro</link><pubDate>Wed, 07 Apr 2021 16:40:05 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:39556381-e6d1-4ccb-b84e-dac3110071dd</guid><dc:creator>michaelkellett</dc:creator><slash:comments>0</slash:comments><description>&lt;blockquote class="jive-quote"&gt;&lt;p&gt;maybe you could pull the start value out of the routine and have it as a #define&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;I&amp;#39;m always rather reluctant to #define something that appears only once in the code.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Having said that it sort of appears twice so probably should have got a #define anyway.&lt;span&gt;[View:/resized-image/__size/16x16/__key/commentfiles/f7d226abd59f475c9d224a79e3f0ec07-39556381-e6d1-4ccb-b84e-dac3110071dd/contentimage_5F00_1.png:16:16]&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;I think the Barr guide wants all numbers #defined - but then you get into #define ZEROU 0u&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;(It must be nearly time to go home !)&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;MK&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=11090&amp;AppID=323&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: Implementing a CRC on an ST micro</title><link>https://community.element14.com/members-area/personalblogs/b/michael-kellett-s-blog/posts/implementing-a-crc-on-an-st-micro</link><pubDate>Wed, 07 Apr 2021 16:01:22 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:39556381-e6d1-4ccb-b84e-dac3110071dd</guid><dc:creator>jc2048</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;Thanks for an interesting blog to read.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Some of the Microchip PIC microcontrollers have hardware CRC generators. I can remember it appearing in at least some of the 16-bit PIC24 family.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;I don&amp;#39;t have much to say on the coding [I'm no great shakes as a programmer] other than maybe you could pull the start value out of the routine and have it as a #define. To generalise it further, you could also define the bit-order in the message bytes and anything that happens to the final CRC value.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;As an aside, the table method seems to go back quite a long way.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Numerical Recipes in C [Press, Teukolsky, Vetterling, and Flannery, 1992] gives an algorithm for a 16-bit CRC using it.&lt;/p&gt;&lt;p&gt;The explanation itself is quite brief, and they do a very quick whizz through the maths, so after four pages my head was spinning.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;They give as a reference this article in Byte magazine by Jerry LeVan [November 1987]&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;a class="jive-link-external-small" href="https://archive.org/details/byte-magazine-1987-11/page/n395/mode/2up" rel="nofollow ugc noopener" target="_blank"&gt;https://archive.org/details/byte-magazine-1987-11/page/n395/mode/2up&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;where it&amp;#39;s used for calculating a CRC for XMODEM. From reading, it looks like XMODEM could be either checksum or CRC, with people at the time struggling to do the CRC fast enough at high baud rates. That one&amp;#39;s a 16-bit CRC because the packets are [can be?] quite long.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;He gives the name of someone who suggested it to him, but there the trail goes a little cold [perhaps it leaked out of an alternative universe].&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=11090&amp;AppID=323&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: Implementing a CRC on an ST micro</title><link>https://community.element14.com/members-area/personalblogs/b/michael-kellett-s-blog/posts/implementing-a-crc-on-an-st-micro</link><pubDate>Sun, 04 Apr 2021 18:29:04 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:39556381-e6d1-4ccb-b84e-dac3110071dd</guid><dc:creator>shabaz</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;Incidentally, by coincidence, I noticed the &lt;a class="jive-link-external-small" href="https://www.jetbrains.com/clion/whatsnew/" rel="nofollow ugc noopener" target="_blank"&gt;latest version of CLion&lt;/a&gt; has some &lt;a class="jive-link-external-small" href="https://confluence.jetbrains.com/display/CLION/MISRA+checks+supported+in+CLion?_ga=2.243182466.164855624.1617558088-339828637.1617558088" rel="nofollow ugc noopener" target="_blank"&gt;MISRA 2012 support listed here&lt;/a&gt;. I&amp;#39;m using an older version of it, however, which doesn&amp;#39;t support it, so I cannot say if it&amp;#39;s any good at it or not.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;CLion is quite a nice IDE, however it cannot be used to build projects for all microcontrollers via GUI, but only ST Micro chips are supported via GUI.&lt;/p&gt;&lt;p&gt;It can compile Windows programs too, although I mainly use it for the very good editor and search capabilities. It is not free, but has a perpetual license (and free trial license). (£69 for individual or £149 per org user), for the first year and it converts to a perpetual license after that).. but probably worth exploring with the 30-day free trial first!&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;span&gt;[View:/resized-image/__size/792x564/__key/commentfiles/f7d226abd59f475c9d224a79e3f0ec07-39556381-e6d1-4ccb-b84e-dac3110071dd/7853.contentimage_5F00_207597.jpg:792:564]&lt;/span&gt;&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=11090&amp;AppID=323&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: Implementing a CRC on an ST micro</title><link>https://community.element14.com/members-area/personalblogs/b/michael-kellett-s-blog/posts/implementing-a-crc-on-an-st-micro</link><pubDate>Sun, 04 Apr 2021 14:53:30 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:39556381-e6d1-4ccb-b84e-dac3110071dd</guid><dc:creator>shabaz</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;Hi Michael,&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Great blog post, it&amp;#39;s very useful to see how the hardware CRC is used versus the software implementation. I think I&amp;#39;ve only done it in software, never having realized that some processors will have the capability built-in and adaptable. Nice to see how easy it was to set up in hardware.&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=11090&amp;AppID=323&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item></channel></rss>