<?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 Re: S08 Random Number Generator in 8-bit Microcontrollers</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/S08-Random-Number-Generator/m-p/186318#M13993</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Hello,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The % operator, and all the other operators should be listed within the "Operands" section.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Your problem is because the number 256 is being treated as a hexadecimal value, rather than decimal.&amp;nbsp; When the P&amp;amp;Eassembler is first started, the default number base is hexadecimal. &amp;nbsp;If you do not wish to change the default number&amp;nbsp;base to decimal using the directive #BASE 10T, you can either use 100 as the hexadecimal equivalent of 256 decimal, or specifically define 256 as a decimal number.&amp;nbsp; the following instructions should produce the same result for&amp;nbsp;a hexadecimal base.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; EOR&amp;nbsp;&amp;nbsp;&amp;nbsp; #{POLYVAL/256T}&amp;nbsp; ; Explicit decimal&amp;nbsp;divisor&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; EOR&amp;nbsp;&amp;nbsp;&amp;nbsp; #{POLYVAL/$100}&amp;nbsp;&amp;nbsp;; Explicit hexadecimal&amp;nbsp;divisor&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; EOR&amp;nbsp;&amp;nbsp;&amp;nbsp; #{POLYVAL/100}&amp;nbsp;&amp;nbsp; ; Default hexadecimal divisor&lt;BR /&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;For me, it is more intuitive to use the BASE directive so that decimal numbers are the default, and hexadecimal or binary numbers&amp;nbsp;need to be explicitly defined as such.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Interestingly, the CW assembler defaults to a decimal number base.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Regards,&lt;/DIV&gt;&lt;DIV&gt;Mac&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;Message Edited by bigmac on &lt;SPAN class="date_text"&gt;2008-09-25&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;04:17 PM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 25 Sep 2008 12:59:58 GMT</pubDate>
    <dc:creator>bigmac</dc:creator>
    <dc:date>2008-09-25T12:59:58Z</dc:date>
    <item>
      <title>S08 Random Number Generator</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/S08-Random-Number-Generator/m-p/186296#M13971</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;I am looking for a way of generatring an 8 bit&amp;nbsp;random number using an S08. Preferably in assembly.&amp;nbsp; I have searched the web endlessly but haven't found anything simple and usable.&amp;nbsp; Any ideas appreciated.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Sep 2008 20:13:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/S08-Random-Number-Generator/m-p/186296#M13971</guid>
      <dc:creator>Davo</dc:creator>
      <dc:date>2008-09-16T20:13:03Z</dc:date>
    </item>
    <item>
      <title>Re: S08 Random Number Generator</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/S08-Random-Number-Generator/m-p/186297#M13972</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;The first question is how "random" does it need to be?&lt;BR /&gt;What are you going to use it for?&lt;BR /&gt;"Good" random generators are just not as simple as you may like.&lt;BR /&gt;&lt;BR /&gt;This is about as simple as it gets.&lt;BR /&gt;&lt;BR /&gt;Read &lt;A href="http://en.wikipedia.org/wiki/Linear_congruential_generator" rel="nofollow noopener noreferrer noopener noreferrer" target="_blank"&gt;this&lt;/A&gt; to see if it it will do.&lt;BR /&gt;It this is good enough, then I am sure the asm guys will jump in to tell you the best way to do it.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;DIV class="msg_source_code"&gt;&lt;DIV class="text_smallest"&gt;Code:&lt;/DIV&gt;&lt;PRE&gt;unsigned long int lehmer(long int s)//  linear congruential pseudo based on D. Lehmer{  static unsigned long long a = 2007, b = 4194301, c = 2147483647, z = b;    if ( s &amp;lt; 0 ) {s = -s; a = s;}    z = (a + b * z) % c;    return z % s;}&lt;/PRE&gt;&lt;/DIV&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Message Edited by JimDon on &lt;SPAN class="date_text"&gt;2008-09-16&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;09:40 AM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:37:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/S08-Random-Number-Generator/m-p/186297#M13972</guid>
      <dc:creator>JimDon</dc:creator>
      <dc:date>2020-10-29T09:37:16Z</dc:date>
    </item>
    <item>
      <title>Re: S08 Random Number Generator</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/S08-Random-Number-Generator/m-p/186298#M13973</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;If you have an AD input or time input, you may use them to generate your random number.&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Sep 2008 00:50:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/S08-Random-Number-Generator/m-p/186298#M13973</guid>
      <dc:creator>Roach</dc:creator>
      <dc:date>2008-09-17T00:50:27Z</dc:date>
    </item>
    <item>
      <title>Re: S08 Random Number Generator</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/S08-Random-Number-Generator/m-p/186299#M13974</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hello,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Use of the Lehmer algorithm, as suggested by JimD, may be somewhat overkill for an 8-bit result, since 32-bit quantities are used&amp;nbsp;during the calculation.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;You might also consider a pseudo-random sequence (PRS), similar to that used for CRC calculations.&amp;nbsp; The suitability will depend on your application.&amp;nbsp; For an 8-bit PRS, the pattern will repeat after 255 iterations, and for 16-bit, the sequence&amp;nbsp;length would be 65535 iterations.&amp;nbsp;Each of the possible (non-zero) values will occur once within each sequence.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The starting point for the sequence will be determined by initialisation of a "seed" value.&amp;nbsp; If the starting point should be different for each equipment, the seed must be related to an external event.&amp;nbsp; Perhaps read the TPM counter when this randomly timed event occurs, and use the LS byte as the seed.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The following 8-bit PRS is based on a CRC function coded in C, and then converted to ASM.&amp;nbsp; The ASM code is untested.&amp;nbsp; The 8-bit polynomial used is X^8 + X^5 + X^4 + 1.&amp;nbsp; The subroutine assumes that you have allocate a byte variable RAND, preferably within zero page RAM, and that this has been initialised to the required non-zero seed value.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;POLYVAL&amp;nbsp;EQU $8C&amp;nbsp; ; Polynomial value&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;; PRS sub-routine:&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;; On exit, ACC = next value of sequence&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;NEXTVAL:&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; LDX&amp;nbsp;&amp;nbsp; #8&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LDA&amp;nbsp;&amp;nbsp; RAND&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;NV1:&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;LSRA&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BCC&amp;nbsp;&amp;nbsp; NV2&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; EOR&amp;nbsp;&amp;nbsp; #POLYVAL&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;NV2:&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;DBNZX NV1&amp;nbsp; ; Loop for next bit&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;STA&amp;nbsp;&amp;nbsp; RAND&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;RTS&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;This process could be easily extended to a 16 bit PRS, obviously&amp;nbsp;using a suitable&amp;nbsp;16-bit polynomial.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Regards,&lt;/DIV&gt;&lt;DIV&gt;Mac&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Sep 2008 13:06:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/S08-Random-Number-Generator/m-p/186299#M13974</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2008-09-17T13:06:46Z</dc:date>
    </item>
    <item>
      <title>Re: S08 Random Number Generator</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/S08-Random-Number-Generator/m-p/186300#M13975</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Thanks bigmac.&amp;nbsp; I tested this generator and it works well.&amp;nbsp; There are a few more things I would like&amp;nbsp;to achieve:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I would like to range the number within 0-47 or 1-48.&amp;nbsp; I tried simply rejecting every value over 48 but that didn't seem to give me well distributed results.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The "randomness" is not overly important, however I do want every number in the range to appear at least occaisonally.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The end goal is that I have 48 outputs that I need to randomly turn-on and turn-off every few seconds - and every bit should over a period of time (minutes to 10's of minutes) have a turn at being in either state.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;thanks again&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Sep 2008 04:16:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/S08-Random-Number-Generator/m-p/186300#M13975</guid>
      <dc:creator>Davo</dc:creator>
      <dc:date>2008-09-18T04:16:01Z</dc:date>
    </item>
    <item>
      <title>Re: S08 Random Number Generator</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/S08-Random-Number-Generator/m-p/186301#M13976</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;Hello,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;If you are simply toggling the respective LED when each value between 1 and 48 is output, this will not produce random on and off intervals since the sequence repeats every 255 iterations.&amp;nbsp; If you do require "randomness" for the intervals, one way would be to use a 48-bit PRS generator, with each &lt;U&gt;bit&lt;/U&gt; representing&amp;nbsp;a LED state.&amp;nbsp; However, this might be more complex than the task warrants.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;A possible alternative might be to divide the LEDs into three groups of 16.&amp;nbsp; Now divide the 8-bit result so that the low nybble addresses the LED position in each group, and the MS bit determines whether the addressed LED should be currently on or off.&amp;nbsp; The remaining three bits would be used to select the LED group - so the 8 states would need to be mapped to the three groups.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;One possibility might me to ignore two of the states (representing no change to LED status), and map the remaining 6 states, with two states per group.&amp;nbsp; Alternatively, if the groups are physically interspersed, it may be acceptable to favour two of the groups over the third, i.e. 3 + 3 + 2 = 8.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The following code represents a slightly more complex arrangement that achieves 24 states using an auxiliary COUNT variable.&amp;nbsp; However, I don't know how "random" the group selection will actually be.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; JSR&amp;nbsp;&amp;nbsp; NEXTVAL&amp;nbsp;&amp;nbsp; ; Get next PRS value&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PSHA&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; AND&amp;nbsp;&amp;nbsp; #$0F&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; Low nybble&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;STA&amp;nbsp;&amp;nbsp; ADDRESS&amp;nbsp;&amp;nbsp; ; LED address within group&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LDX&amp;nbsp;&amp;nbsp; COUNT&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; Auxiliary counter&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; AIX&amp;nbsp;&amp;nbsp; #8&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CPX&amp;nbsp;&amp;nbsp; #24&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; BLO&amp;nbsp;&amp;nbsp; *+3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; Skip next if no overflow&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CLRX&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; STX&amp;nbsp;&amp;nbsp; COUNT&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PULA&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; PRS value&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PSHX&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; NSA&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; AND&amp;nbsp;&amp;nbsp; #$07&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; Range 0-7&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ORA&amp;nbsp;&amp;nbsp; 1,SP&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; Combine with count value (0-23)&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; AIS&amp;nbsp;&amp;nbsp; #1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; Adjust stack pointer&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LDX&amp;nbsp;&amp;nbsp; #3&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DIV&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PSHH&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; Remainder (0-2)&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PULA&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; NSA&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ORA&amp;nbsp;&amp;nbsp; ADDRESS&amp;nbsp;&amp;nbsp; ; Combine with low nybble&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; STA&amp;nbsp;&amp;nbsp;&amp;nbsp;ADDRESS&amp;nbsp;&amp;nbsp; ; Range 0-47&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; BRSET 7,RAND,BR1 ; Branch if LED on state&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; JSR&amp;nbsp;&amp;nbsp; LED_OFF&amp;nbsp;&amp;nbsp;&amp;nbsp;; Addressed LED off&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; BRA&amp;nbsp;&amp;nbsp; BR2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; Branch always&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;BR1:&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; JSR&amp;nbsp;&amp;nbsp; LED_ON&amp;nbsp;&amp;nbsp;&amp;nbsp; ; Addressed LED on&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;BR2:&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Regards,&lt;/DIV&gt;&lt;DIV&gt;Mac&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;Message Edited by bigmac on &lt;SPAN class="date_text"&gt;2008-09-18&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;03:12 PM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Sep 2008 11:49:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/S08-Random-Number-Generator/m-p/186301#M13976</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2008-09-18T11:49:51Z</dc:date>
    </item>
    <item>
      <title>Re: S08 Random Number Generator</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/S08-Random-Number-Generator/m-p/186302#M13977</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Thanks again Mac for your reply.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I do need to work from a number that is 0-47 or 1-48.&amp;nbsp; The reason being that I don't want a situation where many outputs can change at one time.&amp;nbsp; There needs to be a gradual changing of states.&amp;nbsp; So I basically feed the number into a routine that sets/clears the corresponding bit.&amp;nbsp; A separate&amp;nbsp;random number generator makes the set/clear decision (simply use one bit of the 8 bit result&amp;nbsp;to make the set/clear decision).&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The compactness of the code is not important, as the processor is pretty idle and the app only takes a few k. It's running in an SH8.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Perhaps I could take the 8 bit result and divide it by 48 and use the remainder.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;One other point - I need a seed that has some rendomness about it.&amp;nbsp; I was thinking of using the lower bits of the internal temperature sensor read by the ADC. There should be sufficient noise and variability. Your thoughts?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Sep 2008 12:23:41 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/S08-Random-Number-Generator/m-p/186302#M13977</guid>
      <dc:creator>Davo</dc:creator>
      <dc:date>2008-09-18T12:23:41Z</dc:date>
    </item>
    <item>
      <title>Re: S08 Random Number Generator</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/S08-Random-Number-Generator/m-p/186303#M13978</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;dah !&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;of course I can't use the reminder because 48 doesn't evenly divide into 256&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Sep 2008 12:58:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/S08-Random-Number-Generator/m-p/186303#M13978</guid>
      <dc:creator>Davo</dc:creator>
      <dc:date>2008-09-18T12:58:27Z</dc:date>
    </item>
    <item>
      <title>Re: S08 Random Number Generator</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/S08-Random-Number-Generator/m-p/186304#M13979</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hello,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;If I correctly understand your requirements, the code sample that I gave would seem to meet most of them.&amp;nbsp; For each sample, a maximum of one LED would change state.&amp;nbsp; Of course there will be many samples where no change occurs because the new state for a particular LED is identical to&amp;nbsp;its previous state.&amp;nbsp; But I don't think this would detract from the randomness of the process.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The sample code attempts to provide equal weighting to all LEDs.&amp;nbsp; Simply dividing by 48 may also be adequate, but some LEDs will have more weighting.&amp;nbsp;&amp;nbsp;LEDs 1-15 would be addressed six times during each PRS cycle, whereas the other LEDs would be addressed five times.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;With this in mind, there is possibly some advantage in using an 8-bit value from a&amp;nbsp;16-bit PRS, so that each LED is addressed many more times during&amp;nbsp;the full PRS cycle.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I would suggest running the LED control code from within the ISR associated with a TPM overflow interrupt.&amp;nbsp; With the use of an additional counter variable, the update could occur once every N overflows.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I assume that the seed would only need to be initialised after each POR.&amp;nbsp; The only reason I can think of for having this randomised would be for the case of multiple units, operating side by side, to have different display&amp;nbsp;patterns.&amp;nbsp; The temperature sensor measurement may possibly work, however if multiple units are subject to the same temperature environment, the&amp;nbsp;range of different values may be quite limited.&amp;nbsp; I would suggest using the low byte of a 10-bit measurement, and swap the nybbles.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;An alternative possibility that comes to mind&amp;nbsp;is to use an external R and C, connected to a comparator input.&amp;nbsp; Then read the low byte of the TPM counter value when the capacitor (or resistor) voltage reaches the internal reference level and the comparator changes state.&amp;nbsp; The time constant should&amp;nbsp;correspond to many TPM increments, and the capacitor&amp;nbsp;should be a&amp;nbsp;loose tolerance type (-20, +80 percent) used typically for bypassing applications.&amp;nbsp;Finally, don't trim the internal clock until this process is completed.&amp;nbsp; Again, I would swap the nybbles of the counter value.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Regards,&lt;/DIV&gt;&lt;DIV&gt;Mac&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Sep 2008 14:04:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/S08-Random-Number-Generator/m-p/186304#M13979</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2008-09-18T14:04:25Z</dc:date>
    </item>
    <item>
      <title>Re: S08 Random Number Generator</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/S08-Random-Number-Generator/m-p/186305#M13980</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Getting Interesting.&amp;nbsp; The first routine (NEXTVAL) works OK, however about 30% of the numbers never get generated (meaning some LEDs don't ever get turned on).&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The second routine crashes - not had time yet to debug it, but the COP times out when the routine is called.&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Sep 2008 20:19:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/S08-Random-Number-Generator/m-p/186305#M13980</guid>
      <dc:creator>Davo</dc:creator>
      <dc:date>2008-09-18T20:19:02Z</dc:date>
    </item>
    <item>
      <title>Re: S08 Random Number Generator</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/S08-Random-Number-Generator/m-p/186306#M13981</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;i is 150 for all 48 values. This varies with the initial value of z.&lt;BR /&gt;&lt;BR /&gt;You could probably tweak the values and get it better than that. Read the wiki I linked to for advise.&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;DIV class="msg_source_code"&gt;&lt;DIV class="text_smallest"&gt;Code:&lt;/DIV&gt;&lt;PRE&gt;#include "stdafx.h"



