<?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 K10 Spi read buffer bit inverted in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K10-Spi-read-buffer-bit-inverted/m-p/247282#M6663</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, I'm using a K10 as SPI master. I've some problem with rx buffer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to read data from MAX31855: data are storage, but MSB&amp;nbsp; has been saved in bit 0 of rx_buffer. Do someone explain me why?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My code is the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* Initialization SPI */&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;SIM_SCGC6 |= SIM_SCGC6_SPI0_MASK;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;SPI_MCR_REG(regmap) = SPI_MCR_MSTR_MASK | &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;SPI_MCR_CONT_SCKE_MASK | &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;SPI_MCR_PCSIS(0xF) | &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;SPI_MCR_HALT_MASK;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SPI_CTAR_REG(regmap,0) = SPI_CTAR_FMSZ(0x7) | SPI_CTAR_BR(0x05) | SPI_CTAR_CPHA_MASK | ~SPI_CTAR_CPOL_MASK;&lt;/P&gt;&lt;P&gt;SPI_CTAR_REG(regmap,1) = SPI_CTAR_FMSZ(0x7) | SPI_CTAR_BR(0x05) | SPI_CTAR_CPHA_MASK | ~SPI_CTAR_CPOL_MASK;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* Main */&lt;/P&gt;&lt;P&gt;while((SPI_SR_REG(regmap)&amp;nbsp; &amp;amp; SPI_SR_TFFF_MASK) != 0x2000000U);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; // Transmit Byte on SPI &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;SPI_MCR_REG(regmap) &amp;amp;= ~SPI_MCR_HALT_MASK;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;SPI_PUSHR_REG(regmap) |= 0xFFFF;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//--&amp;gt; Wait till transmit complete&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;while (((SPI_SR_REG(regmap) &amp;amp; SPI_SR_TCF_MASK)) != SPI_SR_TCF_MASK);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//--&amp;gt; Clear Transmit Flag.&lt;/P&gt;&lt;P&gt;SPI_SR_REG(regmap) |= SPI_SR_TFFF_MASK;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;data = SPI_POPR_RXDATA(regmap);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another problem that I have is that I want to send a 8bit per time, but it send and receive 16bit per time. Why? I have setted SPI_CTAR_FMSZ(0x7), but when I stop in debug mode, I read 0xF in FMSZ! &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you help me?&lt;/P&gt;&lt;P&gt;Nicola&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 20 Feb 2014 08:39:17 GMT</pubDate>
    <dc:creator>nicola90</dc:creator>
    <dc:date>2014-02-20T08:39:17Z</dc:date>
    <item>
      <title>K10 Spi read buffer bit inverted</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K10-Spi-read-buffer-bit-inverted/m-p/247282#M6663</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, I'm using a K10 as SPI master. I've some problem with rx buffer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to read data from MAX31855: data are storage, but MSB&amp;nbsp; has been saved in bit 0 of rx_buffer. Do someone explain me why?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My code is the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* Initialization SPI */&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;SIM_SCGC6 |= SIM_SCGC6_SPI0_MASK;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;SPI_MCR_REG(regmap) = SPI_MCR_MSTR_MASK | &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;SPI_MCR_CONT_SCKE_MASK | &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;SPI_MCR_PCSIS(0xF) | &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;SPI_MCR_HALT_MASK;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SPI_CTAR_REG(regmap,0) = SPI_CTAR_FMSZ(0x7) | SPI_CTAR_BR(0x05) | SPI_CTAR_CPHA_MASK | ~SPI_CTAR_CPOL_MASK;&lt;/P&gt;&lt;P&gt;SPI_CTAR_REG(regmap,1) = SPI_CTAR_FMSZ(0x7) | SPI_CTAR_BR(0x05) | SPI_CTAR_CPHA_MASK | ~SPI_CTAR_CPOL_MASK;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* Main */&lt;/P&gt;&lt;P&gt;while((SPI_SR_REG(regmap)&amp;nbsp; &amp;amp; SPI_SR_TFFF_MASK) != 0x2000000U);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; // Transmit Byte on SPI &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;SPI_MCR_REG(regmap) &amp;amp;= ~SPI_MCR_HALT_MASK;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;SPI_PUSHR_REG(regmap) |= 0xFFFF;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//--&amp;gt; Wait till transmit complete&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;while (((SPI_SR_REG(regmap) &amp;amp; SPI_SR_TCF_MASK)) != SPI_SR_TCF_MASK);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//--&amp;gt; Clear Transmit Flag.&lt;/P&gt;&lt;P&gt;SPI_SR_REG(regmap) |= SPI_SR_TFFF_MASK;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;data = SPI_POPR_RXDATA(regmap);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another problem that I have is that I want to send a 8bit per time, but it send and receive 16bit per time. Why? I have setted SPI_CTAR_FMSZ(0x7), but when I stop in debug mode, I read 0xF in FMSZ! &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you help me?&lt;/P&gt;&lt;P&gt;Nicola&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Feb 2014 08:39:17 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K10-Spi-read-buffer-bit-inverted/m-p/247282#M6663</guid>
      <dc:creator>nicola90</dc:creator>
      <dc:date>2014-02-20T08:39:17Z</dc:date>
    </item>
    <item>
      <title>Re: K10 Spi read buffer bit inverted</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K10-Spi-read-buffer-bit-inverted/m-p/247283#M6664</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Nicola,&lt;/P&gt;&lt;P&gt;I've had a brief through your code and I think your cod is not very right.&lt;/P&gt;&lt;P&gt;For instance, your code didn't select the CTAR0 or CTAR1 for clock and transfer attribute if use &lt;SPAN style="font-size: 10pt;"&gt;SPI_PUSHR_REG(regmap) |= 0xFFFF;&lt;BR /&gt;&lt;/SPAN&gt;You also can't send a 8bit per time prorperly with this code.&lt;/P&gt;&lt;P&gt;So I've like to suggest a demo code about K60 connect with a exteranl flash chip through SPI interface.&lt;/P&gt;&lt;P&gt;I think it should be useful for reference and I've attached the file with the reply. Please refer to it for details.&lt;/P&gt;&lt;P&gt;Wish it help.&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Ping&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Feb 2014 07:30:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K10-Spi-read-buffer-bit-inverted/m-p/247283#M6664</guid>
      <dc:creator>jeremyzhou</dc:creator>
      <dc:date>2014-02-24T07:30:52Z</dc:date>
    </item>
  </channel>
</rss>

