3 Replies Latest reply on Jun 21, 2016 6:43 AM by user_1377889

    Request guide and example of using SPI with interrupt

    typoon_1686656

      I am using the CY8CKIT-042-BLE development board with the CYBL10573 BLE module board. And I am using the PSoC Creator 3.3 IDE for the development.

         

      I am writing code for the PRoC as a SPI master to control a LCD. I can send data out by using the xxx_SpiUartPutArray() API function. However I do not know how to check when it finish sending the whole packet of data. On my previous experience, usually there are two ways:

         

      1.  keep checking a "BUSY" flag in a while loop, when the transmission is finished, it break out from the loop

         

      2. Set up an transmission end interrupt.

         

      I have looked the example code generated by the PSoC Creator, but I could not found a SPI examples using the above method. Instead, the code examples always assume there is a slave which will feedback data, and it check whether the number of byte transmitted is equal to the number of bytes received. However in my case the LCD will not feedback anything.

         

      Could you provide guide and code example?

         

      Frankly, the PSoC Creator generate a high level of abstraction code, but lack of detail explanation of using the API (Or it is very difficult to find them). I have also used Atmel, which use the same kind of abstraction, but I can find all examples for every MCU in its IDE. When I started to write the Atmel M0 MCU the first time, I can use only one day to drive all simple peripherals.

        • 1. Re: Request guide and example of using SPI with interrupt
          user_1377889

          Welcome in the forum!

             

          "check whether the number of byte transmitted is equal to the number of bytes received"

             

          This is an SPI thing, your LCD will send back data although they might be meaningless. For every bit (byte) you send as master a bit (byte) is received from the slave. So you may check whether the number of bytes received is equal to the number of bytes sent. That would indicate a complete transfer, including delay times in the sender / receiver part. Some of the serial components use an internal (!!) interrupt to make sure that the data is fetched from FIFO and stored in memory thus avoiding overflows. This could interfere with your own interrupt handlers.

             

          There is an extension to the SPI internal interrupt named "Macro Callback", search for this string in the datasheet for explanation. Some general information is in Creator Help.

             

          Opposed to competitor's chips, PSoCs contain real hardware. so the component's datasheet are made in the style of electronic datasheets. When used to them, they are easy to read and understand.

             

           

             

          Bob

          • 2. Re: Request guide and example of using SPI with interrupt
            typoon_1686656

            Hi Bob, thanks for your replay. I am not sure whether the SPI does require both MOSI and MISO exist together. However in my LCD module, which use a popular LCD driver IC, there is no MISO pin. Also in the Cypress configuration, we can set the SPI component to remove the MISO pin.....

               

            I can leave the MISO pin on the SPI component there, however is it good if this pin is useless? Especially in the case that we have used up all IO pins.

            • 3. Re: Request guide and example of using SPI with interrupt
              user_1377889

              Try the bi-directional mode for your SPIM, see picture in datasheet. There is an internal loopback so you can still see when transmission is done.

                 

               

                 

              Bob