Cypress Perform

Home > Design Support > Cypress Developer CommunityTM > Cypress Forums > PSoC® 3 > Problem with SPI in bidirectional mode

Bookmark and Share
Cypress Developer CommunityTM
Forums | Videos | Blogs | Training | Rewards Program | Community Components



Problem with SPI in bidirectional mode
Moderator:
RKRM

Post Reply
Follow this topic



Problem with SPI in bidirectional mode

qihuixu posted on 27 Apr 2012 12:50 PM PST
Member
3 Forum Posts

I am trying to use the SPI Master block in bidirectional mode (only one sdat pin instead of MOSI and MISO). I can't seem to get a read signal. Is there anything specific I need to do in the programming or in the TopDesign differently from the MOSI/MISO mode? How should I be using TxEnable/TxDisable methods?




Re: Problem with SPI in bidirectional mode

Bob Marlowe posted on 27 Apr 2012 01:47 PM PST
Top Contributor
1768 Forum Posts

When reading from SPI you have to call SPIM_TxDisable() before, when wanting to transmit call SPIM_TxEnable().

Not working communication is mostly caused by different clock / mode, check that twice.

 

Bob



Re: Problem with SPI in bidirectional mode

qihuixu posted on 02 May 2012 01:43 PM PST
Member
3 Forum Posts

Thank you for your response.

I have been using TxEnable/TxDisable before and after reading and writing. I measured the clock cycle on the oscilloscope and it was at the correct frequency required for our application. The mode also seems to be correct. However, is there anything else on the sdata pin that I need to change (like open drain/strong drive etc.)? Also, should I clear the buffer upon every read and write? And I discovered that CheckBufferSize() seems to take the data from the buffer. How does that function?



Re: Problem with SPI in bidirectional mode

Bob Marlowe posted on 02 May 2012 01:55 PM PST
Top Contributor
1768 Forum Posts

Can you post your project here so that we can have a look at? Maybe there is something not as you want it.

To do so, select Build->clean project

File->create workspace bundle(minimal)

Then upload the compressed file here.

 

Bob

 

 



Re: Problem with SPI in bidirectional mode

qihuixu posted on 02 May 2012 03:36 PM PST
Member
3 Forum Posts

 I have attached the zip file. Thank you.



Re: Problem with SPI in bidirectional mode

kmmankad posted on 03 May 2012 08:39 PM PST
Top Contributor
268 Forum Posts

A couple of things,

1.Get the latest PSoC Creator

2. I noticed you have connected the Chip Select pin to your SPI module directly.

I think thats the issue.You see,that is one devious chip select on the SPI module.The problem is,the SPI master toggles this around sending and getting a byte.when ideally,it should be toggled around a transaction.

Solution?

Toggle the CS manually,around an entire transaction.

AccSPI_CS_Write(0);

//Send SPI command to accelo

//Get some funky data back

AccSPI_CS_Write(1);

I guess that should do it.



Re: Problem with SPI in bidirectional mode

kmmankad posted on 03 May 2012 08:47 PM PST
Top Contributor
268 Forum Posts

i.e it should look like this-->

Note that Reset should be connected to 0..(but oddly enough even the example project in the recent edition of creator doesnt..)

 






ALL CONTENT AND MATERIALS ON THIS SITE ARE PROVIDED "AS IS". CYPRESS SEMICONDUCTOR AND ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY OF THESE MATERIALS FOR ANY PURPOSE AND DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THESE MATERIALS, INCLUDING BUT NOT LIMITED TO, ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL PROPERTY RIGHT. NO LICENSE, EITHER EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, IS GRANTED BY CYPRESS SEMICONDUCTOR. USE OF THE INFORMATION ON THIS SITE MAY REQUIRE A LICENSE FROM A THIRD PARTY, OR A LICENSE FROM CYPRESS SEMICONDUCTOR.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms and Conditions of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms and Conditions of this site. Cypress Semiconductor and its suppliers reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Spec No: None; Sunset Owner: GRAA; Secondary Owner: RAIK; Sunset Date: 01/01/20