A scanning probe microscope capable of preventing contact between the
probe and a sample and a method of operating this microscope. The
scanning probe microscope measures the topography of a surface of the
sample by scanning the probe relative to the surface of the sample. A
scanning reference position in the heightwise direction is updated in
response to a maximum value of the height of the surface of the sample on
the scan lines scanned so far. A limit value is set for motion of the
probe in the heightwise direction relative to the scanning reference
position. After the update, the next scan line is scanned. In this way,
scanning is carried out along the successive scan lines.