6 Replies Latest reply on Aug 9, 2015 12:41 AM by user_377418940

    SPI slave component TX what? when buffer is empty

    user_377418940

      Hi,

         

      I have a SPI slave component (obviously talking to some master...) which is part of a command interface.
      The slave normally has less data than commands received...

         

      SPI(UDB) full duplex slave has software buffers rx&tx enabled (size=64)

         

      My simple question is basically: how do i define the standard reply data when no data is available to transfer from slave to master.
      I would like to define txdata = 0x00 by default when no data is available to transfer to master. In my communication language this is a NOP.

         

      (yes: i can do counting incoming bytes and making sure the tx-buffer is always filled to same amount...)

         

      isn't there an elegant solution based on bufferEmpty of FIFOempty status?
      status now: i see repeats of 'earlier' data from fifo of txbuffer...

         

      any help is welcome ...

        • 1. Re: SPI slave component TX what? when buffer is empty
          user_14586677

          Maybe Bob can comment on this but I thinks its just that inelegant. SPI

             

          is not a "high level" interface standard, as such is not "aware" of what

             

          the data is, just the user coding for it. Its up to the user ro throw away

             

          irrelevant Rx data when Tx is active.

             

           

             

          Regards, Dana.

          • 2. Re: SPI slave component TX what? when buffer is empty
            user_377418940

            what i have observed is a repeat of data placed in the txbuffer, so a retransmission... but it's not the last piece of data ;-(

               

            I guess something is either stuck in the fifo or the ringbuffer is not updating the low-level component because there nothing to transmit...

               

            i did see a difference between psoc 4 hardware engine and psoc 5 udb component... now i want in 5lp basically the same behavior and having problems with the auto repeat data...

               

            i did think of adding a some counterbits (so receiver can see the diff between new and stale/repeat data) but that just seems nasty !

               

            my guess is that everybody using the spi-slave functionality must solve this issue, if the slave transmitted data is less then the number of bytes transferred by the master... so hopefully a lot of solutions exist to this fundamental problem... "what to transmit when no data is available in the buffer."

            • 3. Re: SPI slave component TX what? when buffer is empty
              user_1377889

              When no data is in the buffer, the last byte transmitted out of the FIFO will be repeated. Since this may not be what you want, why not set up a transmit buffer for this special case? This enables you to define yourself what has to happen.

                 

              Since for every bit (byte) sent by the master a bit (byte) is returned by the slave you may already indicate at the command-byte sent by master if (or how many) data is present.

                 

               

                 

              Bob

              • 4. Re: SPI slave component TX what? when buffer is empty
                user_377418940

                Hi all,

                   

                thanks for the comments, and i have implemented a solution which is 'good enough' but (as already stated) a bit dirty...
                (added a counter (3bit) in slave tx data, and in master receive routine compare new data which last 4) indeed ugly but good enough.

                   

                the data received from slave is (in my test) not the last, but the 2nd to last data put in the buffer. because I'm queuing commands in the slave (so at least results will be delayed in time...) adding information in the reply data from slave reflecting the amount of data in principle works, but is 'ugly' too... My command parser is knowledgeable about the number of bytes of payload... the low level transport channel is not aware of payload size and i really want to keep it that way ;-)

                   

                As stated before i did see a difference in behavior between SCB and UDB implemention, the SCB does behave 'better' because if does not repeat data from txbuffer but instead outputs all zero's of all one's, easy to detect ;-)

                   

                I do hope that somebody adds the 'what default data to transmit from SPI slave when no data is in txbuffer' to the API, naturally preserving compatibility etc. ;-) ???

                   

                again thanks Dana and Bob for looking at the options and your feedback is (was) highly appreciated !

                • 5. Re: SPI slave component TX what? when buffer is empty
                  user_14586677

                  Consider filing a CASE on this to "help" factory see this needed change.

                     

                  Just give them a link to this to save yourself from repetition.

                     

                   

                     

                  To create a technical or issue case at Cypress -

                     

                   

                     

                  www.cypress.com

                     

                  “Support”

                     

                  “Technical Support”

                     

                  “Create a Case”

                     

                   

                     

                  You have to be registered on Cypress web site first.

                     

                   

                     

                  Regards, Dana.

                  • 6. Re: SPI slave component TX what? when buffer is empty
                    user_377418940

                    done.

                       

                    case #2957760528