KSDK SPI Master-Slave with FRDM-K64F

cancel
Showing results for 
Search instead for 
Did you mean: 

KSDK SPI Master-Slave with FRDM-K64F

KSDK SPI Master-Slave with FRDM-K64F

Hi all Kinetis lovers,

 

Freescale has launched the Kinetis SDK and I believe this is a great opportunity for us to start our new applications using these drivers. The information contained on this post will show you how to use the SPI drivers based on simple master and slave examples.

 

The examples attached here were developed for KDS IDE using KSDK. To build and run the example you may need to consider the following:

  • Install KSDK: You need to have  KSDK v1.1.0 installed on your machine. You can find it HERE.
  • Build the KSDK library and import the examples: In the KSDK install folder go to the doc folder and look for the Getting Started with Kinetis SDK (KSDK) document. Follow the instructions of the section 5 Run a demo using Kinetis Design Studio IDE. To know how to build and import projects.


If you have further question you may find useful information in this posts:

 

I hope you can benefit from this post.

 

If you have questions please let me know

 

If this post was useful for you do not hesitate to click the Like button.

 

Best Regards,

Adrian Sanchez Cano

Technical Support Engineer

 


Labels (1)
Attachments
Comments

Hello Adrian,

Good sample. Would you have similar sample program but having SPI-Slave using the DMA transfer rather than just IRS?

Thanks

Hi Marcelo,

I do not have such example, but, the new KSDK 1.2 coming end of April includes those demos, one of them the DMA+SPI.

I recommend to wait the release and check the new examples. If you have further question please do not hesitate to post them.

Regards,

Adrian

Hello Adrian,


Great example,

I have a doubt about an application with SPI communication, needs to be transmitted in master mode, a byte and receive 4 bytes, so far I have not had many problems, however when I get the bytes so I have access to one of them. How do I access all received bytes.

thank you

Hi Paulo,

As you can see in the example the transmission API I am using looks like this:

dspi_status_t DSPI_DRV_SlaveTransferBlocking (  uint32_t instance,

                                                                                     const uint8_t   * sendBuffer,

                                                                                     uint8_t  * receiveBuffer,

                                                                                     uint32_t transferByteCount,

                                                                                     uint32_t timeout )

The parameter receiveBuffer is a pointer, you will use it to point to the Buffer you want to store your incoming data from the slave. Here an example:

//Buffer to store the incoming data

uint8_t spiSinkBuffer[10];  

//Bufer with the data to transfer

uint8_t spiSourceBuffer[10] = { 0x00, 0x01 , 0x02, 0x03 , 0x04 , 0x05 , 0x06, 0x07, 0x08, 0x09}

dspi_status_t Error = DSPI_DRV_SlaveTransferBlocking(HW_SPI0, &spiSourceBuffer[0], &spiSinkBuffer[0], 10,                                                                                           OSA_WAIT_FOREVER);

As you can see here I defined an array called spiSinkBuffer that I am passing as the receiveBuffer parameter and in the parameter trnasferByteCount I am setting the number of bytes to transmit an send

Once the returned value stores in Error is kStatus_DSPI_Success we can check the values of the received data, we can do something like this:

uint8_t value1 = spiSinkBuffer[0];

uint8_t value2 = spiSinkBuffer[1];

.

.

.

.

uint8_t value10 = spiSinkBuffer[9];

The spiSinkBuffer[10] has the received values.

I hope this information can help you.

Regards,

Adrian

Hello Adrian

How can I manipulate the configuration of the clock phase, for this example?

thank you

Hello Adrian,

About your comment "the new KSDK 1.2 coming end of April includes those demos, one of them the DMA+SPI.".

Is that new KSDK version coming today? Otherwise, when? Some progress in our project is being blocked by the lack of this SPI+DMA feature.

Thanks in advance,

Marcelo

Hi Marcelo,

Estimated release date for KDS_3.0.0 and KSDK_1.2.0 is April 37th (i.e. May 7th :smileyblush: ).

Regards,

David

Thanks a lot, David. Any chance I could get a release candidate?

My email: marcelo.varanda@skywave.com

Thanks,

Marcelo

Will see.

Back on Monday to reply.

Regards,

David

Thanks David. Is a KSKD RC available today? Half of my drivers are implemented for MQX 4.1.1 and the other half for KSDK 1.1

I must start merging them for a single version this week.

Freescale's help is appreciated. Thanks,

Marcelo

HI Adrian, this sample is very useful. However, I am using SDK3.0+KDSK1.2.0, 'configure_spi_pins' cannot be declared. Is there difference between KDSK1.1.0 and KDSK1.2.0? Which file 'configure_spi_pins' is included?

Many thanks!

Hi Everyone,

I tried to build this project, but unfortunately gave me make*** file error error_kds.jpg

that I could not solve, I'm not sure what is the problem,

can anyone help me with that?

hi Cano,

I'm also looking to use the DSPI_DRV_SlaveTransferBlocking api for K64F. However, what if I just wanted to transfer data and ignore the resulting recieve data on transfer. Can I set the receiveBuffer to NULL?

Regards,

Vergil

Version history
Revision #:
1 of 1
Last update:
‎03-03-2015 07:51 PM
Updated by: