2 Sensor调试常见问题

2.1 Lcpu中的I2C5上添加了一个Gsensor驱动方法

a, 请Create a directory under SDK\rtos\rtthread\bsp\sifli\peripherals\ by referring to other Gsensor directories;,比如:
Copy and create the directory: stk8321, and modify the macro group = DefineGroup('Drivers', src, depend = ['ACC_USING_STK8321'], CPPPATH = CPPPATH), in the corresponding SConscript file;
The macro ACC_USING_STK8321 depends on the Kconfig configuration in lcpu’s menuconfig, which needs to be added by referring to other peripherals;.

b, Enable the Gsensor device and I2C5 in the lcpu project’s menuconfig;, RTOS On-chip Peripheral Drivers Enable I2C BUS-> Enable I2C5 BUS
To confirm whether the configuration is correct, check if the following exists in rtconfig.h under the corresponding lcpu project directory;

#define ACC_USING_STK8321
#define STK8321_BUS_NAME "i2c5
#define RT_USING_I2C
#define BSP_USING_I2C
#define BSP_USING_I2C4"

c,Please confirm whether the I2C configuration in pinmux.c is for I2C function and pull-up status;.

    HAL_PIN_Set(PAD_PB43, I2C5_SCL, PIN_PULLUP, 0);               //i2c5
    HAL_PIN_Set(PAD_PB44, I2C5_SDA, PIN_PULLUP, 0);

d,The I2C peripheral has been encapsulated into a standard rt_thread I2C devices device. You can check the usage of the I2C device on the rt_thread official website;:
可以参考I2C总线设备 (rt-thread.org),官方文档:

alt text

e,If the log from lcpu indicates that I2C cannot read the device ID;,
请依次排查:
Test the power supply and working conditions of I2C, including RESET, LDO_ON and other timing;,
Then use an oscilloscope or logic analyzer to check whether the read/write waveforms output by I2C meet the device expectations, whether the I2C device address is normal, and whether there is an ACK;,
f,You can customize msh commands to test whether the Gsensor is working properly;
详细可以参考rtthread官网文档:FinSH 控制台 (rt-thread.org)

alt text

2.2 After the system enters sleep mode, the Sensor may not trigger GPIO interrupts;

根本原因:
The wake-up pulse width provided by the heart rate sensor is up to 32us, with a small pulse width. After the system enters sleep mode and uses a 32kHz frequency, AON cannot guarantee stable detection;

alt text

解决方法:
Modify the peripheral’s registers or firmware so that the interrupt pulse width is greater than the clock cycle, and the pulse width should be at least greater than 125us under the RC10K oscillator;,常见FAQ中断章节