- 
                Notifications
    
You must be signed in to change notification settings  - Fork 37
 
Description
Hello!
I have an interesting problem. I tried to port the driver onto STM32 board. I rewrote the mlx90640_i2c_driver.
With my code, I can dump calibration data, then extract the parameters, and them seem correct. But the "MLX90640_GetFrameData" always stuck in a while loop, because the status register's data ready bit will never be 1.
	paramsMLX90640 sensor_params;
	static uint16_t eeData[832];
	static uint16_t mlx90640Frame[834];
	static float32_t pixels[768];
	HAL_Delay(5000);
//Tried with another resolution, refresh-rate too
	MLX90640_DumpEE(MLX90640_ADDR,eeData);
	MLX90640_ExtractParameters(eeData,&sensor_params);
	MLX90640_GetFrameData(MLX90640_ADDR,mlx90640Frame);    // stuck here
	MLX90640_CalculateTo(mlx90640Frame,&sensor_params,1,1,pixels);In debug mode I can clearly see that the status register is always 0x0900.
I tried to solve it with direct register writings:
//initializations etc...
	if(StartMeasTempSensor() != 0){
		Error_Handler();
	}
	HAL_Delay(5000);
	while(!CheckTempSensor()){ }      // stuck here
int StartMeasTempSensor(){
	uint16_t status_register;
	uint16_t control_register;
	int error  = 0;
	//Set control register
	error += MLX90640_I2CRead(MLX90640_ADDR,0x800D,1,&control_register);
	control_register = (control_register & 0xE000) | 0x1901;
	error += MLX90640_I2CWrite(MLX90640_ADDR,0x800D,control_register);
	//Set status register
	error += MLX90640_I2CRead(MLX90640_ADDR,0x8000,1,&status_register);
	status_register = (status_register & 0xFFC0) | 0x0030;
	MLX90640_I2CWrite(MLX90640_ADDR,0x8000,status_register);
	return error;
}
int CheckTempSensor(){
	uint16_t status_register;
	uint16_t control_register;
	MLX90640_I2CRead(MLX90640_ADDR,0x800D,1,&control_register);
	MLX90640_I2CRead(MLX90640_ADDR,0x8000,1,&status_register);
	//Data ready
	if((status_register & 0x0008) > 0){
		return 1;
	}
	else{
		if((status_register & 0x0020) == 0){
			status_register = (status_register & 0xFFC0) | 0x0020;
			MLX90640_I2CWrite(MLX90640_ADDR,0x8000,status_register);
		}
		return 0;
	}
}I noticed another interesting thing, if I write the control register, I can read back the correct value (e.g. 0x1901), so I think I2C communication is OK.  But if I write the status register (e.g. 0x0930), I always read back 0x0900.
I have two senors, but both produce this (error).
Do you have any idea?
Thanks
Edit:
If I write 0x0901 to control register, i read out 0x0800 from the status register, I don't write to the status register, but new data never comes.