Possible Causes ……
Defective Knock Sensor Considering you’ve replace this and still having the issue
Broken or frayed wires that connects to the sensor circuit C onsidering you’ve apparently tested this and still have the issue
That would lead to possibly one of these …..
Faulty EGR (Exhaust Gas Recirculation) system
Lean air-fuel ratio
Defective cooling system