9 Replies Latest reply on Apr 7, 2014 3:01 PM by user_3566761

    SPIM  API

    user_301665782

      Hi there !

         

      Can anyone tell me please how send many bytes on spi bus (using the API for SPIM) without  get SS high  before sent all the bytes ?

         

      Thank you very much.

        • 1. Re: SPIM  API
          ki.leung

           I normally control the cs pin myself via a control register output. 

          • 2. Re: SPIM  API
            user_1377889
                    The SPI-Master has got a FIFO (4 bytes deep). As long as this FIFO is not empty the SS-signal will not go high.   
            So you should check the SPIM_ReadTxStatus() for STS_TX_FIFO_NOT_FULL in a loop until you have sent all your bytes to the SPIM. The transfer is handled by the component. When you are using the high-level API SPIM_PutArray() all this will be handled by the internals.   
               
            Bob   
            • 3. Re: SPIM  API
              user_78878863

              This depends on the SPI frequency. When it is too high, even using an interrupt to refill the FIFO is not fast enough. In this case SS will go high even though it should not.

              • 4. Re: SPIM  API
                user_1377889
                        At 1000 kbit/s filling the FIFO with 3 bytes will leave you 24µs to perform that job.   
                If that does not work, you may use HI's hint and control a ss-signal yourself.   
                   
                Bob   
                • 5. Re: SPIM  API
                  user_301665782

                  Thank you very much Bob and hli for your valuable help.

                     

                  Thanks  both of you , with your suggestion and experience , finaly I could establish comunication with nRFL24L01+.

                     

                  The point was that that chip has a SPI  and requires hold its CSN ( chip select) low over the entire transaccion for send a  write or read comand to set Registers or Verify Register.

                     

                  I 'm using SPIM  API and when I need to send two bytes and receive two ( status register and other one),  there is no issue with the API.

                     

                  The issue  come  up when I am trying to send  a  read  or write comand byte with  5 or more  byte long.  At that time API does not work.

                     

                  I suppose it happend because ss   ( ss( SPIM API) ------->CSN ( nRF24L01+) ),  goes high - low- high,  with every  SPIM_WriteTxData or  SPIM_ReadTxData.

                     

                  I have tried to use void SPIM_PutArray(const uint8/uint16 buffer[], uint8 byteCount) .

                     

                  Taking a look to this fuction, it has a loop with SPIM_WriteTxData, and that implies that ss is getting" low and high too."

                     

                  So, based on both of you suggestion  I have controlled CSN independently of API. I have used a control register for that.

                     

                  And !!!!!! every think work ok so far.

                     

                  So Thank you so much.

                  • 6. Re: SPIM  API
                    user_1377889

                    Alex, you are always welcome!

                       

                     

                       

                    Bob

                    • 7. Re: SPIM  API
                      user_78878863

                      As said above, when you configure tha SPI buffers to more than 4 bytes (which I assume you did), an internal ISR is used. And it might just not be fast enough to supply the data fast enough before the SPI runs out of data to send. (And if not, a similar thing happens when you send more than 4 bytes with a 4 byte buffer, but then its the API method doing this magic)

                      • 8. Re: SPIM  API
                        ki.leung

                        Good to here that 

                        • 9. Re: SPIM  API
                          user_3566761

                           Gee, folks, I really should have read your posts before I spent a few days figuring this out by myself. I have exactly the same problem. SS goes high before I could put another byte through WriteTxData(). While the slave sees SS going high, it reset itself and call it a day! I am going to use a control register like you guys suggested!