<?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 SPI interrupt MISO line K22 and FreeRTOS driver in Kinetis Software Development Kit</title>
    <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/SPI-interrupt-MISO-line-K22-and-FreeRTOS-driver/m-p/590598#M5987</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'musing FreeRTOS SPI diver with SDK 2.0 and I need a interrupt for MISO line.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;More in detail, I'm using AD7793 ADC and this chip have a feature that use the MISO line to indicatewhen a conversion is ready. Now, this is very useful for given the development I have in hand right now and I want to know how implement this interrupt using FreeRTOS and DSPI driver.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried configuring the MISO pin as input with interrupt but is not working.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the configuration for my normal SPI:&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class="c++" name="code"&gt;void SetSPIConfig() { &amp;nbsp; dspi_master_config_t masterConfig; &amp;nbsp; uint32_t sourceClock; &amp;nbsp; status_t status; &amp;nbsp; /*Master config*/ &amp;nbsp; masterConfig.whichCtar = kDSPI_Ctar0; &amp;nbsp; masterConfig.ctarConfig.baudRate = TRANSFER_BAUDRATE; &amp;nbsp; masterConfig.ctarConfig.bitsPerFrame = 8; &amp;nbsp; masterConfig.ctarConfig.cpol = kDSPI_ClockPolarityActiveLow; &amp;nbsp; masterConfig.ctarConfig.cpha = kDSPI_ClockPhaseSecondEdge; &amp;nbsp; masterConfig.ctarConfig.direction = kDSPI_MsbFirst; &amp;nbsp; masterConfig.ctarConfig.pcsToSckDelayInNanoSec = 2000; &amp;nbsp; masterConfig.ctarConfig.lastSckToPcsDelayInNanoSec = 2000; &amp;nbsp; masterConfig.ctarConfig.betweenTransferDelayInNanoSec = 1000;&amp;nbsp;&amp;nbsp; &amp;nbsp; masterConfig.whichPcs = kDSPI_Pcs1; &amp;nbsp; masterConfig.pcsActiveHighOrLow = kDSPI_PcsActiveLow;&amp;nbsp;&amp;nbsp; &amp;nbsp; masterConfig.enableContinuousSCK = false; &amp;nbsp; masterConfig.enableRxFifoOverWrite = false; &amp;nbsp; masterConfig.enableModifiedTimingFormat = false; &amp;nbsp; masterConfig.samplePoint = kDSPI_SckToSin0Clock;&amp;nbsp;&amp;nbsp; &amp;nbsp; NVIC_SetPriority(SPI0_IRQn, 6);&amp;nbsp;&amp;nbsp; &amp;nbsp; sourceClock = CLOCK_GetFreq(DSPI_MASTER_CLK_SRC); &amp;nbsp; status = DSPI_RTOS_Init(&amp;amp;master_rtos_handle, DSPI_MASTER_BASEADDR, &amp;amp;masterConfig, sourceClock);&amp;nbsp;&amp;nbsp; &amp;nbsp; if (status != kStatus_Success) &amp;nbsp; { &amp;nbsp; PRINTF("DSPI master: error during initialization. \r\n"); &amp;nbsp; //vTaskSuspend(NULL); &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; &lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and the functions to eanble pin interrupt&lt;/P&gt;&lt;PRE class="c++" name="code"&gt;void EnableSPIDataInInterrupt(void) { &amp;nbsp; DSPI_RTOS_Deinit(&amp;amp;master_rtos_handle); &amp;nbsp; gpio_pin_config_t pin_config; &amp;nbsp; pin_config.pinDirection = kGPIO_DigitalInput; &amp;nbsp; PORT_SetPinMux( PORTD, &amp;nbsp; 3U, &amp;nbsp; kPORT_MuxAsGpio);&amp;nbsp;&amp;nbsp; &amp;nbsp; PORT_SetPinInterruptConfig(PORTD,3U, kPORT_InterruptRisingEdge); &amp;nbsp; EnableIRQ(PORTD_IRQn); &amp;nbsp; NVIC_SetPriority(PORTD_IRQn, 6); &amp;nbsp; GPIO_PinInit(GPIOD,3U,&amp;amp;pin_config); &amp;nbsp; //PORT_SetPinMux(PORTD, 3U, kPORT_MuxAlt2); // pin 60 , PTD3, SPI0_SIN, alt2, MISO }&amp;nbsp;&amp;nbsp; &lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, once I have the interrupt I release a semaphore that reconfigure the pin as SPI MISO and read the data in AD7793 and back to configure the pin as simple input interrupt with a semaphore lock.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If there is a more fancy or proper way to do this please let me know.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;JP&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 19 Jul 2016 22:26:12 GMT</pubDate>
    <dc:creator>jpcordovae</dc:creator>
    <dc:date>2016-07-19T22:26:12Z</dc:date>
    <item>
      <title>SPI interrupt MISO line K22 and FreeRTOS driver</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/SPI-interrupt-MISO-line-K22-and-FreeRTOS-driver/m-p/590598#M5987</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'musing FreeRTOS SPI diver with SDK 2.0 and I need a interrupt for MISO line.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;More in detail, I'm using AD7793 ADC and this chip have a feature that use the MISO line to indicatewhen a conversion is ready. Now, this is very useful for given the development I have in hand right now and I want to know how implement this interrupt using FreeRTOS and DSPI driver.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried configuring the MISO pin as input with interrupt but is not working.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the configuration for my normal SPI:&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class="c++" name="code"&gt;void SetSPIConfig() { &amp;nbsp; dspi_master_config_t masterConfig; &amp;nbsp; uint32_t sourceClock; &amp;nbsp; status_t status; &amp;nbsp; /*Master config*/ &amp;nbsp; masterConfig.whichCtar = kDSPI_Ctar0; &amp;nbsp; masterConfig.ctarConfig.baudRate = TRANSFER_BAUDRATE; &amp;nbsp; masterConfig.ctarConfig.bitsPerFrame = 8; &amp;nbsp; masterConfig.ctarConfig.cpol = kDSPI_ClockPolarityActiveLow; &amp;nbsp; masterConfig.ctarConfig.cpha = kDSPI_ClockPhaseSecondEdge; &amp;nbsp; masterConfig.ctarConfig.direction = kDSPI_MsbFirst; &amp;nbsp; masterConfig.ctarConfig.pcsToSckDelayInNanoSec = 2000; &amp;nbsp; masterConfig.ctarConfig.lastSckToPcsDelayInNanoSec = 2000; &amp;nbsp; masterConfig.ctarConfig.betweenTransferDelayInNanoSec = 1000;&amp;nbsp;&amp;nbsp; &amp;nbsp; masterConfig.whichPcs = kDSPI_Pcs1; &amp;nbsp; masterConfig.pcsActiveHighOrLow = kDSPI_PcsActiveLow;&amp;nbsp;&amp;nbsp; &amp;nbsp; masterConfig.enableContinuousSCK = false; &amp;nbsp; masterConfig.enableRxFifoOverWrite = false; &amp;nbsp; masterConfig.enableModifiedTimingFormat = false; &amp;nbsp; masterConfig.samplePoint = kDSPI_SckToSin0Clock;&amp;nbsp;&amp;nbsp; &amp;nbsp; NVIC_SetPriority(SPI0_IRQn, 6);&amp;nbsp;&amp;nbsp; &amp;nbsp; sourceClock = CLOCK_GetFreq(DSPI_MASTER_CLK_SRC); &amp;nbsp; status = DSPI_RTOS_Init(&amp;amp;master_rtos_handle, DSPI_MASTER_BASEADDR, &amp;amp;masterConfig, sourceClock);&amp;nbsp;&amp;nbsp; &amp;nbsp; if (status != kStatus_Success) &amp;nbsp; { &amp;nbsp; PRINTF("DSPI master: error during initialization. \r\n"); &amp;nbsp; //vTaskSuspend(NULL); &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; &lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and the functions to eanble pin interrupt&lt;/P&gt;&lt;PRE class="c++" name="code"&gt;void EnableSPIDataInInterrupt(void) { &amp;nbsp; DSPI_RTOS_Deinit(&amp;amp;master_rtos_handle); &amp;nbsp; gpio_pin_config_t pin_config; &amp;nbsp; pin_config.pinDirection = kGPIO_DigitalInput; &amp;nbsp; PORT_SetPinMux( PORTD, &amp;nbsp; 3U, &amp;nbsp; kPORT_MuxAsGpio);&amp;nbsp;&amp;nbsp; &amp;nbsp; PORT_SetPinInterruptConfig(PORTD,3U, kPORT_InterruptRisingEdge); &amp;nbsp; EnableIRQ(PORTD_IRQn); &amp;nbsp; NVIC_SetPriority(PORTD_IRQn, 6); &amp;nbsp; GPIO_PinInit(GPIOD,3U,&amp;amp;pin_config); &amp;nbsp; //PORT_SetPinMux(PORTD, 3U, kPORT_MuxAlt2); // pin 60 , PTD3, SPI0_SIN, alt2, MISO }&amp;nbsp;&amp;nbsp; &lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, once I have the interrupt I release a semaphore that reconfigure the pin as SPI MISO and read the data in AD7793 and back to configure the pin as simple input interrupt with a semaphore lock.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If there is a more fancy or proper way to do this please let me know.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;JP&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Jul 2016 22:26:12 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/SPI-interrupt-MISO-line-K22-and-FreeRTOS-driver/m-p/590598#M5987</guid>
      <dc:creator>jpcordovae</dc:creator>
      <dc:date>2016-07-19T22:26:12Z</dc:date>
    </item>
    <item>
      <title>Re: SPI interrupt MISO line K22 and FreeRTOS driver</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/SPI-interrupt-MISO-line-K22-and-FreeRTOS-driver/m-p/590599#M5988</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,Juan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is my opinion, I have checked the data sheet of AD7793, the MOSI pin is multiplexed with DOUT data function and RDY flag, if we can decouple the function MOSI and RDY Flag from hardware perspective, it is okay. I think you can use a latch for example 74LS373, connect the DOUT/RDY to Dx pin of the latch, connect the CS pin of SPI to LE(lock enable), connect the /EN of latch to GND, you can connect the Qx pin of latch to an GPIO pin of K22, in this way, the Qx pin is the only RDY signal. When the CS is low, the SPI will receive the bit stream, while the Qx pin is latched High , when the transfer is over, the CS is high, the Qx will have the same waveform as that of Dx pin, in this way, the Qx pin can separate the flag state and generate interrupt if you can connect the Qx pin to GPIO.&lt;/P&gt;&lt;P&gt;Pls have a try, this is my opinion, I never test it, can not confirm if it is okay or not.&lt;/P&gt;&lt;P&gt;BR&lt;/P&gt;&lt;P&gt;XiangJun Rong&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jul 2016 02:43:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/SPI-interrupt-MISO-line-K22-and-FreeRTOS-driver/m-p/590599#M5988</guid>
      <dc:creator>xiangjun_rong</dc:creator>
      <dc:date>2016-07-20T02:43:15Z</dc:date>
    </item>
    <item>
      <title>Re: SPI interrupt MISO line K22 and FreeRTOS driver</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/SPI-interrupt-MISO-line-K22-and-FreeRTOS-driver/m-p/590600#M5989</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I can't comment on the hardware set up, but as far as triggering a FreeRTOS task from an interrupt is concerned, you would be better off using a direct to task notification rather than a semaphore.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If it is always the same task that receives the notification then you can simply store the task's handle in a variable, and have the ISR send the notification to that task.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If it is not known in advance which task will receive the notification, because more than one task is using the peripheral, then you can use code similar to the example provided on the following page: &lt;A href="http://www.freertos.org/vTaskNotifyGiveFromISR.html" title="http://www.freertos.org/vTaskNotifyGiveFromISR.html"&gt;http://www.freertos.org/vTaskNotifyGiveFromISR.html&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jul 2016 10:04:12 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/SPI-interrupt-MISO-line-K22-and-FreeRTOS-driver/m-p/590600#M5989</guid>
      <dc:creator>FreeRTOS_org</dc:creator>
      <dc:date>2016-07-20T10:04:12Z</dc:date>
    </item>
    <item>
      <title>Re: SPI interrupt MISO line K22 and FreeRTOS driver</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/SPI-interrupt-MISO-line-K22-and-FreeRTOS-driver/m-p/590601#M5990</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;XiangJun ,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;I put a diode to another pint to trigger a read on SPI interface, I'll enable and disable that interrupt, is should be fast enough as I understand is a register bit modification. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;I'll let you know if it works.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;JP&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jul 2016 13:40:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/SPI-interrupt-MISO-line-K22-and-FreeRTOS-driver/m-p/590601#M5990</guid>
      <dc:creator>jpcordovae</dc:creator>
      <dc:date>2016-07-20T13:40:15Z</dc:date>
    </item>
    <item>
      <title>Re: SPI interrupt MISO line K22 and FreeRTOS driver</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/SPI-interrupt-MISO-line-K22-and-FreeRTOS-driver/m-p/590602#M5991</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Richard,&lt;/P&gt;&lt;P&gt;You are right, the correct approach is through your example, you save me at least few days of try/fail/search work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TY&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;JP&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jul 2016 13:44:37 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/SPI-interrupt-MISO-line-K22-and-FreeRTOS-driver/m-p/590602#M5991</guid>
      <dc:creator>jpcordovae</dc:creator>
      <dc:date>2016-07-20T13:44:37Z</dc:date>
    </item>
  </channel>
</rss>

