cancel
Showing results for 
Search instead for 
Did you mean: 

timing problems with port

juergen239955
Associate II
Posted on September 14, 2004 at 12:27

timing problems with port

5 REPLIES 5
juergen239955
Associate II
Posted on September 02, 2004 at 05:07

Hi,

I have following problem:

I use the ST10F269 and I want to send and receive data via the SSC to a flash. For this I use for example following function:

int readStatusRegister(unsigned int chipSelect)

{

int data;

// part 1: set chip select

P2 &= ~chipSelect;

SSCTIR = 0;

SSCRIR = 0;

// part 2: send RDSR to the flash

SSCTB = FLASH_RDSR;

while (!SSCTIR) ServeWatchdog();

SSCTIR = 0;

// part 3: generate clock to read data from flash

SSCTB = FLASH_RDSR;

while (!SSCTIR) ServeWatchdog();

SSCTIR = 0;

// part 4: get readed data from SCC

while (!SSCRIR) ServeWatchdog();

data = SSCRB;

SSCRIR = 0;

// part 5: reset chip select

P2 |= chipSelect;

return data;

}

If I do it in this way, the chip select is resetted (part 5) while I generate the clock (part 3). But the chip select should be resetted after I readed the data (part 4).

Do you have any idea, what I have to do to get this?

Regards,

Juergen
juergen239955
Associate II
Posted on September 02, 2004 at 10:54

I use the M25P10 of ST.

But my problem has nothing to do with this flash. My problem is, that the chip select which I realized over P2 is resettet BEFORE I read the data out of the SCC. What I need is that the chip select is resettet AFTER I read the data out of the SCC.
tom7
Associate II
Posted on September 13, 2004 at 14:55

Juergen,

you may have run into the following problem, caused by the buffered SSCTB...

int readStatusRegister(unsigned int chipSelect)

{

int data;

// part 1: set chip select

P2 &= ~chipSelect;

SSCTIR = 0;

SSCRIR = 0;

// part 2: send RDSR to the flash

SSCTB = FLASH_RDSR;

while (!SSCTIR) ServeWatchdog();

SSCTIR = 0;

*** here your data was placed inside the SSC-Tx, now SSCTIR is set

and data gets physically clocked out...

// part 3: generate clock to read data from flash

*** you write the SSCTB (Tx of your first data might be ongoing by the SSC hardware...)

SSCTB = FLASH_RDSR;

while (!SSCTIR) ServeWatchdog();

*** Tx of first data is now finished - so does reception,

*** SSCRIR gets set !

*** SSCTB content gets shifted to SSC-Tx HW reg. and...

*** from here Tx starts physically, SSCTIR gets set by HW

***and you are immediately here, even if your second data hasn't been completely sent

*** SSCRIR is already set from first data transmission...

// part 4: get readed data from SCC

while (!SSCRIR) ServeWatchdog();

data = SSCRB;

SSCRIR = 0;

*** so you fall all the way through, even if your second data is still transmitting...

// part 5: reset chip select

P2 |= chipSelect;

return data;

}

Do you have any idea, what I have to do to get this?

*** yes, in polling mode always use SSCRIR to detect the finished sending of a data item on the SSC, reset SSCRIR, send second data...

Regards,

** have fun

Juergen

***tomas

juergen239955
Associate II
Posted on September 14, 2004 at 06:07

Hello Tomas,

thank you very much, but I don't think, that this happens. I need the first sended byte to tell the M25P10 that I want to read out the status register. The second byte is sended only to generate the clock which I need to read out the data serially. So the SSCRIR should be set after the second byte is sended and the whole byte is read in.

I attache a hardcopy of my oscilloscope to show what happens.

channel 1: chip select

channel 2: sended data

channel 3: received data

channel 4: clock

Here you can see that the chip select is resettet, while the second byte is sended.

Or am I wrong?

________________

Attachments :

TEK00000.PCX : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0K4&d=%2Fa%2F0X0000000bXU%2FTASDONIrAld.F1I037vBjXvNG4A4nakuDtr_bxExqVc&asPdf=false
tom7
Associate II
Posted on September 14, 2004 at 12:27

Juergen,

Sending implies receiving with the ssc device, so SSCRIR gets set when you send your first data byte and you are polling exactly this.

try this :

-switch CS active

-send first byte

-poll SSCRIR until it's set

- reset SSCRIR

- send second byte

-poll SSCRIR until it's set

- reset SSCRIR

switch CS off

that will certainly work

,

tom.