Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 

    BHI160 no sensor data after first interrupt signal

    BHI160 no sensor data after first interrupt signal

    MintaeBae
    New Poster

    Hello

     

    We're developing board using BHI160B with STM32 MCU.

    My code and firmware is based on the driver and examples.

    Driver : https://github.com/BoschSensortec/BHy1_driver_and_MCU_solution

     

    We were able to upload and check firmware, then we can read interrupt signal and data once.

    After that, there is no interrupt signal nor data from the sensor.

     

    We've done some test and found out there's no pullup resistor for aux I2C port, but adding them made no difference.

    It seems there's no signal from aux I2C port at all.

     

    Here's our test code snippet.

      /* Wait for IMU is powered on. */
      while(!Dev_IMU_CheckIntSignal());
    
      /* put callbacks. */
      bhy_install_meta_event_callback(BHY_META_EVENT_TYPE_INITIALIZED, meta_event_callback);
      bhy_install_meta_event_callback(BHY_META_EVENT_TYPE_SELF_TEST_RESULTS, meta_event_callback);
    
      /* initialize the bhy chip */
      if(bhy_driver_init(&bhy1_fw))
      {
          DEBUG("Fail to init bhy\n");
          for(;;){}
      }
    
      /* Wait for IMU interrupt pin triggers. */
      while(Dev_IMU_CheckIntSignal());
      while(!Dev_IMU_CheckIntSignal());
    
      /* Enables a streaming sensor. The goal here is to generate data */
      /* in the fifo, not to read the sensor values. */
      int dbg;
      dbg = bhy_enable_virtual_sensor(VS_TYPE_ROTATION_VECTOR, VS_NON_WAKEUP, FIFO_SAMPLE_RATE, 1000, VS_FLUSH_NONE, 0, 0);
    
      /* empty the fifo for a first time. the interrupt does not contain sensor data */
      bhy_read_fifo(fifo, FIFO_SIZE, &bytes_read, &bytes_remaining);
    
      /* Sets the watermark level */
      bhy_set_fifo_water_mark(BHY_FIFO_WATER_MARK_NON_WAKEUP, 800);
    
    
      while (1)
      {
          /* Wait until IMU releases interrupt signal. */
          if(Dev_IMU_CheckIntSignal() || bytes_remaining)
          {
              bhy_read_fifo(fifo + bytes_left_in_fifo, FIFO_SIZE - bytes_left_in_fifo, &bytes_read, &bytes_remaining);
              bytes_read += bytes_left_in_fifo;
              fifoptr = fifo;
              packet_type = BHY_DATA_TYPE_PADDING;
    
              do
              {
                  /* this function will call callbacks that are registered */
                  result = bhy_parse_next_fifo_packet(&fifoptr, &bytes_read, &fifo_packet, &packet_type);
    
                  /* prints all the debug packets */
                  if (packet_type == BHY_DATA_TYPE_DEBUG)
                  {
                      bhy_print_debug_packet(&fifo_packet.data_debug, bhy_printf);
                  }
    
                  /* the logic here is that if doing a partial parsing of the fifo, then we should not parse  */
                  /* the last 18 bytes (max length of a packet) so that we don't try to parse an incomplete   */
                  /* packet */
              } while ((result == BHY_SUCCESS) && (bytes_read > (bytes_remaining ? 18 : 0)));
    
              bytes_left_in_fifo = 0;
    
              if (bytes_remaining)
              {
                  /* shifts the remaining bytes to the beginning of the buffer */
                  while (bytes_left_in_fifo < bytes_read)
                  {
                      fifo[bytes_left_in_fifo++] = *(fifoptr++);
                  }
              }
          }
    
          HAL_Delay(1);
      }

     

     

    Regards,

    Bae

     

    3 REPLIES 3

    BSTRobin
    Community Moderator
    Community Moderator

    Hello MintaeBae,

    You could try to use the way of reading interrupt register.

    while(!bhi160b_get_int_status());

    int bhi160b_get_int_status()
    {
    uint8_t value;

    bhy_read_reg(BHY_I2C_REG_INT_STATUS_ADDR, &value, 1);
    return(value&0x01);
    }

    It does not work.Always reads zero.

    BSTRobin
    Community Moderator
    Community Moderator

    Hello MintaeBae,

    I setup demo code with BHy1_driver_and_MCU_solution on STM32, it worked well.
    Please refer attached code.

    Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist