TMC2130 stepper driver with NEMA 17, and SSC I2C pressure sensor

Hello everyone,
I am going to control the stepper motor with a pressure sensor. for example, when the pressure reaches a specific amount, the motor stops rotation.
I have a code for running the NEMA17 stepper motor with TMC 2130 (SPI communication).
Also, I have a code to read the sensors.

Both are working well. However, when I combine the two codes to control the motor based on the measures of the sensor, the motor is mostly locked. with some specific delay and microsteps, it hardly turns.

I attached one of the combined code I wrote based on the information in various websites.
Thank you in advance for your help.

// ______________________Pressure sensor definition___________________
#include "Wire.h"
#include <Arduino.h>

#define SSCDANN100PG5A5_I2C 0x58 // each I2C object has a unique bus address, the DS1307 is 0x68
#define OUTPUT_MIN 1638.4        // 1638 counts (10% of 2^14 counts or 0x0666)
#define OUTPUT_MAX 14745.6       // 14745 counts (90% of 2^14 counts or 0x3999)
#define PRESSURE_MIN 0        // 
#define PRESSURE_MAX 100   //PSI 
//_____________________Stepper motor definitoin and pressure sensor set up______________________
#include <SPI.h>

#define EN_PIN    7 //enable (CFG6)
#define DIR_PIN   8 //direction
#define STEP_PIN  9 //step

#define CS_PIN   10 //CS chip select
#define MOSI_PIN 11 //SDI/MOSI (ICSP: 4, Uno: 11, Mega: 51)
#define MISO_PIN 12 //SDO/MISO (ICSP: 1, Uno: 12, Mega: 50)
#define SCK_PIN  13 //CLK/SCK  (ICSP: 3, Uno: 13, Mega: 52)

//TMC2130 registers
#define WRITE_FLAG     (1<<7) //write flag
#define READ_FLAG      (0<<7) //read flag
#define REG_GCONF      0x00
#define REG_GSTAT      0x01
#define REG_IHOLD_IRUN 0x10
#define REG_CHOPCONF   0x6C
#define REG_COOLCONF   0x6D
#define REG_DCCTRL     0x6E
#define REG_DRVSTATUS  0x6F

uint8_t tmc_write(uint8_t cmd, uint32_t data)
{
  uint8_t s;

  digitalWrite(CS_PIN, LOW);

  s = SPI.transfer(cmd);
  SPI.transfer((data>>24UL)&0xFF)&0xFF;
  SPI.transfer((data>>16UL)&0xFF)&0xFF;
  SPI.transfer((data>> 8UL)&0xFF)&0xFF;
  SPI.transfer((data>> 0UL)&0xFF)&0xFF;

  digitalWrite(CS_PIN, HIGH);
  return s;
}

uint8_t tmc_read(uint8_t cmd, uint32_t *data)
{
  uint8_t s;

  tmc_write(cmd, 0UL); //set read address

  digitalWrite(CS_PIN, LOW);

  s = SPI.transfer(cmd);
  *data  = SPI.transfer(0x00)&0xFF;
  *data <<=8;
  *data |= SPI.transfer(0x00)&0xFF;
  *data <<=8;
  *data |= SPI.transfer(0x00)&0xFF;
  *data <<=8;
  *data |= SPI.transfer(0x00)&0xFF;

  digitalWrite(CS_PIN, HIGH);

  return s;
}

