Calibrating CMPS03 compass module

Hi all,

I have a Devantech CMPS03 compass module.
Initially was accurate without calibration but then lost calibration without any known reason.

I can read data (firmware revison, heading in 1-byte and 2-byte mode) without problems. I am using a Rev.Ed. PICAXE 40X1 PIC based microcontroller.

To calibrate one must write the value 255 ($FF) to register 4 times.
Each time it is cleared and then you move to next cardinal point and write 255 again into register.
Pin 5 is normally high but goes low during the calibration period until all 4 cardinal points have been logged by the calibration then pin 5 returns high.

If I modify my calibration program and read register 15 initially it is 0. Then when I write the value 255 to register 15, if I read back I see 255 but it is never cleared and pin 5 never goes low. :mad:

I have finally tried calibration by the manual method with a switch on pin 6 and that has worked. :slight_smile:

So my question is:
has anyone here managed to calibrate a CMPS03 using software and the i2c bus?

If so would appreciate a copy of your i2c based calibration code.