8 Replies Latest reply on Dec 18, 2014 11:25 PM by georgschmidt

    SPI Interrupt on SN8200

    georgschmidt

      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

        • 1. Re: SPI Interrupt on SN8200
          user_60662854

          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.

          • 2. Re: SPI Interrupt on SN8200
            georgschmidt

            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.

            • 3. Re: SPI Interrupt on SN8200
              georgschmidt

              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

              • 4. Re: SPI Interrupt on SN8200
                user_60662854

                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

                • 5. Re: SPI Interrupt on SN8200
                  georgschmidt

                  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[i] = *(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

                  • 6. Re: SPI Interrupt on SN8200
                    jone_yi_1844281

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

                    • 7. Re: SPI Interrupt on SN8200
                      seyhan

                      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

                      • 8. Re: SPI Interrupt on SN8200
                        georgschmidt

                        Yes, question is resolved.

                        Thanks!