cancel
Showing results for 
Search instead for 
Did you mean: 

SPI problems, no interrupt?

basvandijk86
Associate II
Posted on December 07, 2007 at 10:04

SPI problems, no interrupt?

2 REPLIES 2
basvandijk86
Associate II
Posted on December 05, 2007 at 04:30

I’m using the STR730 on the Hitex STR730 evaluation board (via Keil). I have problems with receiving SPI data. When I watch with a scope I see there is data running over the bus, but it seems that the STR does not get a receive interrupt.

I did not use DMA (is this recommended?) because I did never use it before when using SPI.

On the evaluation board there is a 7segments led display which I want to change when he receives an interrupt. But so far he is not changing anything, so not receiving anything! Here is my code, am I missing something? I did make use of the example code which is on the ST site.

Main.c

/* Standard include ------------------------------------------------------------*/

#include ''main.h''

/* Include of other module interface headers -----------------------------------*/

/* Local includes --------------------------------------------------------------*/

/* Private typedef -------------------------------------------------------------*/

/* Private define --------------------------------------------------------------*/

/* Private macro ---------------------------------------------------------------*/

/* Private variables -----------------------------------------------------------*/

const unsigned char LED7SEG[] = { 0xC0, 0xF9, 0xA4, 0xB0,

0x99, 0x92, 0x82, 0xF8,

0x80, 0x90, 0x88, 0x83,

0xC6, 0xA1, 0x86, 0x8E

} ;

GPIO_InitTypeDef GPIO_InitStructure;

BSPI_InitTypeDef BSPI_InitStructure;

PRCCU_InitTypeDef PRCCU_InitStructure;

/* Private function prototypes -------------------------------------------------*/

/* Interface functions ---------------------------------------------------------*/

/* Private functions -----------------------------------------------------------*/

/*******************************************************************************

* Function Name : wait

* Description : wait statement

* Input : None

* Output : None

* Return : None

*******************************************************************************/

void wait(void)

{

u32 i;

for (i=100000L; i!=0 ; i-- ) {}

}

/*******************************************************************************

* Function Name : SPI0_Init

* Description : Initialize SPI0 perifpheral

* Input : None

* Output : None

* Return : None

*******************************************************************************/

void SPI0_init()

{

/* BSPI0 configuration -------------------------------------------------------*/

BSPI_InitStructure.BSPI_RxFifoSize = 5;

BSPI_InitStructure.BSPI_TxFifoSize = 5;

BSPI_InitStructure.BSPI_SSPin = BSPI_SSPin_Used;

BSPI_InitStructure.BSPI_CPOL = BSPI_CPOL_High;

BSPI_InitStructure.BSPI_CPHA = BSPI_CPHA_1Edge;

BSPI_InitStructure.BSPI_WordLength = BSPI_WordLength_8b;

BSPI_InitStructure.BSPI_Mode = BSPI_Mode_Slave;

BSPI_RxITConfig(BSPI0, BSPI_RxIT_RFNE | BSPI_RxIT_RFF);

BSPI_Init(BSPI0, &BSPI_InitStructure);

}

/*******************************************************************************

* Function Name : GPI0_Init

* Description : Initialize GPI0

* Input : None

* Output : None

* Return : None

*******************************************************************************/

void GPIO_init()

{

/* GPIO pins configuration ---------------------------------------------------*/

/* BSPI0 pins configuration */

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_TRI_TTL;

GPIO_InitStructure.GPIO_Pins = GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13 |

GPIO_PIN_14;

GPIO_Init(GPIO6, &GPIO_InitStructure);

/* Setup GPIO0 - 7 segment LED displays (P0.0 .. P0.9)*/

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT_PP;

GPIO_InitStructure.GPIO_Pins = GPIO_PIN_ALL;

GPIO_Init(GPIO0, &GPIO_InitStructure);

}

/*******************************************************************************

* Function Name : MLCK_Config

* Description : Master CLK settings

* Input : None

* Output : None

* Return : None

*******************************************************************************/

void MCLK_Config (void)

{

PRCCU_InitTypeDef Clock;

CMU_InitTypeDef ClockInit;

Clock.PRCCU_DIV2=DISABLE;

Clock.PRCCU_MCLKSRC_SRC=PRCCU_MCLKSRC_PLL;

Clock.PRCCU_PLLDIV=PRCCU_PLLMUL_12;

Clock.PRCCU_PLLMUL=PRCCU_PLLDIV_6;

ClockInit.CMU_RCOscControl=0x0;

ClockInit.CMU_EndCountValue=0x0;

ClockInit.CMU_FreqRef_High=0x0;

ClockInit.CMU_FreqRef_Low=0x0;

ClockInit.CMU_CKSEL0=0x0;

ClockInit.CMU_CKSEL1=0x0;

ClockInit.CMU_CKSEL2=CMU_CKSEL0_CKOSC;

CMU_Lock (DISABLE);

CMU_Init (&ClockInit);

PRCCU_Init(&Clock);

/* Peripheral clock configuration --------------------------------------------*/

/* enable GPIO 0, 4, 5 and 6 clock */

CFG_PeripheralClockConfig(CFG_CLK_GPIO0, ENABLE);

CFG_PeripheralClockConfig(CFG_CLK_GPIO4, ENABLE);

CFG_PeripheralClockConfig(CFG_CLK_GPIO5, ENABLE);

CFG_PeripheralClockConfig(CFG_CLK_GPIO6, ENABLE);

/* enable BSPI 0 clock */

CFG_PeripheralClockConfig(CFG_CLK_BSPI0, ENABLE);

/* enable EIC clock */

CFG_PeripheralClockConfig(CFG_CLK_EIC, ENABLE);

}

void SPI_interrupt()

{

/* Enable global interrupts */

EIC_IRQChannelConfig(BSPI0_IRQChannel,ENABLE);

EIC_IRQChannelPriorityConfig(BSPI0_IRQChannel, 1);

/* enable the Interrupt controller to manage IRQ channel*/

EIC_IRQCmd(ENABLE);

BSPI_Cmd(BSPI0, ENABLE); /* Enable BSPI0 */

// disable interrupts globally

EIC_IRQCmd(DISABLE);

}

/*******************************************************************************

* Function Name : main

* Description : main function, where program start.

* Input : None

* Output : None

* Return : None

*******************************************************************************/

int main()

{

#ifdef DEBUG

debug();

#endif

MCLK_Config();

GPIO_init();

SPI0_init();

GPIO_WordWrite(GPIO0, LED7SEG[0] | 0x0100);

while(1)

{

SPI_interrupt();

if (ReceivedData != 0x0){

GPIO_WordWrite(GPIO0, LED7SEG[2] | 0x0100);

}

}

}

73x_it.c

/*******************************************************************************

* Function Name : BSPI0_IRQHandler

* Description : This function handles the BSPI0 interrupt request.

* Input : None

* Output : None

* Return : None

*******************************************************************************/

void BSPI0_IRQHandler (void)

{

ReceivedData = BSPI_WordReceive(BSPI0);

GPIO_WordWrite(GPIO0, 0x88 | 0x0100);

}

christophe239955_st
Associate II
Posted on December 07, 2007 at 10:04

why do you need to disable the interrupt EIC_IRQCmd(DISABLE); in SPI_interrupt() function? try to comment this in your code to allow interrupt to be served.