afry-south / dragonfly-fcb

ÅF Dragonfly Quadrotor UAV Project
Other
7 stars 3 forks source link

SensorValues task hangs after a while. #147

Closed superdupersvard closed 8 years ago

stenbergd commented 8 years ago

Was it due to the reason we discussed yesterday?

superdupersvard commented 8 years ago

The reason for bug was: timeSinceDrdy is calculated as HAL_GetTick() - lastDrdyTime. lastDrdyTime is updated in an ISR. So it can happen that we run GetTick to get the current SysTick. Right after this (and before we read lastDrdyTime) we get an interrupt to increase SysTick. Immediately after we get an interrupt for new sensor value and the lastDrdyTime will be updated to the new SysTick value. This will result an underflow when calculation of timeSinceDrdy is done.