melexis / MLX90621-library

Library functions for MLX90621
Apache License 2.0
4 stars 6 forks source link

MLX90621_SetRefreshRate erase all other bit #5

Open Olfox59 opened 4 years ago

Olfox59 commented 4 years ago

Hi,

Thanks for the driver.

But i updated my previous driver with this one. The probleme is that when I use SetRefreshRate, it clear all the bit, even POR bit. As i check this bit to know if i need to reprogram oscillator via Configure. It always do it as the bit as been cleared . So idea should be to read configuration, do an OR with refresh rate and write register . I did it and check is working :

` int MLX90621_SetRefreshRate(uint8_t refreshRate) { uint16_t cfgReg; int value; int error; confReg test;

//value = refreshRate & 0x0F;

error = MLX90621_GetConfiguration(&cfgReg);

if(error == 0)
{

    value = (cfgReg & 0xfff0) | (refreshRate & 0x0F);
    //value = (cfgReg & 0x000F) | value;
    error = MLX90621_I2CWrite(0x60, 0x03, 0x55, value);        
}    

return error;

}`

slavysis commented 4 years ago

Indeed - using wrong mask value (000F instead of FFF0). It is fixed in the latest commit. Thanks a lot for the feedback!

Best regards