M2 12VIO Library Causing Lag Issues?

I have been running my M2 in my LT1 swapped Porsche for a while now to bridge the communication between the two systems. The issue I am having is using the 12VIO library. I am using it to create a PWM signal to simulate a VSS sensor for the GM side. It works great for that… as long as the vehicle is moving. The range of frequency is 2-1000hz using that. So my algo is setup such that, if vehicle speed drops below the equivalent of 2hz, I switch it off:

if (VSS <= 0.5 && (VSS_Stat == true)) {
M2IO.Setpin_12VIO(2, OFF);
VSS_Stat = false; //VSS is now off, set this false so we do not fall in this IF every time
}

Of course, I switch it back on later if vehicle speed increases again. When it switches off, it seems to cause the M2 to skip a beat. I drop CAN frames for a short period of time, which causes failure codes to set on the traction control module. The same does not happen when switching from Off to On.

Not sure if Tony Doust is still around making updates, or if anyone has any alternative solutions?

One idea I had was to set the frequency and duty cycles as low as possible, but this still registers a tiny vehicle speed. The ECM needs to see 0 speed at a stand still.

Measuring the CANbus, looks like it’s a 150ms long dropout after using the OFF function on that pin. There was a 5ms delay function in the M2_12VIO library, but that doesn’t account for this loss.

And with further testing… Seems like the issue is in the AnalogWrite function itself. I put time stamps in the code before and after that function and it takes 150ms to turn a pin to LOW or OFF. Seems odd?

One more update… Only occurs when turning off a PWM pin. Maybe this is a problem inherent with using PWM on the Due? Turning a 12v source on and off has no issues.