1 Reply Latest reply on May 5, 2019 11:42 PM by BragadeeshV_41

    Bidirectional SPI No Signal Output

    xahuc_3536641

      Hi All, 

       

      I am having an issue getting SPI communication to work. I am using the SPI peripheral in bidirectional mode attempting to interface with this chip. It seems like this should be simple enough as the chip has a single 16-bit command structure. However, when trying to send data, I see the SCLK signal, but I do not see the SDIO signal! It's just low the whole time. Here's a snapshot of the relevant code in my main loop with relevant code on line 61:

       

      #include "project.h"
      #include "I2C.h" 
      #include "MODBUS.h"
      #include "MODBUS_Util.h"
      uint16 Heartbeat_LED_counter = 0;
      void SysTickISRCallback(void)
      {
          Heartbeat_LED_counter++;
      }
      int main(void)
      {
          CyGlobalIntEnable; /* Enable global interrupts. */
         
          
          /***********************************************/
          /* Custom Code to enable timeout for I2C hang */
          CySysTickStart();
          
          for (uint8 i = 0u; i < CY_SYS_SYST_NUM_OF_CALLBACKS; ++i)
          {
              if (CySysTickGetCallback(i) == NULL)
              {
                  /* Set callback */
                  CySysTickSetCallback(i, SysTickISRCallback);
                  break;
              }
          }
          /***********************************************/
          
          /* Indicator LED ON During Setup */
          Indicator_LED_OUT_1_Write(0x01);
          
          /* Place your initialization/startup code here (e.g. MyInst_Start()) */
          
          MODBUS_Start();
          I2C_Start();
          SPI_Master_Start();
          
          uint16 test_spi = 0b0010101001000000;
          
          /* Flash Indicator LED OFF After Setup */
          Indicator_LED_OUT_1_Write(0x00);
          CyDelay(100);
          Indicator_LED_OUT_1_Write(0x01);
          CyDelay(100);
          Indicator_LED_OUT_1_Write(0x00);
          CyDelay(100);
          Indicator_LED_OUT_1_Write(0x01);
          CyDelay(100);
          Indicator_LED_OUT_1_Write(0x00);
          CyDelay(100);
          
          CyWdtStart(CYWDT_1024_TICKS, CYWDT_LPMODE_NOCHANGE);
          
          
          
          
          for(;;)
          {    
              
              SPI_CS_REG_Write(0x00);
              CyDelay(100);
              SPI_Master_TxEnable();
              SPI_Master_WriteTxData(test_spi);
              uint8 status = SPI_Master_ReadTxStatus();
              while(!(status & SPI_Master_STS_SPI_DONE))
              {
                  status = SPI_Master_ReadTxStatus();
              }
              SPI_Master_TxDisable();
              CyDelay(100);
              SPI_CS_REG_Write(0x01);
              CyDelay(500);
              
              
              /* Place your application code here. */
              if(MODBUS_Get_Message_Available())
              {
                  MODBUS_Process_Msg();
              }
              
              /* Feed the WatchDog */
              CyWdtClear();
              
              /* Check Heartbeat LED */
              if(Heartbeat_LED_counter >= 1000)
              {
                  Heartbeat_LED_counter = 0;
                  Indicator_LED_OUT_2_Write(~Indicator_LED_OUT_2_Read());
              }
          }
      }
      

       

      I am very unsure what's going on, but I do know that if I switch to MOSI+MISO mode and assign MOSI to the same pin as SDIO it seems to at least try to send the data, but the chip doesn't seem to respond. The main problem is just not a hair or a breath of movement on the SDIO pin even though the SCLK signal is there and I called SPI_Master_TxEnable(). I don't know what else I have to do for it to work.

       

      I have attached my project for reference. Also, please don't link me to a different thread. I have read so many and no one has answered my question. This thread gets linked all over the place and I swear to you I have already read it.