Memory Permission Error: 03802550

Im having an error on the brain of my robot, and I am unsure what the issue is. I just updated the brain and the issue is now popping up.

Here is my code.

/*----------------------------------------------------------------------------*/
/*                                                                            */
/*    Module:       main.cpp                                                  */
/*    Author:       VEX                                                       */
/*    Created:      Thu Sep 26 2019                                           */
/*    Description:  Competition Template                                      */
/*                                                                            */
/*----------------------------------------------------------------------------*/

// ---- START VEXCODE CONFIGURED DEVICES ----
// Robot Configuration:
// [Name]               [Type]        [Port(s)]
// ---- END VEXCODE CONFIGURED DEVICES ----

#define _USE_MATH_DEFINES
 
#include <cmath>
#include <math.h>
#include <algorithm>
#include <iostream>
#include "vex.h"

using namespace vex;

// A global instance of competition
competition Competition;

// define your global instances of motors and other devices here

controller Controller1 = controller(primary);
motor lF = motor(PORT11, ratio6_1, false);
motor lM = motor(PORT16, ratio6_1,true);
motor lB = motor(PORT17, ratio6_1, false);
motor rF = motor(PORT18, ratio6_1, true);
motor rM = motor(PORT19, ratio6_1,false);
motor rB = motor(PORT20, ratio6_1, true);
motor_group lefts = motor_group(lF,lB,lM);
motor_group rights = motor_group(rF,rB,rM);
drivetrain all = drivetrain(lefts,rights);


motor intake = motor(PORT16, ratio6_1  ,false);
motor uptake = motor(PORT2, ratio6_1,false);  
motor_group Donut = motor_group(intake, uptake);

motor lift = motor(PORT1,ratio36_1,false);


encoder leftTrack = encoder(Brain.ThreeWirePort.A);
encoder rightTrack = encoder(Brain.ThreeWirePort.C);

digital_out pistonA = digital_out(Brain.ThreeWirePort.G);
digital_out pistonB = digital_out(Brain.ThreeWirePort.B);





/*---------------------------------------------------------------------------*/
/*                          Pre-Autonomous Functions                         */
/*                                                                           */
/*  You may want to perform some actions before the competition starts.      */
/*  Do them in the following function.  You must return from this function   */
/*  or the autonomous and usercontrol tasks will not be started.  This       */
/*  function is only called once after the V5 has been powered on and        */
/*  not every time that the robot is disabled.                               */
/*---------------------------------------------------------------------------*/

void pre_auton() {
  // Initializing Robot Configuration. DO NOT REMOVE!
  vexcodeInit();

  
  
  // All activities that occur before the competition starts
  // Example: clearing encoders, setting servo positions, ...
}

/*--------------------------------''/-------------------------------------------*/
/*                                                                           */
/*                              Autonomous Task                              */
/*                                                                           */
/*  This task is used to control your robot during the autonomous phase of   */
/*  a VEX Competition.                                                       */
/*                                                                           */
/*  You must modify the code to add your own robot specific commands here.   */
/*---------------------------------------------------------------------------*/

void closer(void)
  {
 
      
  }

void far(void)
  {
    
      
  }

void skills(void)
  {
    
  }
void autonomous(void) 
{
 
  
}

/*---------------------------------------------------------------------------*/
/*                                                                           */
/*                              User Control Task                            */
/*                                                                           */
/*  This task is used to control your robot during the user control phase of */
/*  a VEX Competition.                                                       */
/*                                                                           */
/*  You must modify the code to add your own robot specific commands here.   */
/*---------------------------------------------------------------------------*/

void usercontrol(void) {
  // User control code here, inside the loop
  float speed;
  float turns;


  lift.setStopping(hold);
  lift.setMaxTorque(200,  percent);
   
  
  bool a;

  bool toggle = false;
  while (1) {
    turns = Controller1.Axis1.position();
    speed = Controller1.Axis3.position();
    
    a = Controller1.ButtonA.pressing();
    //Drivetraain
    lefts.setVelocity(2*(speed+ turns ), percent);
    rights.setVelocity(2*(speed - turns ), percent);
    
    lefts.spin(forward);
    rights.spin(forward);
  
    //lift
    if(Controller1.ButtonR1.pressing() && !(Controller1.ButtonR2.pressing()))
      {
        Donut.spin(forward);
      }

    if(!(Controller1.ButtonR1.pressing()) && Controller1.ButtonR2.pressing())
      {
        Donut.spin(reverse);
      }

    if(!(Controller1.ButtonR1.pressing()) && !(Controller1.ButtonR2.pressing()))
      {
        
        Donut.stop();
      }


    if(Controller1.ButtonL1.pressing() && !(Controller1.ButtonL2.pressing()))
      {
        lift.spin(forward);
      }

    if(!(Controller1.ButtonL1.pressing()) && Controller1.ButtonL2.pressing())
      {
        lift.spin(reverse);
      }

    if(!(Controller1.ButtonL1.pressing()) && !(Controller1.ButtonL2.pressing()))
      {
        
        lift.stop();
      }

    if(Controller1.ButtonA.pressing())
      {
        toggle = true;
      }
    if(Controller1.ButtonB.pressing())
      {
        toggle = false;
      }
    
    pistonA = toggle;
    pistonB = toggle;

 
  



    
    
    wait(20, msec); // Sleep the task for a short amount of time to
                    // prevent wasted resources.
  }
}

//
// Main will set up the competition functions and callbacks.
//
int main() {
  // Set up callbacks for autonomous and driver control periods.
  Competition.autonomous(autonomous);
  Competition.drivercontrol(usercontrol);

  // Run the pre-autonomous function.
  pre_auton();

  // Prevent main from exiting with an infinite loop.
  while (true) {
    wait(100, msec);
  }
}

Usual problem, you are probably using Brain.ThreeWirePort before it has been created, search the forum and you will find several topics with the solution.

6 Likes

Brain is not defined anywhere

3 Likes

Lucky for you, you are including "vex.h" (that defines things such as Brain) and using namespace vex (allowing it to be used as Brain instead of vex::Brain).