Cypress Perform

Home > Design Support > Cypress Developer CommunityTM > Cypress Forums > PSoC® 3 > DFF issue with SPI

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



DFF issue with SPI
Moderator:
RKRM

Post Reply
Follow this topic



DFF issue with SPI

MrLogic posted on 24 Apr 2013 4:39 AM PST
Member
5 Forum Posts

I made a simple circuit with a SPI master followed by a D-flip-flop. Please see attached image.

When I press a button the SPI will transmit the byte: 0xAA

I noticed that the DFF seems to latch the D input on the falling edge of the clock, which was not what I expected.

I've used DFF's often in PSoC design and they normally latch on the rising edge.

Please note I'm running at only 5 Hz SPI clock to be able watch the LEDs on the dev kit.

What's wrong here?

Regards, Tommy




Re: DFF issue with SPI

danaaknight posted on 24 Apr 2013 04:58 AM PST
Top Contributor
1773 Forum Posts

Scope not inverted on other 2 channels ?

 

Scope trigger setup properly ?

 

Setup and hold on D clk OK ?

 

No observable glitches on D clk ?

 

Just thinking outloud.....

 

Set scope up to trigger on runt on clock and input to see if you capture anything.

 

Regards, Dana.

 



Re: DFF issue with SPI

hli posted on 24 Apr 2013 05:31 AM PST
Top Contributor
675 Forum Posts

The DFF should really latch on rising edge. I would no doubt this, but look for other reasons. (Even when it would latch on rising edge, since SPI changes the data at the same moment, I would expect to see some glitches there). So the error is most likely somewhere else.

Do you get any warnings when compiling the project? How is SPI configured (mode 0)?



Re: DFF issue with SPI

MrLogic posted on 24 Apr 2013 05:58 AM PST
Member
5 Forum Posts

Dana:

Scope is not inverted on any channels.

Scope triggers on rising edge of SPI sclk ouput.

No glitches observed.

 

hli:

No serious warnings on compilation, just clock accuracy warnings.

SPI is configured CPHA=0 and CPOL=0

 

I agree with you that since the D input changes at the falling clock, it seems more like the DFF is latching on the rising edge of the clock as it should but waits for the next falling clock edge before it presents the value on Q.

 

Tommy



Re: DFF issue with SPI

hli posted on 24 Apr 2013 06:39 AM PST
Top Contributor
675 Forum Posts

But it is the output of the DFF which changes (or should change) with the rising edge - thats the whole point of the DFF...

I will try to replicate this issue this evening, maybe I see something. Until then you might want to remove the warning about the clock accuracy - just configure the clocks so you have a slower one available derived from a crystal or the IMO (e.g. derive the master clock from IMO which gives 3MHz, and then divide it by 16). Otherwise it selects the ILO as source, which not as accurate, and which is also not synchronized to the other internal clocks.



Re: DFF issue with SPI

hli posted on 24 Apr 2013 02:55 PM PST
Top Contributor
675 Forum Posts

OK, I tested it. Got the same behavior - even with a higher SPI clock derived from MASTER_CLK.

But I also have a solution for you: you need to sync the DFF clock input (I tested with syncing to BUS_CLK), the it works. See this result from the logic analyzer (the top is the SS signal used for triggering, then CLK, MOSI, and Q):

 

So there seems to be an issue with the DFF so that it needs a synchronized clock. Maybe you can open a support case.



Re: DFF issue with SPI

MrLogic posted on 24 Apr 2013 04:01 PM PST
Member
5 Forum Posts

hli:

Thanks a lot for your help and time. You're right. It works with a sync'ed clock.

It seems that DFF clock inputs are for system clocks only, or at least sync'ed signals.

Regards, Tommy



Re: DFF issue with SPI

hli posted on 25 Apr 2013 10:59 PM PST
Top Contributor
675 Forum Posts

The DFF data sheet says nothing about being usable only with system clocks. Its also implemented (and synthesized) directly via the MacroCells in the PLD blocks. So there shouldn't be a dependency on system clocks. I suspect you hit a buig with respect to how your schematic is synthesized - something in the combination between the SPI master component and the DFF might went wrong.






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