SPI example code for K40 tower

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SPI example code for K40 tower

1,712 Views
edsonsanchez
Contributor I

Hi,

I am very new to the Kinetis MCU's. I am working with the K40 tower: Kinetis K40 Tower System Module|Freescale

I can't find a clear example on how to setup/drive the SPI pins on the MCU. I have downloaded CodeWarrior and am running it on Windows 8. Can someone point me in the right direction?

Thanks in advance for your time.

0 Kudos
3 Replies

542 Views
adriancano
NXP Employee
NXP Employee

Hi Edson.

In the attachments you can find a example project compiled with CodeWarrior 10.x for the TWR-K20. The project configures the SPI0 as Master and the SPI1 as slave, the master sends data that is received by the slave an after that just check if the data was correct. Please refer to the code for more information.

Note: there are some function that are used when SPI and DMA are used together.

I hope this information can help you.

Regards,

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Correct Answer button. It would be nice!

-----------------------------------------------------------------------------------------------------------------------

0 Kudos

542 Views
edsonsanchez
Contributor I

HI Adrian,

Thanks for the sample code you provided. I actually tried another approach to try and solve my problem. I found that code warrior comes with the processor expert UI that helps generate code for different applications. I went through a series of menus to setup the SPI pins, but now I am not sure as to how to send data out. In the generated code, there is a method called SM1_SendBlock() which I think can be used to send data out via the MOSI pin, but I am not sure how to use it. In the code that you attached to your reply, would you be able to point out where the master sends data? It might help me with the setup I've already got. Thanks again!

Edson

0 Kudos

542 Views
adriancano
NXP Employee
NXP Employee

Hi Edson,

In the installation folder of CodeWarrior 10.x you can find an example for the SPI module using Processor Expert in this path: <install_folder>\CW MCU v10.6\MCU\CodeWarrior_Examples\Processor_Expert\Kinetis\TWR-K40X256\SPI. In this example the SPI0 is configured as master and the SPI1 is configured as a slave. Take a look at this example, probably it will be useful for you.

I hope this information can help you.

Regards,

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Correct Answer button. It would be nice!

-----------------------------------------------------------------------------------------------------------------------

0 Kudos