unsigned char lehmer(unsigned char  s)
{  static unsigned short a = 2007,
   b = 7,
   m = 32768,
   z=0;
   
    z = (b + a * z) % m;
    return (z &amp;gt;&amp;gt; 6) % s;
}
int main(int argc, char* argv[])
{
 int i = 0;
        unsigned char data[48];
        int j = 0;

 while( j &amp;lt; 48)
 {
  unsigned char c = lehmer(48);
  if( data[c] == 0)
  {
   ++j;
   printf("%d\n",  c );
   data[c] = 1;
  }
  if( j == 48 )
   break;
  ++i;

 }
 printf("\n%d i=%d\n",  j,i );
 return 0;
}

&lt;/PRE&gt;&lt;/DIV&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:37:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/S08-Random-Number-Generator/m-p/186306#M13981</guid>
      <dc:creator>JimDon</dc:creator>
      <dc:date>2020-10-29T09:37:18Z</dc:date>
    </item>
    <item>
      <title>Re: S08 Random Number Generator</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/S08-Random-Number-Generator/m-p/186307#M13982</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Might not be following this correctly, but think you can scale your random number by treating the 0-255 (for 8 bits)&amp;nbsp;as 0-1 (by considering the "binary point" at the left), and just multiply it by 49 to get 0-48 out.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Jim&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Sep 2008 04:08:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/S08-Random-Number-Generator/m-p/186307#M13982</guid>
      <dc:creator>JimB</dc:creator>
      <dc:date>2008-09-19T04:08:25Z</dc:date>
    </item>
    <item>
      <title>Re: S08 Random Number Generator</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/S08-Random-Number-Generator/m-p/186308#M13983</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hello,&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;BR /&gt;&lt;/DIV&gt;&lt;BLOCKQUOTE&gt;&lt;DIV&gt;&lt;HR /&gt;Davo wrote:&lt;BR /&gt;&lt;DIV&gt;Getting Interesting.&amp;nbsp; The first routine (NEXTVAL) works OK, however about 30% of the numbers never get generated (meaning some LEDs don't ever get turned on).&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The second routine crashes - not had time yet to debug it, but the COP times out when the routine is called.&lt;/DIV&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;&lt;DIV&gt;Yes, there is a problem with the manner in which I attempted to convert the original CRC routine to a PRS in assembler - the sequence was not maximal length, and only 50 percent of the possible codes were generated.&amp;nbsp; However, using the CRC method, I now feel that you will need a 16-bit generator to obtain a much longer sequence length.&amp;nbsp; Apparently successful tests were conducted with the following C code, under simulation.&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;#include &amp;lt;hidef.h&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* EnableInterrupts macro */&lt;BR /&gt;#include "derivative.h" /* Include peripheral declarations */&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;typedef union {&lt;BR /&gt;&amp;nbsp;&amp;nbsp; word wval;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; byte bval[2];&lt;BR /&gt;} DBYTE;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;// Global variables:&lt;BR /&gt;DBYTE CRC16;&lt;BR /&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;// Function prototypes:&lt;BR /&gt;void update_crc16( word new, word *crc);&lt;BR /&gt;void LED_control( byte address);&lt;BR /&gt;void LED_on( byte addr);&lt;BR /&gt;void LED_off( byte addr);&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;/**********************************************************************/&lt;BR /&gt;void main(void)&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; static byte a;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; static word i;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp; EnableInterrupts;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp; for( ; ; ) {&lt;BR /&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; update_crc16( 1, &amp;amp;CRC16.wval);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a = CRC16.bval[0] ^ CRC16.bval[1];&amp;nbsp; // Combine the two bytes&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ((a &amp;amp; 0x3F) &amp;lt; 48) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a &amp;amp;= 0xBF;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // MS bit represents LED state&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LED_control( a);&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; __RESET_WATCHDOG();&lt;BR /&gt;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;}&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;/**********************************************************************/&lt;BR /&gt;/* Update 16-bit CRC value&lt;BR /&gt;&amp;nbsp;* Polynomial: x^16 + x^15 + x^2 + 1 */&lt;BR /&gt;#define POLYVAL16 0xA001&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;void update_crc16( word new, word *crc)&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; word c;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; byte i;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp; c = *crc;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; for (i = 0; i &amp;lt; 16; i++) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ((c ^ new) &amp;amp; 1)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; c = (c &amp;gt;&amp;gt; 1) ^ POLYVAL16;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; c &amp;gt;&amp;gt;= 1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; new &amp;gt;&amp;gt;= 1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&amp;nbsp; *crc = c;&lt;BR /&gt;}&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;/**********************************************************************/&lt;BR /&gt;/* Control of addressed LED */&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;void LED_control( byte address)&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; if (address &amp;amp; 0x80)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LED_on( address &amp;amp; 0x3F);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; else&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LED_off( address &amp;amp; 0x3F);&lt;BR /&gt;}&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;With this code the two bytes of the CRC value are XORed (modulo 2 addition).&amp;nbsp; Bit-7 of the result then indicates the next state for the addressed LED, bit-6 is ignored, and the remaining six bits indicate the address of the LED, with values 48-63 as a do nothing condition.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;My tests over about one half the sequence length of 65535,&amp;nbsp;showed that&amp;nbsp; each LED is addressed a similar number of times, although not quite&amp;nbsp;equal, for both LED on and LED off conditions.&amp;nbsp; About one half the LEDs will be active at any time.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;For the purpose of testing the code, I put no delay in the loop between each call of the CRC function, but in practice this would be necessary for your application.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Regards,&lt;/DIV&gt;&lt;DIV&gt;Mac&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 20 Sep 2008 21:21:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/S08-Random-Number-Generator/m-p/186308#M13983</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2008-09-20T21:21:57Z</dc:date>
    </item>
    <item>
      <title>Re: S08 Random Number Generator</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/S08-Random-Number-Generator/m-p/186309#M13984</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hi Mac,&amp;nbsp; Do you have an assembly version of the code ?&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Sep 2008 05:31:17 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/S08-Random-Number-Generator/m-p/186309#M13984</guid>
      <dc:creator>Davo</dc:creator>
      <dc:date>2008-09-22T05:31:17Z</dc:date>
    </item>
    <item>
      <title>Re: S08 Random Number Generator</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/S08-Random-Number-Generator/m-p/186310#M13985</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hello,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;No, I did not convert the 16-bit CRC algorithm, as I previously did for the 8-bit CRC.&amp;nbsp; It was quicker to do the simulation tests using C.&amp;nbsp; Is there any particular reason that you need to use assembler?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Regards,&lt;/DIV&gt;&lt;DIV&gt;Mac&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Sep 2008 18:48:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/S08-Random-Number-Generator/m-p/186310#M13985</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2008-09-22T18:48:48Z</dc:date>
    </item>
    <item>
      <title>Re: S08 Random Number Generator</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/S08-Random-Number-Generator/m-p/186311#M13986</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;You can use C and assembler, but mac does have a point.&lt;BR /&gt;&lt;BR /&gt;You will be much more productive using "C".&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Sep 2008 19:13:53 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/S08-Random-Number-Generator/m-p/186311#M13986</guid>
      <dc:creator>JimDon</dc:creator>
      <dc:date>2008-09-22T19:13:53Z</dc:date>
    </item>
    <item>
      <title>Re: S08 Random Number Generator</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/S08-Random-Number-Generator/m-p/186312#M13987</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Mac, I do appreciate all of your help with this.&amp;nbsp; I am converting some legacy code to include some new features.&amp;nbsp; The main body is all in assembly.&amp;nbsp; I'm not a C programmer and haven't had the time to learn given the small amounts of code I cut these days.&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Sep 2008 06:48:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/S08-Random-Number-Generator/m-p/186312#M13987</guid>
      <dc:creator>Davo</dc:creator>
      <dc:date>2008-09-23T06:48:01Z</dc:date>
    </item>
    <item>
      <title>Re: S08 Random Number Generator</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/S08-Random-Number-Generator/m-p/186313#M13988</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;&lt;/DIV&gt;&lt;BLOCKQUOTE&gt;&lt;DIV&gt;&lt;HR /&gt;Davo wrote:&lt;BR /&gt;&lt;DIV&gt;Hi Mac,&amp;nbsp; Do you have an assembly version of the code ?&lt;/DIV&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;; variable/data section&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp; ORG&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Z_RAMStart&lt;BR /&gt;RAND:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DS.W&amp;nbsp;&amp;nbsp; 1&lt;BR /&gt;ADDRESS:&amp;nbsp; DS.B&amp;nbsp;&amp;nbsp; 1&lt;BR /&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;;*******************************************************************&lt;BR /&gt;; Set next LED state change&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;NEXT_STATE:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; JSR&amp;nbsp;&amp;nbsp;&amp;nbsp; NEXTVAL&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; Get next PRS value&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PSHA&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AND&amp;nbsp;&amp;nbsp;&amp;nbsp; #$3F&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; Mask first 6 bits&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; STA&amp;nbsp;&amp;nbsp;&amp;nbsp; ADDRESS&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CMP&amp;nbsp;&amp;nbsp;&amp;nbsp; #48&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; Test for within range 0-47&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PULA&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BHS&amp;nbsp;&amp;nbsp;&amp;nbsp; NS2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; Exit if out of range (no change)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AND&amp;nbsp;&amp;nbsp;&amp;nbsp; #$80&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; Test bit-7&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BNE&amp;nbsp;&amp;nbsp;&amp;nbsp; NS1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; Branch if bit is set&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LDA&amp;nbsp;&amp;nbsp;&amp;nbsp; ADDRESS&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; JSR&amp;nbsp;&amp;nbsp;&amp;nbsp; LED_OFF&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; Addressed LED turn-off&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RTS&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;NS1:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LDA&amp;nbsp;&amp;nbsp;&amp;nbsp; ADDRESS&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; JSR&amp;nbsp;&amp;nbsp;&amp;nbsp; LED_ON&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; Addressed LED turn-on&lt;BR /&gt;NS2:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RTS&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;;*******************************************************************&lt;BR /&gt;; PRS sub-routine:&lt;BR /&gt;; On exit, ACC = next value of sequence&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;POLYVAL&amp;nbsp;&amp;nbsp; EQU&amp;nbsp;&amp;nbsp;&amp;nbsp; $A001&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; Polynomial value&lt;BR /&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;NEXTVAL:&amp;nbsp; LDX&amp;nbsp;&amp;nbsp;&amp;nbsp; #16&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; Bit count&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LDA&amp;nbsp;&amp;nbsp;&amp;nbsp; RAND+1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; Low byte&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; EOR&amp;nbsp;&amp;nbsp;&amp;nbsp; #1&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PSHA&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; 2,SP&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LDA&amp;nbsp;&amp;nbsp;&amp;nbsp; RAND&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; High byte&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PSHA&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; 1,SP&lt;BR /&gt;NV1:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LSR&amp;nbsp;&amp;nbsp;&amp;nbsp; 1,SP&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ROR&amp;nbsp;&amp;nbsp;&amp;nbsp; 2,SP&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BCC&amp;nbsp;&amp;nbsp;&amp;nbsp; NV2&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LDA&amp;nbsp;&amp;nbsp;&amp;nbsp; 1,SP&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; EOR&amp;nbsp;&amp;nbsp;&amp;nbsp; #(POLYVAL/256)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; STA&amp;nbsp;&amp;nbsp;&amp;nbsp; 1,SP&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LDA&amp;nbsp;&amp;nbsp;&amp;nbsp; 2,SP&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; EOR&amp;nbsp;&amp;nbsp;&amp;nbsp; #(POLYVAL%256)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; STA&amp;nbsp;&amp;nbsp;&amp;nbsp; 2,SP&lt;BR /&gt;NV2:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DBNZX&amp;nbsp; NV1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; Loop for next bit&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PULA&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; High byte&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; STA&amp;nbsp;&amp;nbsp;&amp;nbsp; RAND&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PULA&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; Low byte&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; STA&amp;nbsp;&amp;nbsp;&amp;nbsp; RAND+1&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; EOR&amp;nbsp;&amp;nbsp;&amp;nbsp; RAND&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; Combine byte values&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RTS&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;Message Edited by bigmac on &lt;SPAN class="date_text"&gt;2008-09-24&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;03:13 PM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Sep 2008 12:09:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/S08-Random-Number-Generator/m-p/186313#M13988</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2008-09-24T12:09:04Z</dc:date>
    </item>
    <item>
      <title>Re: S08 Random Number Generator</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/S08-Random-Number-Generator/m-p/186314#M13989</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Mac, again - thanks for the reply.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;My P&amp;amp;E assembler didn't accept the % operator. #(POLYVAL%256)&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;I assume this is an Intel operator. I replaced it with #{POLYVAL&amp;amp;256} assuming it was a bitwise AND of POLYVAL. This worked a treat and I am getting a pretty good distribution of random numbers.&lt;/FONT&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Sep 2008 06:25:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/S08-Random-Number-Generator/m-p/186314#M13989</guid>
      <dc:creator>Davo</dc:creator>
      <dc:date>2008-09-25T06:25:35Z</dc:date>
    </item>
    <item>
      <title>Re: S08 Random Number Generator</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/S08-Random-Number-Generator/m-p/186315#M13990</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;% means modulo, not and, and therefore&lt;BR /&gt;using "&amp;amp; 256" will just load&amp;nbsp; 0....&lt;BR /&gt;I would try just no operator first "&lt;FONT size="2"&gt;#POLYVAL"&lt;/FONT&gt;, or if that gives a warning, try "&amp;amp;255"&lt;BR /&gt;(or check the P&amp;amp;E Manual how to get the lower 8 bits of a label).&lt;BR /&gt;&lt;BR /&gt;Daniel&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Sep 2008 08:34:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/S08-Random-Number-Generator/m-p/186315#M13990</guid>
      <dc:creator>CompilerGuru</dc:creator>
      <dc:date>2008-09-25T08:34:18Z</dc:date>
    </item>
  </channel>
</rss>

