cancel
Showing results for 
Search instead for 
Did you mean: 

SPI interrupt too early?

tech9
Associate II
Posted on June 14, 2007 at 12:23

SPI interrupt too early?

7 REPLIES 7
tech9
Associate II
Posted on June 12, 2007 at 17:26

Has anyone tried various speeds for the SPI bus to read an SD card?

We have found some timing problems when doing so: the interrupt is triggered on the RFNE flag, but the char is not ready, we have to insert a delay before reading it.

Has anyone solved this without inserting delays in an ISR?

We are using an STR710 and an STR711, with IAR Embedded Workbench 4.41A

Thanks!

Jp

sofiene
Associate III
Posted on June 13, 2007 at 06:47

Hi-tech 🙂 ;

Could you detail how do you have configured clocks MCLK, PCLK1, which BSPI prescaler value do you have used, on which mode the BSPI is configured(Master or slave) and how do you have configured the interruption.

[ This message was edited by: M3allem on 13-06-2007 10:18 ]

[ This message was edited by: M3allem on 13-06-2007 10:19 ]

[ This message was edited by: M3allem on 13-06-2007 10:21 ]

tech9
Associate II
Posted on June 13, 2007 at 14:01

Hi M3allem,

MCLK is running at 48 MHz, PCLK1 is at 24MHZ, and we have tried prescalers values for the BSPI at 6, 12, 24, 48 and 60.

The BSPI is configured as master.

We send the char, we wait until TFE is set, we then poll the RFNE flag until set, and (after the wait period), read the char.

If RFNE is set, there should be no need to wait, since the MCU already got something to set it, right?

Thanks and regards,

Tech

sofiene
Associate III
Posted on June 13, 2007 at 14:37

Hi tech,

Could you precise how do you get the char: by polling on RFNE or by using the interruption with RFNE?

tech9
Associate II
Posted on June 13, 2007 at 15:26

Hi M3allem

Sorry if I mislead you in the beginning...

We pool RFNE, we do not use the interrupt.

Thank you.

Jp

sofiene
Associate III
Posted on June 14, 2007 at 11:52

Hi tech,

I have tested BSPI1 and BSPI0 in communication: BSPI1 in master mode, BSPI0 in salve mode, BSPI1 send a character to BSPI0 which poll RFNE and get this char. I don't have any problem.

try this code (after you have configured BSPI 0 and 1):

SendByte = 0xAA;

/* Send a 8bit data BSPI1 ---> BSPI0*/

BSPI_ByteBufferSend(BSPI1, (u8 *)&SendByte, 1);

/* Pool RFNE flag */

while( BSPI_FlagStatus(BSPI0, BSPI_RFNE) == RESET);

/* Receive the char using BSPI0 */

BSPI_ByteBufferReceive(BSPI0, Receivetab, 1);

/* Display of the recieved data */

printf(''0x%X\n'', Receivetab[0]);

/* Infinite loop */

while (1)

{

}

[ This message was edited by: M3allem on 14-06-2007 15:23 ]

tech9
Associate II
Posted on June 14, 2007 at 12:23

Thanks for the reply.

We have found that a dummy read immediately after sending the char helps a lot. Then; the next char to come is the one expected, and there is no longer a need for inserting a delay.

Hope this could also be useful to someone else, thanks for all the help.

Thanks and regards,

Tech