1 Reply Latest reply on May 27, 2016 3:24 AM by hima

    Problems with BLE and I2C Slave

    rich.soennichsen_1592346

      Hi,

         

      The PSoC is acting as an I2C slave.  When new data is received via Bluetooth the PSoC raises a pin, alterting the master that data is available.  When the I2C read by the master is complete the PSoC sets the pin low.

         

      My main loop:

         

          for(;;)
          {
              handleComs();
              
              /* Process BLE Events. This generates events in the callback function */
              CyBle_ProcessEvents();

              /* To achieve low power in the device */
              LowPowerImplementation();

         

          }

         

      This is part of the BLE event handler where the interrupt pin is set high (active) to indicate new data was received via BLE:

         

      case CYBLE_EVT_GATTS_WRITE_REQ:
          /* This event is generated when the connected Central */
          /* device sends a Write request. */
          /* The parameter ‘eventParam’ contains the data written */
              /* Extract the Write data sent by Client */
          wrReqParam = (CYBLE_GATTS_WRITE_REQ_PARAM_T *) eventParam;
          
          /* If the attribute handle of the characteristic written to
          * is equal to that of PX Config characteristic, then extract
          * the PX Config data */
          if(CYBLE_PX_CONFIG_PX_CONFIG_CONTROL_CHAR_HANDLE ==
          wrReqParam->handleValPair.attrHandle)
          {
          /* Store data in local array */
              for(i=0;i<PX_CONFIG_DATA_SIZE;i++)
              {
                  pxConfigData[i] = wrReqParam->handleValPair.value.val[i];
                  i2cReadBuffer[i] = wrReqParam->handleValPair.value.val[i];
              }
          
          /* Update the GATT DB for PX Config read characteristics*/
          UpdatePxConfigcharacteristic(pxConfigData,
          sizeof(pxConfigData),
          CYBLE_PX_CONFIG_PX_CONFIG_CONTROL_CHAR_HANDLE);
          }

         

          /* Send the response to the write request received. */
          CyBle_GattsWriteRsp(cyBle_connHandle);
          BLE_INT_Write(1);   //Set the PX Interrupt pin active
      break;

         

      .....

         

       

         

      In handleComs, this is where the interrupt pin is set low (cleared) after the master read via I2C:

         

      /* Read complete: expose buffer to master */
              /*This is a READ BY THE Master of the BLE   */
              if (0u != (I2C_Slave_I2CSlaveStatus() & I2C_Slave_I2C_SSTAT_RD_CMPLT))
              {
                  
                  BLE_INT_Write(0);   //Set the Interrupt pin inactive
                  
                  /* Clear slave read buffer and status */
                  I2C_Slave_I2CSlaveClearReadBuf();  //just sets the read index to zero
                  (void) I2C_Slave_I2CSlaveClearReadStatus();
              }

         

       

         

      When I am debugging this works great.  The BLE receives data, sets the pin high, the master reads, and the BLE sets the pin low.  When I am NOT running the debugger the interrupt pin never gets set low,

         

       

         

      Ideas?

         

       

         

      Thanks

         

       

         

      Rich