MPU6050 calibration through registers

Hi,
I am using MPU-6050 without jrowberg’s library. I am interested only in the accelration values, and reading raw data. I can see that z axis is a bit off(~17700 instead of expected 16384 and want to correct it.
I saw in the datasheet that register 7E and 7D are responsible for Z’s offset values.
I wrote them some value but nothing happens, no offset is added.
What am I missing?
data sheet:

code(I’m using M5stickC):

#include <Wire.h>
#include <M5StickC.h>
signed int accelX, accelY, accelZ;
float gForceX, gForceY, gForceZ;
TwoWire I2Cone = TwoWire(0);

void setup() {
Serial.begin(115200);
I2Cone.begin(0,26,400000);
setupMPU();
M5_setup();
Serial.println(“Setup done”);
}

void loop() {
recordAccelRegisters();
printData();
}

void setOffsetAccelRegisters() {
I2Cone.beginTransmission(0x68);
I2Cone.write(0x7E);//Z-Axis initialization
I2Cone.write(-150);
I2Cone.endTransmission();

// I2Cone.beginTransmission(0x68);
// I2Cone.write(0x7F);//Z-Axis initialization
// I2Cone.write(0x00);
// I2Cone.endTransmission();

}
void M5_setup() {
M5.begin();
}

void setupMPU(){
I2Cone.beginTransmission(0x68); //This is the I2C address of the MPU (b1101000/b1101001 for AC0 low/high datasheet sec. 9.2)
I2Cone.write(0x6B); //Accessing the register 6B - Power Management (Sec. 4.28)
I2Cone.write(0x00); //Setting SLEEP register to 0. (Required; see Note on p. 9)
I2Cone.endTransmission();
I2Cone.beginTransmission(0x68); //I2C address of the MPU
I2Cone.write(0x1B); //Accessing the register 1B - Gyroscope Configuration (Sec. 4.4)
I2Cone.write(0x08); //Setting the gyro to full scale +/- 250deg./s
I2Cone.endTransmission();
I2Cone.beginTransmission(0x68); //I2C address of the MPU
I2Cone.write(0x1C); //Accessing the register 1C - Acccelerometer Configuration (Sec. 4.5)
I2Cone.write(0x00); //Setting the accel to +/- 2g
I2Cone.endTransmission();
setOffsetAccelRegisters();
}

void recordAccelRegisters() {
I2Cone.beginTransmission(0x68); //I2C address of the MPU
I2Cone.write(0x3B); //Starting register for Accel Readings
I2Cone.endTransmission();
I2Cone.requestFrom(0x68,6); //Request Accel Registers (3B - 40)
while(I2Cone.available() < 6);
accelX = I2Cone.read()<<8|I2Cone.read(); //Store first two bytes into accelX
accelY = I2Cone.read()<<8|I2Cone.read(); //Store middle two bytes into accelY
accelZ = I2Cone.read()<<8|I2Cone.read(); //Store last two bytes into accelZ
processAccelData();
}

void processAccelData(){
gForceX = accelX / 16384.0;
gForceY = accelY / 16384.0;
gForceZ = accelZ / 16384.0;
}

void printData() {
Serial.print(" Accel raw");
Serial.print(" X=");
Serial.print(accelX);
Serial.print(" Y=");
Serial.print(accelY);
Serial.print(" Z=");
Serial.println(accelZ);

}

Thanks.

Please edit your post to add code tags, as described in the "How to use this forum" post.

There is no reason to change the offset registers in the MPU6050. You can just add or subtract offsets from the raw readings. Or much better, calibrate the accelerometer by following this tutorial.