Memory Permission Error V5 VexCode

I am getting a memory permission error anytime I try to upload this autonomous code to my robot. I updated to the latest version of VexCode Text last night so the program is up to date and all the hardware on the robot is also up to date. The program builds, but anytime it tries to actually download to the robot I get an error that says Memory Permission Error #038031B0. I am completely stumped on why this problem is being caused. Here is a copy of the section of the code that is causing issues. The error did not start showing up until I tried to code in a limit switch, so I am pretty sure the code for the limit switch is causing the issue, I just don’t know enough about coding a limit switch to find the error in the code.

// Program Limit Switch
void whenLimitSwitchIsPressed() {

// Pause
vex::task::sleep(50);

// Stop Drive Motors
FrontLeftDriveMotor.stop();
FrontRightDriveMotor.stop();
BackRightDriveMotor.stop();
BackLeftDriveMotor.stop();

// Close claw
ClawMotor1.rotateFor(1000, rotationUnits::deg, false);
ClawMotor2.rotateFor(-1000, rotationUnits::deg, false);
}

// START AUTONOMOUS
void autonomous(void) {

// Set speeds
FrontLeftDriveMotor.setVelocity(30, velocityUnits::pct);
FrontRightDriveMotor.setVelocity(30, velocityUnits::pct);
BackLeftDriveMotor.setVelocity(30, velocityUnits::pct);
BackRightDriveMotor.setVelocity(30, velocityUnits::pct);
ClawMotor1.setVelocity(75, velocityUnits::pct);
ClawMotor2.setVelocity(75, velocityUnits::pct);
ArmMotorRight.setVelocity(50, velocityUnits::pct);
ArmMotorLeft.setVelocity(50, velocityUnits::pct);

// Move forward
FrontLeftDriveMotor.rotateFor(2, rotationUnits::rev, false);
FrontRightDriveMotor.rotateFor(2, rotationUnits::rev, false);
BackLeftDriveMotor.rotateFor(2, rotationUnits::rev, false);
BackRightDriveMotor.rotateFor(2, rotationUnits::rev);

LimitSwitchA.pressed(whenLimitSwitchIsPressed);
}

see this


you are probably using Brain.ThreeWirePort before it’s been created.

2 Likes

I am still a bit confused on the syntax I would use in my particular case. I am new to programming vex this year so I am having a difficult time understanding how to look at a gyro code and make it into a limit switch code.