<?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>Kinetis MicrocontrollersのトピックRe: MK20D classic SPI example??</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MK20D-classic-SPI-example/m-p/1174905#M58657</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;You configure the PTD4 as CS. So you can't configure&amp;nbsp;PDDR and PSOR except you configure the pin as gpio. You can download the sample in&amp;nbsp;&lt;A href="https://mcuxpresso.nxp.com/en/select" target="_blank"&gt;https://mcuxpresso.nxp.com/en/select&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;K20 has same content as k60. So k20 uses k60's sample. You can refer it.&lt;/P&gt;
&lt;P&gt;Have a great day,&lt;BR /&gt;TIC&lt;/P&gt;
&lt;P&gt;-------------------------------------------------------------------------------&lt;BR /&gt;Note:&lt;BR /&gt;- If this post answers your question, please click the "Mark Correct" button. Thank you!&lt;/P&gt;
&lt;P&gt;- We are following threads for 7 days after the last post, later replies are ignored&lt;BR /&gt;Please open a new thread and refer to the closed one, if you have a related question at a later point in time.&lt;BR /&gt;-------------------------------------------------------------------------------&lt;/P&gt;</description>
    <pubDate>Thu, 29 Oct 2020 00:57:43 GMT</pubDate>
    <dc:creator>nxf56274</dc:creator>
    <dc:date>2020-10-29T00:57:43Z</dc:date>
    <item>
      <title>MK20D classic SPI example??</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MK20D-classic-SPI-example/m-p/1174818#M58655</link>
      <description>&lt;P&gt;trying to get the SPI work on K20 in order to access a flash memory.&lt;/P&gt;&lt;P&gt;I have checked on the scope that the SCLK did toggle during a byte send but the CS always held low.&lt;/P&gt;&lt;P&gt;And idea why the CS not toggling?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any sample program that shows how to setup the SPI on K20?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/*******************************************************************************&lt;BR /&gt;* scSSP0Init - Initialize SSP0 module( we are using SSP0 module in SPI frame format&lt;BR /&gt;*******************************************************************************/&lt;BR /&gt;void scSSP0Init(void)&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;SIM_SCGC5 |= SIM_SCGC5_PORTD_MASK; //Enable PORTD&lt;BR /&gt;SIM_SCGC6 |= SIM_SCGC6_DSPI0_MASK; //Turn on clock to SPI0 module&lt;BR /&gt;/* configure GPIO for SPI0 function */&lt;BR /&gt;PORTD_PCR1 = PORT_PCR_MUX(2); //SPI0_CLK&lt;BR /&gt;PORTD_PCR2 = PORT_PCR_MUX(2); //SPI0_SO&lt;BR /&gt;PORTD_PCR3 = PORT_PCR_MUX(2); //SPI0_SI&lt;BR /&gt;PORTD_PCR4 = PORT_PCR_MUX(2); //SPI0_CS1&lt;BR /&gt;GPIOD_PDDR |= (1&amp;lt;&amp;lt;SPI_DFLASH_CS_PIN); //Set PTD4 as output&lt;BR /&gt;GPIOD_PSOR |= (1&amp;lt;&amp;lt;SPI_DFLASH_CS_PIN); //Set High iniitializlly&lt;/P&gt;&lt;P&gt;SPI0_MCR |= SPI_MCR_MDIS_MASK | SPI_MCR_HALT_MASK; // Allows external logic to disable DSPI clock, halt DSPI transfer&lt;BR /&gt;//SPI0_MCR |= SPI_MCR_DIS_TXF_MASK | SPI_MCR_DIS_RXF_MASK; // Disable RX and TX DSPIFIFO as simplified double buffered SPI&lt;BR /&gt;SPI0_CTAR0 = 0x38010008; //8 bit per frame, 50/50 duty, BR scaler = 256, BR div = 3, ~130kbps&lt;BR /&gt;SPI0_MCR |= SPI_MCR_MSTR_MASK; //Master mmode&lt;BR /&gt;//SPI0_TCR = (uint32_t)0x00UL; //Clear transfer count&lt;BR /&gt;// SPI0_RSER = (uint32_t)0x00UL; //Disable Interrupt and DMA&lt;BR /&gt;//SPI0_SR = SPI_SR_EOQF_MASK | SPI_SR_TCF_MASK | SPI_SR_RFOF_MASK | SPI_SR_TFUF_MASK | SPI_SR_TFFF_MASK | SPI_SR_RFDF_MASK; //Clear Status Register&lt;BR /&gt;SPI0_MCR &amp;amp;= ~(SPI_MCR_MDIS_MASK | SPI_MCR_HALT_MASK); // Enable DSPI clock, start DSPI transfer&lt;BR /&gt;//SPI0_MCR |= SPI_MCR_DIS_TXF_MASK | SPI_MCR_DIS_RXF_MASK; // Disable RX and TX DSPIFIFO as simplified double buffered SPI&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/*******************************************************************************&lt;BR /&gt;* SPI Receive Byte, receive one byte only, returns Data byte&lt;BR /&gt;*******************************************************************************/&lt;BR /&gt;unsigned char SSP0ReceiveByte( void )&lt;BR /&gt;{&lt;BR /&gt;unsigned char rxData= 0xff;&lt;BR /&gt;SPI0_SR |= SPI_SR_TCF_MASK; //clear transfer&lt;BR /&gt;//SPI0_PUSHR = 0xFF;&lt;BR /&gt;// Wait until the Busy bit is cleared&lt;BR /&gt;if (!SSP0WaitReady())&lt;BR /&gt;{&lt;BR /&gt;return rxData;&lt;BR /&gt;}&lt;BR /&gt;rxData = SPI0_POPR;&lt;BR /&gt;return rxData;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/*******************************************************************************&lt;BR /&gt;* SSP0 SendByte, send one byte to EEPROM&lt;BR /&gt;*******************************************************************************/&lt;BR /&gt;void SSP0SendByte(unsigned char SP0Byte)&lt;BR /&gt;{&lt;BR /&gt;SPI0_SR |= SPI_SR_TCF_MASK; //clear transfer&lt;BR /&gt;SPI0_PUSHR = SP0Byte; //PUSH TX FIFO&lt;BR /&gt;// Wait until the Busy bit is cleared&lt;BR /&gt;if (!SSP0WaitReady())&lt;BR /&gt;{&lt;BR /&gt;return;&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;</description>
      <pubDate>Wed, 28 Oct 2020 22:27:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MK20D-classic-SPI-example/m-p/1174818#M58655</guid>
      <dc:creator>terence_kong</dc:creator>
      <dc:date>2020-10-28T22:27:19Z</dc:date>
    </item>
    <item>
      <title>Re: MK20D classic SPI example??</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MK20D-classic-SPI-example/m-p/1174905#M58657</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;You configure the PTD4 as CS. So you can't configure&amp;nbsp;PDDR and PSOR except you configure the pin as gpio. You can download the sample in&amp;nbsp;&lt;A href="https://mcuxpresso.nxp.com/en/select" target="_blank"&gt;https://mcuxpresso.nxp.com/en/select&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;K20 has same content as k60. So k20 uses k60's sample. You can refer it.&lt;/P&gt;
&lt;P&gt;Have a great day,&lt;BR /&gt;TIC&lt;/P&gt;
&lt;P&gt;-------------------------------------------------------------------------------&lt;BR /&gt;Note:&lt;BR /&gt;- If this post answers your question, please click the "Mark Correct" button. Thank you!&lt;/P&gt;
&lt;P&gt;- We are following threads for 7 days after the last post, later replies are ignored&lt;BR /&gt;Please open a new thread and refer to the closed one, if you have a related question at a later point in time.&lt;BR /&gt;-------------------------------------------------------------------------------&lt;/P&gt;</description>
      <pubDate>Thu, 29 Oct 2020 00:57:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MK20D-classic-SPI-example/m-p/1174905#M58657</guid>
      <dc:creator>nxf56274</dc:creator>
      <dc:date>2020-10-29T00:57:43Z</dc:date>
    </item>
  </channel>
</rss>

