ARM 8-bit to AVR 32-bit translation NEED Help!

I need help, who knows how to translate a code from the ARM to AVR. I need a 32bit code for DUE

This is code for encoder drive stepper motor. Code is arm 8bit, but need for AVR32 bit. Thanks

#define encoder_a 22 
#define encoder_b 23 
#define motor_step 53
#define motor_direction 52

volatile long motor_position, encoder;

void setup () {
  pinMode(motor_step, OUTPUT);
  pinMode(motor_direction, OUTPUT);
  
  pinMode(encoder_a, INPUT);
  pinMode(encoder_b, INPUT);
  digitalWrite(encoder_a, HIGH); 
  digitalWrite(encoder_b, HIGH); 
  
  attachInterrupt(22, encoderPinChangeA, CHANGE);
  attachInterrupt(23, encoderPinChangeB, CHANGE);
  encoder = 0; 
}

void loop() {
  if (encoder > 0) {
    digitalWrite(motor_direction, HIGH);
    digitalWrite(motor_step, HIGH);
    digitalWrite(motor_step, LOW);
    delayMicroseconds(600);
    motor_position++;
    encoder = 0; 
  }
  else if (encoder < 0) {
    digitalWrite (motor_direction, LOW); 
    digitalWrite (motor_step, HIGH);
    digitalWrite (motor_step, LOW);
    delayMicroseconds(600);
    motor_position--;
    encoder = 0; 
  }
}

void encoderPinChangeA() {
  if (digitalRead(encoder_a)==digitalRead(encoder_b)) {
    encoder--;
  }
  else{
      encoder++;
  }
}

void encoderPinChangeB() {
  if (digitalRead(encoder_a) != digitalRead(encoder_b)) {
    encoder--;
  }
  else {
    encoder++;
  }
 }

That is perfectly standard C code, which looks like it would compile using the Arduino IDE. You will need to change the pin configurations and software details for the particular hardware you are using, which you did not describe.

My code works for arduino DUE and I have a pin configured correctly. I have a problem with the step pulse. The program we slow pulse generated by a stepper motor so I need 32bit code. I do not know how to change.
My program is Arduino 1.5.6. r2

Describe the problem you are having.

Why do you think you need "32 bit code"?

When the encoder quickly turn the output of the step pulse losing the signal. When I measure with an oscilloscope signals running out and the stepper motor is turning slowly, although it should suddenly. So I think there is a problem in the functioning of the program.
I tested on Arduino Mini Pro 16MHz I used the CODE for direct manipulation port as well as I could solve the problem. That's why I bought an Arduino DUE with 32bit 84Mhz also does not work correctly for this code. So I just left it to program in 32bit mode.
This problem occurs only if the encoder speed turns. If you slowly turn the motor correctly rotates

What is not anyone who could help me. What's so complicated :fearful:

What's so complicated

If it was easy, you could do it.

What are you sending the step pulses to? Why do you have to delay for ANY length of time after telling the motor to step, before you increment the position you think the motor is at?

as the variables - motor_position, encoder - are more than one byte you should use

nointerrupts();
interrupts();

around the code where you read them in the main loop as the interrupt may change them halfway a read.

I do not get to answer, you can more precisely explain the. Thanks.