What would cause an engine to make a loud knocking sound once every 3 seconds while in park or neutral?

The failure to step on the brake pedal

or if manual the failure to step on the clutch

The transmission or gearbox is not working properly