SPI Properties

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

Post Reply
MarkW
Flowcode v5 User
Posts: 118
Joined: Thu Sep 17, 2009 1:30 pm
Has thanked: 3 times
Been thanked: 11 times
Contact:

SPI Properties

Post by MarkW »

How can one change the SPI timing property that deals
with the "sample point" setting?

Currently, there are only two options: sample at END or MIDDLE

The device i am using ADXL345 accelerometer calls for sampling the
data at the trailing edge of the clock...

You can edit the properties of the sample point and it lists the options
as follows:

000 Middle
001 End

How does one define a third property such as trailing edge sampling?

From the ADXL345 datasheet...quote:
"Data is updated on the falling edge of SCLK and should be sampled on the rising edge of SCLK."


Thanx

Mark

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: SPI Properties

Post by Benj »

Hi Mark,

I think that the "Trailing Edge" is equivalent to "Sample At End".

MarkW
Flowcode v5 User
Posts: 118
Joined: Thu Sep 17, 2009 1:30 pm
Has thanked: 3 times
Been thanked: 11 times
Contact:

Re: SPI Properties

Post by MarkW »

Hi Ben,

I think you are referring to the clock phase....but i need to change
sample point.
The only options are middle or end for sample point, but i need
to have a 3rd option which is a "begin" or rising edge of clock, of which there is
no option....

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: SPI Properties

Post by kersing »

Mark,

Flowcode setting 'Sample Point' set to 'End' is equivalent to what you called 'trailing edge' in your first message. From the description you also need 'Clock Polarity' set to 'Idle High' and "Clock Phase" set to "Trailing Edge".

Best regards,

Jac
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

MarkW
Flowcode v5 User
Posts: 118
Joined: Thu Sep 17, 2009 1:30 pm
Has thanked: 3 times
Been thanked: 11 times
Contact:

Re: SPI Properties

Post by MarkW »

Hi Jac,

Hmmm, no i think everyone is not reading my messages
properly...

I am referring to the sample point...it needs a setting of "begin"
or in other words "rising edge" ...of the clock signal

This involves a SPI read operation, when the data is SAMPLED

Currently, the only settings for sample point are "middle" and "end"
of the clock signal....i need a setting that will be for better words
a "begin" or "rising edge"...this would be a 3rd option setting but
does not exist

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: SPI Properties

Post by kersing »

Mark,

I even took the trouble of reading the original data sheet.

The clock for your device is idle high, the sample needs to be taken when the clock goes from low to high, the rising edge of the clock signal, that means in the middle of a clock cycle, not at the start.

EDIT: sample should be taken in the middle of the cycle, not at the end. My mistake. Check Wikipedia the diagram at the right show the correct waveform for CPOL=1 and CPHA=1 (sample at blue line) (this can be found in the data sheet at page 15). For PIC this translates to CKP=1, SMP=0 and CKE=0. In Flowcode these settings are: Clock Polarity = Idle High, Clock Phase = Leading Edge and Sample Point = Middle.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

MarkW
Flowcode v5 User
Posts: 118
Joined: Thu Sep 17, 2009 1:30 pm
Has thanked: 3 times
Been thanked: 11 times
Contact:

Re: SPI Properties

Post by MarkW »

Hi Jac (Kersing),

That worked! Thank you very much....it seems it is sometimes bit
difficult to interpret the waveforms correctly and as such i will
need to study these setting more intently in future
And thank you for taking the time and effort to look at the datasheet
etc...

Many thanx

Mark

Post Reply