cancel
Showing results for 
Search instead for 
Did you mean: 

SPI Interrupts

tyronevs
Associate II
Posted on December 03, 2007 at 13:41

SPI Interrupts

2 REPLIES 2
tyronevs
Associate II
Posted on October 30, 2007 at 04:04

Hi all,

I am not having much joy in getting my SPI peripherals to work on an IRQ base. Polling works!!! but I am not finding that it triggers an interrupt when I set the receive interrupt. (BSPI_RcItSrc(BSPIx,BSPI_RC_FNE);)

My Init code is as follows. (Using IAR)

// =============================================================================

void SPI_Init(char SPI_Channel_No, char SPI_Mode)

{

BSPI_TypeDef *BSPIx;

// Configure GPIO0's pins to perform alternate function, SPIx (Push Pull)

switch (SPI_Channel_No)

{

case 0 :

BSPIx = BSPI0;

// P0.0 - MISO P0.1 - MOSI P0.2 - CLK P0.3 - SS

GPIO_Config(GPIO0,0x000F,GPIO_AF_PP);

BSPI_BSPI0Conf(ENABLE); // Enable the BSPI0 interface in PCU_BOOTCR

break;

case 1 :

BSPIx = BSPI1;

// P0.4 - MISO P0.5 - MOSI P0.6 - CLK P0.7 - SS

GPIO_Config(GPIO0,0x00F0,GPIO_AF_PP);

break;

} // switch (SPI_Channel_No)

BSPI_Init(BSPIx); // Initialize BSPI1

BSPI_ClockDividerConfig(BSPIx,8); // Configure Baud rate Frequency :-->APB1/8

BSPI_Enable(BSPIx,ENABLE); // Enable BSPIx

if (SPI_Mode == SPI_MASTER)

{

BSPI_MasterEnable(BSPIx,ENABLE); // Configure BSPI0 as a Master

} // if (SPI_Mode == SPI_MASTER)

else

{

BSPI_MasterEnable(BSPIx,DISABLE); // Configure BSPI0 as a Slave

} // else

BSPI_ClkActiveHigh(BSPIx,ENABLE); // Configure the clock to be active high

BSPI_ClkFEdge(BSPIx,DISABLE); // Enable capturing the first Data sample on the first edge of SCK

BSPI_8bLEn(BSPIx,ENABLE); // Set the word length to 16 bit

BSPI_RcFifoDepth(BSPIx,10); // Configure the depth of receive up to 10 words

BSPI_RcItSrc(BSPIx,BSPI_RC_FNE); // Set RX Interrupt Source

} // void SPI_Init(char SPI_Channel_No, char SPI_Mode)

Any help would be appreciated!!!

Regards,

Gizmoinsa :o :o

kaouther
Associate II
Posted on December 03, 2007 at 13:41

Dear gizmoinsa,

Is the EIC already configured ?

A helpful basic configuration of BSPI in Master and slave mode is available in the STR71xFWLib V4.0. New example for BSPI using interrupt is added as well. Please download the last

http://www.st.com/mcu/download2.php?file=str71xfwlib.zip&info=STR7 Software STR71x&url=http://www.st.com/stonline/products/support/micro/files/str71xfwlib.zip

and refer to readme.txt file for example description.