8 Replies Latest reply on Sep 30, 2014 9:17 PM by dmiya

    SPI Output flow control pin

      Hi all,

      I have a problem when I use SPI Output flow control pin.

      In spi_comm_slave demo, the SPI Output flow control pin is P14:

      #define SPIFFY2_OUTPUT_FLOW_CTRL_PIN                14

      #define SPIFFY2_OUTPUT_FLOW_CTRL_PORT               0

       

      I tried to modify it to P24:

      #define SPIFFY2_OUTPUT_FLOW_CTRL_PIN                24

      #define SPIFFY2_OUTPUT_FLOW_CTRL_PORT               0

      But when I run the application and capture signal on P24, there is not any pulse on this pin.

        • 1. Re: SPI Output flow control pin

          For P24, SPIFFY2_OUTPUT_FLOW_CTRL_PIN should be 8.

          You should modify SPIFFY2_OUTPUT_FLOW_CTRL_PORT to 1 also.

           

          PIN means lower 4bits of GPIO number. PORT is upper 4 bits.

           

          I usually use following definitions.

          #define XXX_PIN (24 & 0x0f)

          #define XXX_PORT (24 >> 0x04)

          1 of 1 people found this helpful
          • 2. Re: SPI Output flow control pin

            Thank dmiya. That information is so helpful.

            • 3. Re: SPI Output flow control pin

              Hi all,

              In spi_comm_slave demo, the SPI max number bytes is 15:

              #define SPIFFY2_MAX_NUMBER_OF_BYTES_PER_TRANSACTION 15


              I want to send a larger bytes per transaction, so I modified:

              #define SPIFFY2_MAX_NUMBER_OF_BYTES_PER_TRANSACTION 23

               

              But It's seem that there is some problem, the data I received is not correct.

              Please help me to fix this problem!

              • 4. Re: SPI Output flow control pin

                SPI interface has 16 bytes receiver buffer.

                So if you send more than 16 bytes data, something will be missing.

                • 5. Re: SPI Output flow control pin

                  Thanks dmiya!

                  But if I want to send more than 16bytes data at the same time, what should I do?

                   

                  example: in my code, I tried to send 20bytes: [ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,0x07,0x08,0x09,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x20]

                   

                            for ( idx = 0; idx < 23; idx++)

                              {

                              spiffyd_slaveTxData(SPIFFYD_2, 1, spi_slave_bytes_to_tx + idx );

                              }

                  but I only received 4bytes: 0x16, 0x17, 0x18, 0x19.

                  • 6. Re: SPI Output flow control pin

                    If the data size is lower than 17 bytes, spiffyd_slaveTxData() works fine I think.

                    So you need to wait until the data in tx FIFO has been transmitted by interrupt or timer.

                    Then you can set additional data to the FIFO using spiffyd_slaveTxData().

                    1 of 1 people found this helpful
                    • 7. Re: SPI Output flow control pin

                      Below is my code:

                       

                             memcpy(&spi_slave_bytes_to_tx[1], buffer, 14);

                           gpio_setPinOutput(SPIFFY2_OUTPUT_FLOW_CTRL_PORT, SPIFFY2_OUTPUT_FLOW_CTRL_PIN, GPIO_PIN_OUTPUT_HIGH);

                           while(gpio_getPinOutput(SPIFFY2_OUTPUT_FLOW_CTRL_PORT, SPIFFY2_OUTPUT_FLOW_CTRL_PIN) == GPIO_PIN_OUTPUT_HIGH);

                           spi_slave_bytes_to_tx[0] = length - 14 ;

                           memcpy(&spi_slave_bytes_to_tx[1], buffer + 14, length - 14 );

                           gpio_setPinOutput(SPIFFY2_OUTPUT_FLOW_CTRL_PORT, SPIFFY2_OUTPUT_FLOW_CTRL_PIN, GPIO_PIN_OUTPUT_HIGH);

                       

                      After the first transaction, I wait for FCO pin change to de-assert ( finish the transaction) by a while loop, then continue to send the second data frame.  But there is problem in the while loop, it seem that the while loop make the the bluetooth disconect.

                       

                      can you help me fix this problem?

                      How can I use data in tx FIFO has been transmitted by interrupt ?

                      • 8. Re: SPI Output flow control pin

                        I never try while loop. But I think using interrupt is better than while loop.