6378 views|0 replies

9721

Posts

24

Resources
The OP
 

lps22hb (IV) DRDY interrupt usage [Copy link]

 There are two ways for the LPS22HB pressure sensor to determine whether the data is ready after starting the conversion. One is to read the STATUS (27h) register to determine whether T_DA and P_DA are 1
This is a passive method, which requires the microcontroller to continuously read and judge, which wastes processor resources and will also have a certain delay
Another method is to use the interrupt pin of the sensor. After the data is good, the sensor notifies the processor to read and process the data by changing the level of the interrupt pin
In this way, the processor can handle other things before triggering the interrupt, or enter the power-down state, which can save processor resources and reduce power consumption
LPS22HB has an INT_DRDY (Interrupt or Data Ready) pin, on PIN7 of the chip, is used to notify the processor to handle the corresponding interrupt
, including the DRDY interrupt function
336896[/attach]
BlueCoinThe evaluation board connects this pin to the PB3 pin of the STM32F446
336897[/attach]
To use the Interrupt or Data Ready function, you need to configure the DRDY bit of the sensor's CTRL_REG3 (12h) register to 1 and enable the DRDY function.
The following measures the maximum Pressure output data rate of LPS22HB by interrupting the DRDY state of the sensor received by the PB3 pin of the STM32F446.
The data sheet shows that LPS22HB supports 1Hz, 10Hz, 25 Hz, 50 Hz and 75 Hz several rates
Add a flag drdy_flag
Configure the interrupt function of PB3 of STM32F446
After triggering the rising edge interrupt, change drdy_flag to 1
Add a function enable_drdy to enable DRDY, and set the DRDY bit of the CTRL_REG3 (12h) register to 1 in the function
Here just directly set CTRL_REG3 (12h) register, which is equivalent to all the data of CTRL_REG3 (12h) except DRDY being 0
If you need to configure other bits of CTRL_REG3 (12h), you usually need to read the data of CTRL_REG3 (12h) before writing, then modify the DRDY bit, and then write the data back
This ensures that other configured bits will not be modified. This method is used in the official driver
336902[/attach]
Continued from the previous post
Use the one_shot method to read data and see how long it takes for LPS22HB to convert data once
The original data is readSTATUS (27h) The code for judging the data readiness of the register is changed to judging the drdy_flag flag. Before enabling ONE_SHOT, set drdy_flag to 0. Before reading the pressure and temperature, wait for drdy_flag to be set to 1 by the rising edge interrupt of the PB3 pin. 336903
The BlueCoinevaluation board is highly integrated, so it is impossible to use an oscilloscope to measure the line from PIN7 of LPS22HB to PB3 pin of STM32F446
You can modify the state of a GPIO in the HAL_GPIO_EXTI_Callback interrupt, and then use an oscilloscope to measure the GPIO to determine the DRDY trigger timing
Here we use a pin PD7 in BlueCoin to control the LED. When DRDY is triggered, change PD7 to 1
Set PD7 to 0 before executing ONE_SHOT
The one_shot function is executed in a loop, and PD7 is measured with an oscilloscope to obtain the following waveform
The time from setting PD7 to 0 to PD7 being modified to 1 by the DRDY interrupt is 13.2ms, and the corresponding rate is 75.8Hz
Because an I2C communication is executed after PD7 is set to 0 to enable the ONE_SHOT interrupt, the actual conversion time should be less than 13.2ms
which is basically the same as the maximum ODR of 75Hz in the data sheet
2ms is basically the same as the maximum ODR of 75Hz in the data sheet
336906[/attach]
2ms is basically the same as the maximum ODR of 75Hz in the data sheet
336906[/attach]


image001.png (23.6 KB, downloads: 0)

image001.png

image002.png (25.58 KB, downloads: 0)

image002.png

image007.png (6.47 KB, downloads: 0)

image007.png

image008.png (14.03 KB, downloads: 0)

image008.png
This post is from MEMS sensors
Personal signature虾扯蛋,蛋扯虾,虾扯蛋扯虾
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list