void setup()
{
  //set pins
  pinMode(EN_PIN, OUTPUT);
  digitalWrite(EN_PIN, LOW); //deactivate driver (LOW active)
  pinMode(DIR_PIN, OUTPUT);
  digitalWrite(DIR_PIN,HIGH); //LOW or HIGH
  pinMode(STEP_PIN, OUTPUT);
  digitalWrite(STEP_PIN, LOW);

  pinMode(CS_PIN, OUTPUT);
  digitalWrite(CS_PIN, HIGH);
  pinMode(MOSI_PIN, OUTPUT);
  digitalWrite(MOSI_PIN, LOW);
  pinMode(MISO_PIN, INPUT);
  digitalWrite(MISO_PIN, HIGH);
  pinMode(SCK_PIN, OUTPUT);
  digitalWrite(SCK_PIN, LOW);

  //init serial port
  Serial.begin(9600); //init serial port and set baudrate
  while(!Serial); //wait for serial port to connect (needed for Leonardo only)
  Serial.println("\nStart...");

  //init SPI
  SPI.begin();
  //SPI.setDataMode(SPI_MODE3); //SPI Mode 3
  //SPI.setBitOrder(MSBFIRST); //MSB first
  //SPI.setClockDivider(SPI_CLOCK_DIV128); //clk=Fcpu/128
  SPI.beginTransaction(SPISettings(1000000UL, MSBFIRST, SPI_MODE3));

  //set TMC2130 config
  tmc_write(WRITE_FLAG|REG_GCONF,      0x00000001UL); //voltage on AIN is current reference
  tmc_write(WRITE_FLAG|REG_IHOLD_IRUN, 0x00001010UL); //IHOLD=0x10, IRUN=0x10
  tmc_write(WRITE_FLAG|REG_CHOPCONF,   0x00008008UL); //native 256 microsteps, MRES=0, TBL=1=24, TOFF=8
  //tmc_write(WRITE_FLAG|REG_CHOPCONF,   0x01008008UL); //128 microsteps, MRES=0, TBL=1=24, TOFF=8
  //tmc_write(WRITE_FLAG|REG_CHOPCONF,   0x02008008UL); // 64 microsteps, MRES=0, TBL=1=24, TOFF=8
  //tmc_write(WRITE_FLAG|REG_CHOPCONF,   0x03008008UL); // 32 microsteps, MRES=0, TBL=1=24, TOFF=8
  //tmc_write(WRITE_FLAG|REG_CHOPCONF,   0x04008008UL); // 16 microsteps, MRES=0, TBL=1=24, TOFF=8
  //tmc_write(WRITE_FLAG|REG_CHOPCONF,   0x05008008UL); //  8 microsteps, MRES=0, TBL=1=24, TOFF=8
  //tmc_write(WRITE_FLAG|REG_CHOPCONF,   0x06008008UL); //  4 microsteps, MRES=0, TBL=1=24, TOFF=8
  //tmc_write(WRITE_FLAG|REG_CHOPCONF,   0x07008008UL); //  2 microsteps, MRES=0, TBL=1=24, TOFF=8
  //tmc_write(WRITE_FLAG|REG_CHOPCONF,   0x08008008UL); //  1 microsteps, MRES=0, TBL=1=24, TOFF=8

  //outputs on (LOW active)
 
 // pressuer sensor void setup 
  {
 Wire.begin(); // wake up I2C bus
 delay (500);
 Serial.begin(9600);
}
}

//_______________________________________________
void loop()
{
  digitalWrite(STEP_PIN, HIGH);
  delayMicroseconds(20);
  digitalWrite(STEP_PIN, LOW);
  delayMicroseconds(20);
  
 float pressure;
 
 //send a request
Wire.beginTransmission(SSCDANN100PG5A5_I2C); // "Hey, CN75 @ 0x48! Message for you"
Wire.write(1);  // send a bit asking for register one, the data register (as specified by the pdf)
Wire.endTransmission(); // "Thanks, goodbye..."
// now get the data from the sensor
delay (20);

Wire.requestFrom(SSCDANN100PG5A5_I2C, 4);
while(Wire.available() == 0);
byte a     = Wire.read(); // first received byte stored here ....Example bytes one: 00011001 10000000
byte b     = Wire.read(); // second received byte stored here ....Example bytes two: 11100111 00000000
byte c     = Wire.read(); // third received byte stored here
byte d     = Wire.read(); // fourth received byte stored here

// Serial.println(a, BIN);
 //Serial.println(b, BIN);
  // Serial.println(c, BIN);
   // Serial.println(d, BIN);

int bridge_data = ((a & 0x3f) << 8) + b;

     pressure = 1.0 * (bridge_data - OUTPUT_MIN) * (PRESSURE_MAX - PRESSURE_MIN) / (OUTPUT_MAX - OUTPUT_MIN) + PRESSURE_MIN;

           Serial.print("pressure    (PSI) ");
           Serial.println(pressure);
           Serial.println("");
           
           delay (50);
}