<?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: Demo board MC9S08DZ60, global declarations in 8-bit Microcontrollers</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Demo-board-MC9S08DZ60-global-declarations/m-p/147870#M7562</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Kef.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I knew that was true on some SPI modules, so I looked at the block diagram "Figure 13-2. SPI System Connections﻿" on page 275, and saw only MSB first. But had I looked further to "Figure 13-3. SPI Module Block Diagram﻿" on page 277, I would have seen the LSBFE bit.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 10 Jul 2011 15:59:28 GMT</pubDate>
    <dc:creator>rocco</dc:creator>
    <dc:date>2011-07-10T15:59:28Z</dc:date>
    <item>
      <title>Demo board MC9S08DZ60, global declarations</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Demo-board-MC9S08DZ60-global-declarations/m-p/147865#M7557</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, I am fairly new to the Freescale line of microcontrollers and not too experienced with ANSI C overall.&amp;nbsp; What I am trying to do on this demo board is to read in 52 bits from a clocked pin.&amp;nbsp; The data is in ultimatley in 12x 4-bit words.&amp;nbsp; I can get this running using a array of char[52].&amp;nbsp; This is obviosly a huge waste of memory.&amp;nbsp; This array is declared globally so it can be populated in an interrupt triggered by the clock pin, and manipulated in the ProcessorExpert main() into a char array where I can at least handle the 4-bit words.&amp;nbsp; I can create a boolean array in the ProcessorExpert main(), but if I try it as an extern bool array[] the compiler throws an error (C2450 Expected: ; = ,) I think this would be an ideal way to collect the bits, either that or make up two long structures.&amp;nbsp; Any sugguestions?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;P&gt;John&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 Jul 2011 13:13:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Demo-board-MC9S08DZ60-global-declarations/m-p/147865#M7557</guid>
      <dc:creator>Johnny_x</dc:creator>
      <dc:date>2011-07-09T13:13:47Z</dc:date>
    </item>
    <item>
      <title>Re: Demo board MC9S08DZ60, global declarations</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Demo-board-MC9S08DZ60-global-declarations/m-p/147866#M7558</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello John,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The usual way of handling the incoming serial data is to shift each bit value into a multiple byte array - in this case the array could be of byte type, with one nybble of each byte occupied, to represent the final form of the data.&amp;nbsp; Thus, the array size would be 13 bytes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With assembly code, the shifting through multiple bytes is simple because of direct access to the carry flag.&amp;nbsp; With C code, the process is somewhat more complex.&amp;nbsp; With the following untested code snippet, I have assumed that MSB of the data&amp;nbsp;is sent first, so that there is a left shift of each data bit into the last nybble of the array.&amp;nbsp; However, before this can be done, the rest of the array needs to be rotated left to make room for the new bit value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;byte array[13];     // Global array for 13 data nybbles (52 bits)byte bitcount = 52; // Value is decremented as each bit is received// Local variable:byte i;for (i = 0; i &amp;lt; 13; i++) {  // Commence with first nybble  array[i] &amp;lt;&amp;lt;= 1;           // Left shift nybble  array[i] &amp;amp;= 0x0F;         // Mask nybble value  if (i &amp;lt; 12) {             // Not last nybble    if (array[i+1] &amp;amp; 0x08)      array[i] |= 0x01;     // Carry bit from next nybble  }  else {                    // Last nybble of array    if (PTAD_PTAD0)         // Serial input data at PTA0 is assumed      array[12] |= 0x01;  }}bitcount--;                 // Decrement countif (bitcount == 0)          // Test for end of data sequence...&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Each element of the array should ultimately contain a value within the limits 0-15 decimal.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mac&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 08:49:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Demo-board-MC9S08DZ60-global-declarations/m-p/147866#M7558</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2020-10-29T08:49:24Z</dc:date>
    </item>
    <item>
      <title>Re: Demo board MC9S08DZ60, global declarations</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Demo-board-MC9S08DZ60-global-declarations/m-p/147867#M7559</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello John,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A more efficient version of the shift process than above, where room is made for the incoming data by shifting the next nybble to the previous nybble location within the array.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;byte array[13];     // Global array for 13 data nybbles (52 bits)byte bitcount = 52; // Value is decremented as each bit is received// Local variable:byte i;if ((bitcount &amp;amp; 0x03) == 0) {  for (i = 0; i &amp;lt; 12; i++)    array[i] = array[i+1];  // Transfer whole nybble  array[12] = 0x00;         // Ready for next serial data nybble}array[12] &amp;lt;&amp;lt;= 1;if (PTAD_PTAD0)  array[12] |= 0x01;bitcount--;                 // Decrement countif (bitcount == 0)          // Test for end of data sequence...&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mac&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 08:49:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Demo-board-MC9S08DZ60-global-declarations/m-p/147867#M7559</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2020-10-29T08:49:26Z</dc:date>
    </item>
    <item>
      <title>Re: Demo board MC9S08DZ60, global declarations</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Demo-board-MC9S08DZ60-global-declarations/m-p/147868#M7560</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In addition to Mac's suggestions, it is also possible to do it in hardware.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since your serial bit-stream is clocked, you could have the SPI programmed as a slave﻿ and feed it into the SPI. It would only work if:&lt;/P&gt;&lt;P&gt;1) your data was byte-aligned, and&lt;/P&gt;&lt;P&gt;2) it is shifting in MSB first.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since you are working with 4-bit data, you could efficiently manipulate it with the NSA instruction (nibble-swap accumulator).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;just a thought . . .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 10 Jul 2011 07:39:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Demo-board-MC9S08DZ60-global-declarations/m-p/147868#M7560</guid>
      <dc:creator>rocco</dc:creator>
      <dc:date>2011-07-10T07:39:01Z</dc:date>
    </item>
    <item>
      <title>Re: Demo board MC9S08DZ60, global declarations</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Demo-board-MC9S08DZ60-global-declarations/m-p/147869#M7561</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;rocco,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SPI in current Freescale MCUs is configureable MSB first or LSB first. Look for LSBFE bit in SPIC1 register. LSBFE is available at least in S08D.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 10 Jul 2011 12:46:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Demo-board-MC9S08DZ60-global-declarations/m-p/147869#M7561</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2011-07-10T12:46:45Z</dc:date>
    </item>
    <item>
      <title>Re: Demo board MC9S08DZ60, global declarations</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Demo-board-MC9S08DZ60-global-declarations/m-p/147870#M7562</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Kef.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I knew that was true on some SPI modules, so I looked at the block diagram "Figure 13-2. SPI System Connections﻿" on page 275, and saw only MSB first. But had I looked further to "Figure 13-3. SPI Module Block Diagram﻿" on page 277, I would have seen the LSBFE bit.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 10 Jul 2011 15:59:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Demo-board-MC9S08DZ60-global-declarations/m-p/147870#M7562</guid>
      <dc:creator>rocco</dc:creator>
      <dc:date>2011-07-10T15:59:28Z</dc:date>
    </item>
    <item>
      <title>Re: Demo board MC9S08DZ60, global declarations</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Demo-board-MC9S08DZ60-global-declarations/m-p/147871#M7563</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The OP seems to be considering 52 clock pulses, with an odd number of nybbles.&amp;nbsp; For SPI slave to work would require that the master generate 56 clock pulses, so that the final nybble can be read.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The high nybble in each byte would need to be extracted with -&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;hi_nybble = array[i] &amp;gt;&amp;gt; 4;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;Whether NSA instruction is used will depend on the compiler.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;Regards,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;Mac&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Jul 2011 05:10:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Demo-board-MC9S08DZ60-global-declarations/m-p/147871#M7563</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2011-07-11T05:10:56Z</dc:date>
    </item>
  </channel>
</rss>

