Problem with analogwrite

I have a sketch that reads engine rpm and it works well.
I have added some if statements so as the rpm increases a pwm
increases i will use as an engine brake. I have done this way so I can
change the output at any particular point.
the problem I have is with the analogwrite on line 169 is it freezes when the rpm gets to 2400 rpm.
if I // that line the tacho works fine.
I have attached the code I have.
I am not overly experienced with Arduino so any help would be grateful.

Prop_2018_8.ino (6.44 KB)

analogWrite  (outputValue, Retarder_Pin);

The syntax for analogWrite() is

analogWrite(pin, value);

You have it backwards.

oops wrong way around
Thank you