I concentrated on that last word of calibration parameters. So for my sensor under test the value of P9 is normally 6000(0x1770). Same as in datasheet example data. But when I get wrong pressure this is 1904(0x0770).
I tried to read the calibration data twise, read the P9 register separately, but it never changes as long as BMP280 has power. On power up that one bit is randomly picked and then it stays.
I am out of ideas how to fix this with SW. What is that P9 anyway? Can I assume that it should always be 6000? Or maybe (p9 mod 1000 == 0)? So that I would have means to try to detect the errors
Could you provide register value just before you test and get some data?
I'd like to check your BMP280 status.
I am not sure I understand what you mean. The test is to to power up the sensor and read calibration parameters. I can't really read them before I read them?
Anyway, I think I managed to resolve the symptoms although the root cause is still unknown.
In short: BMP280 is connected to 3.3V bus and there is also 1.8V bus/LDO on the board. This 1.8V bus discharges slowly. I noticed that if 1.8V LDO was on before the board was power cycled, there is still charge left on the 1.8V bus when BMP280 calibration parameters are read after power cycle. This somehow randomly corrupts the calibration data.
Workaround was to wait for 1.8V bus to go to 0V and read registers from BMP280 then.