Hi,
I have builded a circuit with a nRF52DK and a mpu9250 IMU. If I power the Sensor with VDD the Zephyr driver and all of the Software performs well and the values from the IMU are displayed correctly in my console.
Now I have Problems with powering the mpu sensor through the nRF's GPIOs. My first attempt is to set the GPIO_0 to HIGH and bind the mpu with a little delay. I think i had tenable and disable some driver for the TWI bus, but until now I have not found the right way. Maybe you can give me some advise.
nrf Connect SDK 1.9.1 - VSCode
const struct device *gpio_dev1; gpio_dev1 = device_get_binding("GPIO_0"); if (!gpio_dev1) { printk("Cannot find %s!\n", "GPIO_0"); return; } ret = gpio_pin_configure(gpio_dev1, VDD_PIN1, GPIO_OUTPUT_ACTIVE); if (ret < 0) { return; } gpio_pin_set(gpio_dev1, VDD_PIN1, 1); NRFX_DELAY_US(MEASURE_INTERVAL*1000); // 2 Seconds const char *const label = DT_LABEL(DT_INST(0, DEVICE_NAME_IMU)); //DEVICE_NAME_IMU = invensense_mpu9250 const struct device *mpu9250 = device_get_binding(label); if (!mpu9250) { printf("Failed to find sensor %s\n", label); //return; }else{ printk("Sensor connected: %s\n", label); }
Console Output:
[00:00:02.048,858] <inf> sdc_hci_driver: SoftDevice Controller build revision: 0e e7 c5 66 67 18 3c ac b3 d2 cc 81 a3 dc f1 c0 |...fg.<. ........ c0 36 02 22 |.6." [00:00:02.051,208] <inf> bt_hci_core: HW Platform: Nordic Semiconductor (0x0002) [00:00:02.051,208] <inf> bt_hci_core: HW Variant: nRF52x (0x0002) [00:00:02.051,208] <inf> bt_hci_core: Firmware: Standard Bluetooth controller (0x00) Version 14.50663 Build 1008232294 [00:00:02.052,124] <inf> bt_hci_core: Identity: EF:F0:9B:1E:C2:0B (random) [00:00:02.052,154] <inf> bt_hci_core: HCI: version 5.2 (0x0b) revision 0x12fe, manufacturer 0x0059 [00:00:02.052,154] <inf> bt_hci_core: LMP: version 5.2 (0x0b) subver 0x12fe [00:00:02.092,163] <err> i2c_nrfx_twi: Error 0x0BAE0001 occurred for message 0 [00:00:02.092,163] <err> MPU9250: Failed to read data sample. [0:00:04.102]:2942.578125 mV [0:00:04.117]:23.3 Cel [0:00:04.131]:1003 hPa sample fetch/get failed: -5 [0:00:04.136]:0 minutes ----------------------------------
(P.S.: After powering up the MPU with VDD and then switch the power source of the MPU&I2C Bus to the GPIO it works correctly - so it should not be to less power)