7 Replies Latest reply on Jun 15, 2015 12:31 PM by hmoore

    IRQ question about SPI as a slave

      For our case, the SPI1 of the wiced module is used as a slave mode.

      I have modified wiced_spi_init() to make SPI1 be a slave, and the data sent from master can be received correctly by polling SPI bus.

      However, I would like to enable the IRQ of SPI1.

       

      The IRQ is enabled by the following code due to STM32F2xx is used.

           SPI_I2S_ITConfig(spi_mapping[spi->port].spi_regs, SPI_I2S_IT_RXNE, ENABLE);

      In addition, SPI1_irq() handler is implemented but this ISR is not called while data arriving.

       

      Is there anything missed to enable the SPI IRQ?

      Should link files be modified accordingly ?

        • 1. Re: IRQ question about SPI as a slave

          The reason is that I forget to configure NVIC for SPI IRQ.

          No modification on link file is needed.

          1 of 1 people found this helpful
          • 2. Re: IRQ question about SPI as a slave

            I have an issue which may be similar to your case. I am trying to implement SPI slave with transmit only. Clock will be provided by master (in this case I am just running a PWM and connecting it externally to the CLK pin of SPI).

             

            I realized that wiced_spi_init and platform_spi_init functions did not provide the options for slave and single line. Made some modifications to allow for that.

             

            Now I am stuck at spi_transfer function. When not using DMA, the code just gets stuck. And when using DMA, spi_dma_transfer function returns WICED_TIMEOUT.

             

            What am I doing wrong? My application is a simple broadcaster at frequency provided by the clock (38kHz in this case). It can be used for IR communication (one-way, tx only like remotes).

             

            I would really appreciate your help.

            • 3. Re: IRQ question about SPI as a slave

              Hi,

              I am assuming that slave is to receive data in your case.

              Regarding using DMA mode,

              you can increase the timeout value temporarily, that I ever tried it.

              Then it should get the sent data from host.

              • 4. Re: IRQ question about SPI as a slave

                The underlying platform is STM32F2xx, which does not support 38kHz clock for SPI.

                 

                I would like to transmit data, and since required speed is not supported by the platform, I decided that an external clock could be used and use SPI in slave mode to transmit data.

                 

                In platform_spi.c I made a new function which is similar to platform_spi_init but also allows to provide direction and master/slave setting. For example, following is set:

                 

                spi_init.SPI_Direction = SPI_Direction_1Line_Tx;

                spi_init.SPI_Mode      = SPI_Mode_Slave;

                 

                After this

                SPI_Cmd ( spi->port, ENABLE );

                 

                which SETs SPE in CR1 register to initialize the SPI.

                 

                I didn't modify the transfer functions and am trying to use the original ones. I am wondering if there is anything additional that needs to be taken care of when using SPI in slave mode.

                • 5. Re: IRQ question about SPI as a slave

                  DMA Timeout issue resolved for SPI Master mode.

                   

                  Ref: SPI master and DMA, tested ?

                  (special thanks to userc_9344)

                   

                  I will try to tackle the slave issues:

                  Trying to use the SPI in slave mode to transmit data (TX only) and there is an external clock (generated via wiced_pwm lib connected to CLK pin via jumper).

                   

                  If suggestions, please share.

                  • 6. Re: IRQ question about SPI as a slave

                    Hi,

                    Did you modify chip_select code in wiced_spi_init() as below ?

                    wiced_gpio_init(spi->chip_select, INPUT_HIGH_IMPEDANCE); //we are slave

                    • 7. Re: IRQ question about SPI as a slave

                      Discussion is being locked. If you have any follow-up questions, please start a new discussion.