Connecting an SPI device to WCD4

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

I am trying to hook up an SPI device but am confused about which SPI interface to use. I am using 3.1.2 SDK with the WCD4_EVB.

The only one defined in platform.h/c is SPI1, but this seems to be used by the flash driver. I found some forum discussions that seemed to suggest multiple SPI devices are not feasible as of now.

Can someone please help with the following questions?

1. If I use SPI1 (albeit with a different chip select pin than flash), will this work without any changes to the platform files?

2. Is there any other SPI interface I can use? I saw references to SPI3 in platform.h but nothing is defined in platform files

3. What exactly is the flash code used for? Does it even make sense for me to think of sacrificing flash support to get my SPI device working?

Thanks in advance!

0 Likes
1 Solution
Anonymous
Not applicable

Yes , eventhough you're using different CS pin, you might have to do that, Are SPI APIs thread safe ?

ie; locking & unlocking using a mutex, Since you're sharing a resource you must do that.

Also ,if you're using SPI1 for multiple peripherals, the SPI modes, Clock frequency  used by these modules will be different and you might have to init the SPI for each specific peripheral before doing it's corresponding SPI operation.

View solution in original post

0 Likes
4 Replies
Anonymous
Not applicable

Hi

In most of the platform files the SPI1 is used for extrenal FLASH connected to the MCU, but you can use the SPI1 for your device also, But  you should use a different CS  line, otherwise when you assert CS to 0 and communicate, both your slave & flash could give some data and you'll intrepret this as unexpecetd invalid data.


Can someone please help with the following questions?


1. If I use SPI1 (albeit with a different chip select pin than flash), will this work without any changes to the platform files?

A. You have to use a different CS line,(otherwise when you asser CS to 0 and communicate both your slave & flash could give some data and you'll intrepret this as invalid)


2. Is there any other SPI interface I can use? I saw references to SPI3 in platform.h but nothing is defined in platform files

A. You can use other SPI interface as well, but ensure that pins are available on your board. also you need to decalre/define them in the platform.c file.(take SPI1 as reference)

3 What exactly is the flash code used for? Does it even make sense for me to think of sacrificing flash support to get my SPI device working?

A. Flash code is used only if you need that external flash for some data storage, otherwise that is not required.

0 Likes
Anonymous
Not applicable

Thank you for your input!

If I use SPI1 with different CS, I am concerned that I will have to change the flash driver to protect against the reentrancy problem discussed in the following thread:

Are SPI APIs thread safe ?

Also, based on the above thread, I would have to use the same config across both flash and my SPI device.

I will look into defining a new SPI interface in the platform files, although it looks like I will have to think about the DMA streams and other config that I may safely use.

I am guessing I need the flash code for my WCD4_EVB because it stores some of the WiFi DCT stuff there.

So to summarize, it looks like my best option is to re-use SPI1 with different CS like you suggested.

Would you think the issues raised in the above thread are now resolved?

0 Likes
Anonymous
Not applicable

Yes , eventhough you're using different CS pin, you might have to do that, Are SPI APIs thread safe ?

ie; locking & unlocking using a mutex, Since you're sharing a resource you must do that.

Also ,if you're using SPI1 for multiple peripherals, the SPI modes, Clock frequency  used by these modules will be different and you might have to init the SPI for each specific peripheral before doing it's corresponding SPI operation.

0 Likes
Anonymous
Not applicable

Got it! That sounds like a simpler solution than turning off flash or defining SPI3.

Thanks again for your timely help! I will mark this as answered.