Memory Permission Error 0380174C

I am using vexCode text and keep getting a memory permission error everytime I upload my program. I tried everything I’ve seen in this forum from deleting the build file to checking variables and I can’t figure it out. Here is my code:

#include “vex.h”

using namespace vex;

void whenLimitSwitchIsPressed() {
frontLeftDriveMotor.stop();
frontRightDriveMotor.stop();
backLeftDriveMotor.stop();
backRightDriveMotor.stop();
}

int main() {
// Initializing Robot Configuration. DO NOT REMOVE!
vexcodeInit();

// Set velocities
frontLeftDriveMotor.setVelocity(30, velocityUnits::pct);
frontRightDriveMotor.setVelocity(30, velocityUnits::pct);
backLeftDriveMotor.setVelocity(30, velocityUnits::pct);
backRightDriveMotor.setVelocity(30, velocityUnits::pct);

// Move forward infinitely
frontLeftDriveMotor.spin(directionType::fwd);
frontRightDriveMotor.spin(directionType::fwd);
backLeftDriveMotor.spin(directionType::fwd);
backRightDriveMotor.spin(directionType::fwd);

// Stop driving when limit switch pressed
LimitSwitchE.pressed(whenLimitSwitchIsPressed);

//Pause
wait(0.5, seconds);

// Drive backward infinitely
frontLeftDriveMotor.spin(directionType::rev);
frontRightDriveMotor.spin(directionType::rev);
backLeftDriveMotor.spin(directionType::rev);
backRightDriveMotor.spin(directionType::rev);

}

I think the problem may be that you don’t have while(1) loop and your program prematurely exiting.

Could you try something like this:

#include “vex.h”

using namespace vex;

int main()
{
 // Initializing Robot Configuration. DO NOT REMOVE!
 vexcodeInit();

 // Set velocities
 frontLeftDriveMotor.setVelocity(30, velocityUnits::pct);
 frontRightDriveMotor.setVelocity(30, velocityUnits::pct);
 backLeftDriveMotor.setVelocity(30, velocityUnits::pct);
 backRightDriveMotor.setVelocity(30, velocityUnits::pct);

 // Move forward for 0.5 sec
 frontLeftDriveMotor.spin(directionType::fwd);
 frontRightDriveMotor.spin(directionType::fwd);
 backLeftDriveMotor.spin(directionType::fwd);
 backRightDriveMotor.spin(directionType::fwd);

 wait(0.5, seconds);

 // Drive backward until limit switch is pressed
 frontLeftDriveMotor.spin(directionType::rev);
 frontRightDriveMotor.spin(directionType::rev);
 backLeftDriveMotor.spin(directionType::rev);
 backRightDriveMotor.spin(directionType::rev);

 while(1)
 {
   // Stop driving when limit switch pressed
    if( LimitSwitchE.pressing() )
    {
       break; // exit the loop
    }

   //Pause
   wait(10, msec);
 }

 frontLeftDriveMotor.stop();
 frontRightDriveMotor.stop();
 backLeftDriveMotor.stop();
 backRightDriveMotor.stop();
}
1 Like

Thank you for the response. I tried your program and it came up with a new memory permission error. I think it is something in the formatting of my code because I tried a basic move forward line that I have used before and it came up with the error, I just can’t tell where I messed up in the formatting.

How do you initialize LimitSwitchE?

You may want to read this topic: Memory Permission Error

1 Like