tag:blogger.com,1999:blog-4172950626830217643.comments2024-03-19T00:59:15.574-04:00Better Embedded System SWPhil Koopmanhttp://www.blogger.com/profile/11849599272360094243noreply@blogger.comBlogger393125tag:blogger.com,1999:blog-4172950626830217643.post-37111176036207179082024-02-04T17:40:55.206-05:002024-02-04T17:40:55.206-05:00Hi Emil,
You're right -- the computation can a...Hi Emil,<br />You're right -- the computation can avoid a mod operation if you are clever. A common optimization is to make things multiples of powers of two and look for low bits all being zero, and so on.<br />In general, you usually want periods to be harmonic multiples for better schedulability, so that would be 5000, 10000, 20000, but not 15000.Phil Koopmanhttps://www.blogger.com/profile/11849599272360094243noreply@blogger.comtag:blogger.com,1999:blog-4172950626830217643.post-55487342696585478922024-02-01T08:14:15.718-05:002024-02-01T08:14:15.718-05:00Hi Phil,
A few years have passed since your post...Hi Phil, <br /><br />A few years have passed since your post, but I still think it is worth noting that there is a possibility to get rid of the division or modulo operations completely. Most MCU have timer compare registers which can be used to generate interrupts at different frequencies using just one timer!<br /><br />For example, with a 1 MHz timer clock, you can set your compare registers to 5000, 10000, 15000, and 20000 respectively. In the last one, you restart the timer. In each interrupts, you set the flag for the 5ms tick, in first and third the 10ms tick flag, and in the first one the 20ms flag. <br /><br />If your tick periods are too far aways from each other, then you can use a prescaler (counter). E.g. in the first interrupt you increment a counter and when it reaches five you reset it and set the 100ms flag.<br /><br />Cheers, EmilAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-4172950626830217643.post-85807133777069577062024-01-27T14:41:02.367-05:002024-01-27T14:41:02.367-05:00Thanks for the comments Andreas. Indeed concurrenc...Thanks for the comments Andreas. Indeed concurrency gets complicated. This list was developed for small single-microcontroller projects as you suspected.Phil Koopmanhttps://www.blogger.com/profile/11849599272360094243noreply@blogger.comtag:blogger.com,1999:blog-4172950626830217643.post-31479117999527736892022-11-16T11:46:18.070-05:002022-11-16T11:46:18.070-05:00Thanks, i hoped that there is a more elegant appro...Thanks, i hoped that there is a more elegant approach, but adding an extra non 0xFF Byte at the end will work.LegoTechnikernoreply@blogger.comtag:blogger.com,1999:blog-4172950626830217643.post-85502084344381411242022-11-16T08:47:42.602-05:002022-11-16T08:47:42.602-05:00There is a special class of codes called "era...There is a special class of codes called "erasure" codes that might do a little better, but I don't have handy info on them.<br /><br />You might try adding an extra data bit at the end of your data stream to ensure the CRC value itself can never be all ones. (that bit should be either odd or even parity depending on the CRC.) <br />Phil Koopmanhttps://www.blogger.com/profile/11849599272360094243noreply@blogger.comtag:blogger.com,1999:blog-4172950626830217643.post-53912481822759064302022-11-16T07:48:36.551-05:002022-11-16T07:48:36.551-05:00I'm looking for a CRC that is tailored to I2C ...I'm looking for a CRC that is tailored to I2C and a few Flash specific issues. Namely that all bits are one after an error. For I2C this is the case when the transmitter detects an error and stops sending or for Flash this is the case when the write process has been aborted at some point. Flash is usually cleared to one. Are there implementations where this arbitrary long but special error is always detected? The length is known for these two examples.LegoTechnikernoreply@blogger.comtag:blogger.com,1999:blog-4172950626830217643.post-60403326147485515452022-10-19T11:06:31.985-04:002022-10-19T11:06:31.985-04:00I'm sorry to hear about that experience. I jus...I'm sorry to hear about that experience. I just checked the kindle eBook content page and can confirm that DRM is definitely OFF for this book. (Moreover, due to Amazon policy I can never turn it on even if I wanted to.) So not sure what the issue might be. I guess you can ask Amazon for a refund if this does not meet your expectations. Sorry for the inconvenience.Phil Koopmanhttps://www.blogger.com/profile/11849599272360094243noreply@blogger.comtag:blogger.com,1999:blog-4172950626830217643.post-62560900304823875582022-10-19T10:47:01.382-04:002022-10-19T10:47:01.382-04:00Hey, just purchased the book from amazon and it lo...Hey, just purchased the book from amazon and it looks like it's DRM protected and cannot convert it to epub :( Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-4172950626830217643.post-71338068507976588642022-08-18T20:28:01.773-04:002022-08-18T20:28:01.773-04:00Corruption of the CRC field itself is accounted fo...Corruption of the CRC field itself is accounted for in the HD. The HD accounts for any combination of codeword bit corruptions, including both the dataword and the Frame Check Sequence (CRC value)Phil Koopmanhttps://www.blogger.com/profile/11849599272360094243noreply@blogger.comtag:blogger.com,1999:blog-4172950626830217643.post-20285714833715777172022-08-18T20:13:53.876-04:002022-08-18T20:13:53.876-04:00What are the effects of corruptions in the CRC its...What are the effects of corruptions in the CRC itself?<br /><br />I'm assuming that a single bit corruption in the CRC makes all HD promises invalid.<br /><br />If that's the case, how does this affect the error detection analysis?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-4172950626830217643.post-76465246711198007892022-03-13T18:25:08.583-04:002022-03-13T18:25:08.583-04:00Those "fast algorithms" are closed sourc...Those "fast algorithms" are closed source? How much is "a lot of memory"?<br /><br />This "outrolling" of recursive code is something I have already tried for HD=5. It works and actually gives some significant speed-up of >10% compared to an implementation that uses pseudo-recursions on a manually managed stack. <br /><br />Still this is small compared to the slow-down caused by the huge and (seemingly) arbitrary payload differences between polynomials (resulting in huge loop-count differences, leading to huge thread divergence). That effect results in a slowdown in the dimension of 2000% which is a total show-stopper.<br /><br />Since there seem to be no heuristics, the only workaround (I can think of) would be a single-loop solution that is able to compute payloads for HDs > 4. I would have ideas how to exploit such a single-loop implementation to maximize GPU utilization. <br /><br />But looking at your HDLen code, e.g. for HD=5 a minimum of two nested loops is required. Using the optimization option even three loops. The accumulator manipulations inside those loops are similar to each other but the exit conditions differ a lot. I can't think of a way to solve this using only one uniform loop without big divergent branches. Jordynoreply@blogger.comtag:blogger.com,1999:blog-4172950626830217643.post-49597033531760409402022-03-13T10:27:26.316-04:002022-03-13T10:27:26.316-04:00The fast algorithms tend to require lots of memory...The fast algorithms tend to require lots of memory for various reasons to speed things up beyond the HDLen code.<br /><br />If you want GPU friendly code (which I have never tried) you don't have to have recursion -- it is just more convenient to write it that way. A set of nested loops for a particular HD will work the same. (You'll need different loop source code for each HD, but there aren't that many HDs you care about.) Then batch up a set of polynomials and run all combinations of bits across all of them.<br /><br />There are some heuristics for faster search campaigns in section 4.1 of this paper:<br />https://users.ece.cmu.edu/~koopman/networks/dsn02/dsn02_koopman.pdf<br /><br /><br />Phil Koopmanhttps://www.blogger.com/profile/11849599272360094243noreply@blogger.comtag:blogger.com,1999:blog-4172950626830217643.post-25828005264199191522022-03-12T19:47:40.158-05:002022-03-12T19:47:40.158-05:00Of course I have seen your great work there. Thank...Of course I have seen your great work there. Thanks for that! I also have seen your HDLen code. <br /><br />I tried to write similar code for GPUs. But I failed because the performance between polynomials varies a lot in an arbitrary way, which kills the performance on SIMD architectures due to thread divergence. One way to solve that would have been to roughly sort the polynomials by expected performance so the actual brute-force computation is more efficient.<br /><br />Seems I am stuck if there isn't such a heuristic.<br /><br />Is HDLen the only publicly available code for performance computation? Have you ever seen alternative/primitive implementations that is able to compute an entire HD for a given polynomial without recursion, without nested loops and without multiple different conditional exit branches? Such a code, even when less efficient on GPUs, could be a game changer on a GPU.Jordynoreply@blogger.comtag:blogger.com,1999:blog-4172950626830217643.post-73717669920294415242022-03-12T19:25:27.418-05:002022-03-12T19:25:27.418-05:00As far as know there is no heuristic method, just ...As far as know there is no heuristic method, just brute force search.<br />But I've already done the searching for you here:<br /> https://users.ece.cmu.edu/~koopman/crc/hd5.html<br />or more generally here:<br /> https://users.ece.cmu.edu/~koopman/crc/index.html<br />Phil Koopmanhttps://www.blogger.com/profile/11849599272360094243noreply@blogger.comtag:blogger.com,1999:blog-4172950626830217643.post-88525490654720379152022-03-12T19:21:12.065-05:002022-03-12T19:21:12.065-05:00Hello Mr. Koopman,
do you know of any heuristic m...Hello Mr. Koopman,<br /><br />do you know of any heuristic method to predict the performance (i.e. max. payload size) of a given polynomial at a given HD of 5 and above? Such a method don't need to be very precise. Even a rough estimate would be EXTREMELY helpful when searching for optimal polynomials.Jordynoreply@blogger.comtag:blogger.com,1999:blog-4172950626830217643.post-31979994497175355072022-01-05T09:52:40.376-05:002022-01-05T09:52:40.376-05:00Karl Weigers' lessons are found on https://bet...Karl Weigers' lessons are found on https://betterprogramming.pub/sixty-software-development-pearls-of-wisdom-22754a9a27dbPeterhttps://www.blogger.com/profile/10167909323435996285noreply@blogger.comtag:blogger.com,1999:blog-4172950626830217643.post-71985480880039048112021-12-27T00:14:23.653-05:002021-12-27T00:14:23.653-05:00Well, the list of possible faults focus mainly on ...Well, the list of possible faults focus mainly on the protocol but lacks much of standard software mitigation mechanisms like in AUTOSAR and ignore the system architecture of the nodes in a vehicle.Mohamed Elmawazinihttps://www.blogger.com/profile/05020626551061897849noreply@blogger.comtag:blogger.com,1999:blog-4172950626830217643.post-87077045334314333492021-11-02T11:41:01.570-04:002021-11-02T11:41:01.570-04:00Sadly there are many embedded systems without that...Sadly there are many embedded systems without that optimization in their compiler. Moreover, the tail recursion can easily be broken by later maintenance. It's better not to get into a "well as long as..." type situation if people's lives depend on it.Phil Koopmanhttps://www.blogger.com/profile/11849599272360094243noreply@blogger.comtag:blogger.com,1999:blog-4172950626830217643.post-46580643895570312632021-11-01T21:02:09.935-04:002021-11-01T21:02:09.935-04:00A recursive function should be safe so long as it ...A recursive function should be safe so long as it is tail-recursive and you're using a static compiler (that implements the corresponding optimization). Most C and C++ compilers implement this optimization. Dynamically compiled languages (e.g. Java) do not.<br /><br />There only 3 cases where you need to worry about stack frames for recursive functions: When your function is not tail-recursive, When you are using a dynamic compiler, and when you are using static compiler that is complete garbage.Anonymoushttps://www.blogger.com/profile/06366449253783818726noreply@blogger.comtag:blogger.com,1999:blog-4172950626830217643.post-12094209916195059442021-10-27T08:31:25.447-04:002021-10-27T08:31:25.447-04:00See this other page for the usual suspects:
https...See this other page for the usual suspects: <br />https://betterembsw.blogspot.com/2011/11/avoiding-eeprom-corruption-problems.htmlPhil Koopmanhttps://www.blogger.com/profile/11849599272360094243noreply@blogger.comtag:blogger.com,1999:blog-4172950626830217643.post-66677112992672194082021-10-27T05:13:47.077-04:002021-10-27T05:13:47.077-04:00Hi, This is Ram
I am using Flowcode software for ...Hi, This is Ram<br /> I am using Flowcode software for microcontroller programming. And the ic is PIC18f46k40 we have some problem in eeprom, if we store some value in specific address then after 3 or 4 month it will automatically change <br />and if we set again then it will work for 4 or 5 month and again same problem. Their is no power fluctuation but i can not understand why this is happen so please guide how to solve Ramhttps://www.blogger.com/profile/00062341834447931270noreply@blogger.comtag:blogger.com,1999:blog-4172950626830217643.post-11250807848339821612021-10-15T21:40:30.292-04:002021-10-15T21:40:30.292-04:00You need to do this to prevent a race condition du...You need to do this to prevent a race condition during the operation (i.e., to make it an atomic operation), assuming a single core processor.Phil Koopmanhttps://www.blogger.com/profile/11849599272360094243noreply@blogger.comtag:blogger.com,1999:blog-4172950626830217643.post-52293090029772509782021-10-15T20:48:53.182-04:002021-10-15T20:48:53.182-04:00Hello, I bought your book is very interesting!!.
...Hello, I bought your book is very interesting!!.<br /><br />I have a question: <br />why in the above code inside the "Void Alive function (uint16 x);" interrupts are disabled and then enabled. It may be a silly question but I am new to the world of microcontrollers.<br /><br />ThanksLuis Peñahttps://www.blogger.com/profile/08296337096384402935noreply@blogger.comtag:blogger.com,1999:blog-4172950626830217643.post-86133356000707373422021-10-11T14:42:19.918-04:002021-10-11T14:42:19.918-04:00Thanks for letting me know.Thanks for letting me know.Phil Koopmanhttps://www.blogger.com/profile/11849599272360094243noreply@blogger.comtag:blogger.com,1999:blog-4172950626830217643.post-52779725685939135732021-10-11T14:39:07.181-04:002021-10-11T14:39:07.181-04:00It says author have deleted this story Mr. Phil Ko...It says author have deleted this story Mr. Phil KoopmanAnonymoushttps://www.blogger.com/profile/11884322443606435856noreply@blogger.com