MPU6050+BMP180 causes system lockup - Raspberry Pi Forums


i trying write flight control program quadcopter, , code can found on https://github.com/sgsdxzy/adc
10dof sensor board gy87, consists of 3 i2c devices: mpu6050, hmc5883l , bmp180(same api bmp085). use i2cdevlib , pigpio data sensors.
mpu6050 can use i2c slaves, , set hmc5883l slave. got dmp running. mpu6050 can generate interrupt when dmp data ready , send data fifo. wired interrupt gpio, , used pigpio's gpiosetalertfunc() monitor it's status. if interrupt generated, program read fifo , dmp data, write them (thread-safe) global variables. alone working well.
bmp180 relatively simpler device, set register change mode , wait time, read other registers results. alone working too.
however, when combined two, random system lockup occured: set interrupt handler, enter loop: every 0.1s set bmp180 measure , it's data, print global variables on screen; mpu6050 generate 100 interrupts per second , program handled them in time, every 0.1s latest data. works quite correct results several loops, @ random point program stucks, , top shows it's using 2 cores.
remove either
1) interrupt handling
2) or measure of bmp180 in every loop
, program run flawlessly , tested can ran stable @ least half hour.
combining 2 stuck using processor power, either after 10 seconds or 1 minute.
can't understand why, point out what's wrong? or @ least teach me how debug causes lockup (using tool, lockup happens @ random point , there many procedures, using gdb run program step-by-step isn't option)
in advance.

all right, found out i2cdevlib not thread-safe, , caused problem.

i2cdevlib's api far pigpio, porting these codes pure pigpio not trival. pthread mutex let 1 thread access i2c @ same time.


raspberrypi



Comments

Popular posts from this blog

Connecting Raspberry Pi 2 to P10(1R)-V706 LED Dot Matrix - Raspberry Pi Forums

TypeError: <unknown> is not a numpy array - Raspberry Pi Forums

datso and removing imagetitle - Joomla! Forum - community, help and support