2022-12-07 12:27 PM
I am trying to read data from a sensor in the background(using DMA) using I2C. Below the I2C DMA settings on CubeMX. The problem is that it shows a frozen measurement on the debug window although in the blocking mode the measurement floats all the time. Which setting I could have missed?
void QMC7983_read_temp (void){
uint8_t status_flag = 0xFF;
uint8_t raw_temp_data[2];
HAL_I2C_Mem_Read_DMA (&hi2c1, QMC7983_ADDR,STATUS_REG_1,1, &status_flag, 1);
if((status_flag & 1U>>0)!=1)
while(1){}
HAL_I2C_Mem_Read_DMA (&hi2c1, QMC7983_ADDR,TOUT_LSB_REG,1,raw_temp_data, 2);
temp_meas = (int16_t)(raw_temp_data[1]<<8 |raw_temp_data[0])/100.0;
}
int main(void)
{
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
MX_DMA_Init();
MX_TIM1_Init();
MX_I2C1_Init();
MX_ADC1_Init();
QMC7983_config();
HAL_Delay(100);
QMC7983_read_temp ();
while (1)
{
}
}
2022-12-07 04:09 PM
> HAL_I2C_Mem_Read_DMA (&hi2c1, QMC7983_ADDR,STATUS_REG_1,1, &status_flag, 1);
> if((status_flag & 1U>>0)!=1)
Use blocking mode (non-DMA) or wait for the call to complete before using the data that it populates.
> The problem is that it shows a frozen measurement on the debug window although in the blocking mode the measurement floats all the time
What does this mean exactly? measurement floats? shows a frozen measurement?
2022-12-08 02:32 AM
by frozen I mean the measurement is stuck, as if it reads only one measurement(fixed) no matter if a heat the sensor a little bit.
Float means that the measurement changes constantly in the debugging window(but around a specific reference value)
2022-12-08 02:34 AM
wait for the call to complete
What do you mean by this?