SPI Interrupt on SN8200

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
GeSc_2134251
Level 2
Level 2
First like received

Hi,

I'm trying to use the SPI-Interrupt on my SN8200-Board.

Can anyone tell me how to assign an interrupt handler to the apropriate interrupt vector?

Regards,

Georg

0 Likes
8 Replies
Anonymous
Not applicable

Take a look at the GPIO Sample Code section of the WICED Smart Hardware Interfaces pdf (in the Doc folder).  There is sample code there that sets up an interrupt on a GPIO pin.

0 Likes

Sorry, I can't find the pdf in my Doc folder.

But setting up an interrupt on a GPIO Pin is not the problem, I already did this with wiced_gpio_input_irq_enable​().

What I need is an interrupt for the SPI module.I configured the SN8200 as a SPI slave and I want to handle the SPI reception in an ISR using the "Receive buffer not empty" (RXNE) interrupt.

I printed the vector table to the console and it seems that the SPI interrupt vector is mapped to a default handler.

As the vector table is located in the flash section, i think I have to edit something in the RTOS files.

I'm using FreeRTOS, but by now I havent't find the file where the interrupt vectors are being assigned.

0 Likes
Anonymous
Not applicable

Ahh, ok.  The sample code uses the stack functionality to communicate over the spi interface, so it wouldn't be much help.  Post some code when you have it working!

FYI -

Screenshot_120214_090142_AM.jpg

There seems to be a different between your WICED-Smart-SDK and the WICED-SDK I use.

There's some different content in my doc folder...

Now here's the code I use.

It runs well with ST32F103RF on Murata SN8200 but it should be easy to modify it for any other ARM-Core.

typedef void (*IsrFunc_t)(void);

uint32_t auiUser_Vector_Table[75] __attribute__((aligned(512)));

void SPI_Int(void);

void CopyVectorTable()

{

    uint32_t* pSourcePointer;

    pSourcePointer = (uint32_t*)SCB->VTOR;

    uint8_t i;

    for(i=0; i<75; i++)

    {

        auiUser_Vector_Table = *(pSourcePointer++);

    }

    SCB->VTOR = (uint32_t)auiUser_Vector_Table;

}

void SetIntHandler(uint8_t VectorNr, IsrFunc_t pFunc)

{

    uint8_t IntNr  = VectorNr;

    uint8_t RegNr  = IntNr / 32;

    uint8_t BitPos  = IntNr % 32;

    NVIC->ISER[RegNr] = 1<<BitPos;

    auiUser_Vector_Table[VectorNr+16] = (uint32_t)pFunc;

}

void application_start(void)

{

    /* Initialise the device and WICED framework */

    wiced_init( );

    /* copy the vector table to RAM */

    CopyVectorTable();

    /* assign the SPI Interrupt Handler */

    SetIntHandler(SPI1_IRQn,SPI_Int);

    /*Init the SPI Interface */

    wiced_spi_device_t spi = {

        .port        = WICED_SPI_1,

        .chip_select = WICED_SPI_FLASH_CS,

        .speed      = 750000,

        .mode        = (SPI_CLOCK_FALLING_EDGE | SPI_CLOCK_IDLE_HIGH | SPI_NO_DMA | SPI_MSB_FIRST),

        .bits        = 8

    };

    wiced_spi_init(&spi);

    /* Enable SPI RX interrupt */

    SPI1->CR2 |= SPI_CR2_RXNEIE;


     while (1)

     {

          // Main loop

     }

}


/* SPI interrupt handler */

void SPI_Int(void)

{

     // Handle SPI reception

}


Additionally I modified these two lines of wiced_spi_init():

spi_init.SPI_Mode = SPI_Mode_Slave;

spi_init.SPI_NSS = SPI_NSS_Hard;

Regards,

Georg

0 Likes

The interrupt is assign by the linker script *.ld under platform

0 Likes

Hi,

The WICED-Smart-SDK supports the Broadcom bluetooth and BLE devices.

The WICED-SDK supports the Broadcom WiFi devices.

These are different SDKs which support different devices.

Georg, I understand you already resolved your question right?

Seyhan

0 Likes

Yes, question is resolved.

Thanks!

0 Likes
GeSc_2134251
Level 2
Level 2
First like received

Ok, I made it.

I copied the vector table into RAM and set the SCB_VTOR register to address of the copy.

In the copy I could assign an ISR to the SPI-Vector finally.

Additionally I had to activate the interrupt in the NVIC_ISER Register.

Regards,

Georg

0 Likes