'Arduino MEGA configurable PORT manipulation fails when PIN is volatile int

I have a project in Arduino Mega where i want the user to be able to configure the output pins for XYZE axes of a motion controller from a Python GUI. I am using direct port manipulation for fast pin toggling and in order to define each PORT and PIN i am using variables for both. So far i am experimenting only at Arduino side.

PORTS:

volatile uint8_t *PORTX_STEP;
volatile uint8_t *PORTX_DIR;
volatile uint8_t *PORTY_STEP;
volatile uint8_t *PORTY_DIR;
volatile uint8_t *PORTZ_STEP;
volatile uint8_t *PORTZ_DIR;
volatile uint8_t *PORTE_STEP; 
volatile uint8_t *PORTE_DIR;

.....

void configure_output(){
   PORTX_STEP = &PORTF;
   PORTY_STEP = &PORTF;
   PORTX_DIR = &PORTF;
   PORTY_DIR = &PORTF;
   PORTZ_STEP = &PORTL;
   PORTZ_DIR = &PORTL;
   PORTE_STEP = &PORTA; 
   PORTE_DIR = &PORTA;
}

....

void setup(){
   configure_output();
}

....

void service_routine(){  /// **Timer interrupt routine** bitRead(buffer1.byte_1[j],0) = 0 or 1 
   *PORTX_DIR = *PORTX_DIR | (bitRead(buffer1.byte_1[j],0)<<XDIR);
   *PORTX_STEP = *PORTX_STEP | (bitRead(buffer1.byte_1[j],1)<<XSTEP);
   *PORTY_DIR = *PORTY_DIR | (bitRead(buffer1.byte_1[j],2)<<YDIR); 
   *PORTY_STEP = *PORTY_STEP | (bitRead(buffer1.byte_1[j],3)<<YSTEP);
   *PORTZ_DIR = *PORTZ_DIR | (bitRead(buffer1.byte_1[j],4)<<ZDIR);
   *PORTZ_STEP = *PORTZ_STEP | (bitRead(buffer1.byte_1[j],5)<<ZSTEP);
   *PORTE_DIR = *PORTE_DIR | (bitRead(buffer1.byte_1[j],6)<<EDIR);
   *PORTE_STEP = *PORTE_STEP | (bitRead(buffer1.byte_1[j],7)<<ESTEP);
}

While PORT configuration works something stange happens when configure PINs

This works:

int XSTEP=0;//PF0
int YSTEP=6;//PF6
int ZSTEP=3;//PL3
int ESTEP=4;//PA4
int XDIR=1;//PF1
int YDIR=7;//PF7
int ZDIR=1;//PL1
int EDIR=6;//PA6`

while this NOT:

 volatile int XSTEP=0;//PF0
 volatile int YSTEP=6;//PF6
 volatile int ZSTEP=3;//PL3
 volatile int ESTEP=4;//PA4
 volatile int XDIR=1;//PF1
 volatile int YDIR=7;//PF7
 volatile int ZDIR=1;//PL1
 volatile int EDIR=6;//PA6

Link to full source code: github

Any ideas?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source