Problem with rangefinder

Hey everyone! I am trying to get my rangefinder working for terrain following with a tf mini and pixhawk 4. I can read the values but the drone is not following the terrain in guided mode. Can you help me? Here is the parameters I have: TERRAIN_ENABLE= 1 , EK2_ALT_SOURCE=0 EK2_RNG_USE_HGT=-1
SERIAL4_ PROTOCOl=9, SERIAL4_BAUD=115
RNGFND1_TYPE=20
RNGFND1_MIN_CM=30
RNGFND1_MAX_CM=1000
RNGFND1_GNDCLEAR=10

hello!
There is nothing wrong with your settings, just in auto mode guided mode , terrain following flight is not effective! In AltHold, PosHold ,Loiter effective, you can change height source is rangefinder EK2_ALT_SOURCE : 2

However, this is dangerous, the ground height can not exceed the travel, beyond the sensor travel will change the altitude source, switching baro or Rangefinder, the aircraft will rise or fall sharply.