When I use sleep mode while debug it sleep mode Works. But when I try runing code without using debug method it dosnot go in Sleep mode. When I chack current.

When using debug method stape by stape.

Without using stape by stape debug method.
Hear is the Code :-
#include "main.h"
#include "i2c.h"
#include "usart.h"
#include "gpio.h"
#include "string.h"
#include "stdio.h"
#include "math.h"
void SystemClock_Config(void);
#define LIS3DHTR_ADDR (0x1D)
/* LIS3DHTR registers */
#define LIS3DHTR_CTRL_REG1 0x20
#define LIS3DHTR_CTRL_REG4 0x23
#define LIS3DHTR_OUT_X_L 0x28
#define LIS3DHTR_INT1_CFG 0x30
#define LIS3DHTR_INT1_THS 0x32
#define LIS3DHTR_INT1_DURATION 0x33
#define LED_PIN GPIO_PIN_10
#define LED_GPIO_PORT GPIOA
#define FALL_THRESHOLD 24 // 24 mg
volatile uint8_t fallDetected = 0;
char *str={0};
uint8_t Rx_data;
int main(void)
{
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
MX_I2C1_Init();
MX_USART2_UART_Init();
HAL_UART_Receive_IT(&huart2, &Rx_data, 1);
uint8_t ctrl_reg1_data = 0x27; // X, Y, Z axis enabled, power on mode, data rate selection = 10Hz
HAL_I2C_Mem_Write(&hi2c1, LIS3DHTR_ADDR << 1, LIS3DHTR_CTRL_REG1, I2C_MEMADD_SIZE_8BIT, &ctrl_reg1_data, 1, HAL_MAX_DELAY);
uint8_t ctrl_reg4_data = 0x00; // Continuous update, +/- 2g, Self-test disabled
HAL_I2C_Mem_Write(&hi2c1, LIS3DHTR_ADDR << 1, LIS3DHTR_CTRL_REG4, I2C_MEMADD_SIZE_8BIT, &ctrl_reg4_data, 1, HAL_MAX_DELAY);
uint8_t int1_cfg_data = 0x2A; // Enable interrupt on X, Y, Z axes' data overrun and data-ready events
HAL_I2C_Mem_Write(&hi2c1, LIS3DHTR_ADDR << 1, LIS3DHTR_INT1_CFG, I2C_MEMADD_SIZE_8BIT, &int1_cfg_data, 1, HAL_MAX_DELAY);
uint8_t int1_ths_data = FALL_THRESHOLD; // Set threshold for fall detection
HAL_I2C_Mem_Write(&hi2c1, LIS3DHTR_ADDR << 1, LIS3DHTR_INT1_THS, I2C_MEMADD_SIZE_8BIT, &int1_ths_data, 1, HAL_MAX_DELAY);
uint8_t int1_duration_data = 0x00; // Set duration of interrupt pulse to minimum value
HAL_I2C_Mem_Write(&hi2c1, LIS3DHTR_ADDR << 1, LIS3DHTR_INT1_DURATION, I2C_MEMADD_SIZE_8BIT, &int1_duration_data, 1, HAL_MAX_DELAY);
while (1)
{
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, 0);
HAL_Delay(5000);
char str[100]; // Declare str at the beginning
strcpy(str, "Going into SLEEP MODE in 5 seconds\r\n");
HAL_UART_Transmit(&huart2, (uint8_t *)str, strlen (str), 100);
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, 1);
HAL_Delay(10000);
HAL_SuspendTick();
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, 0); // Just to indicate that the sleep mode is activated
HAL_PWR_EnableSleepOnExit ();
char message="shreyash";
uint8_t data[6]={0};
HAL_I2C_Mem_Read(&hi2c1, LIS3DHTR_ADDR << 1, LIS3DHTR_OUT_X_L | 0x80, I2C_MEMADD_SIZE_8BIT, data, 6, HAL_MAX_DELAY);
int16_t xAccl = ((int16_t)((data[1] << 8| data[0]));
int16_t yAccl = ((int16_t)((data[3] << 8| data[2]));
int16_t zAccl = ((int16_t)((data[5] << 8| data[4]));
sprintf(str, "\r\nx: %d ,\r\ny: %d ,r\nz: %d\r\n", xAccl,yAccl,zAccl);
HAL_UART_Transmit(&huart2, (uint8_t *)str, sizeof(str), 100);
//char magnitude = sqrt(xAccl * xAccl + yAccl * yAccl + zAccl * zAccl);
char magnitude = sqrt(pow(xAccl, 2) + pow(yAccl, 2) + pow(zAccl, 2));
sprintf(str, " trupti %d\r \n",(int)( magnitude/10));
HAL_UART_Transmit(&huart2,(uint8_t *)str, sizeof(str), 100);
if((magnitude/10)>=20)
{
}
else{
HAL_UART_Transmit(&huart2, "below\r\n", strlen ("below\r\n"), HAL_MAX_DELAY);
}
strcpy(str, "Going into SLEEP(below) MODE in 5 seconds\r\n");
HAL_UART_Transmit(&huart2, (uint8_t *)str, strlen (str), 100);
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, 1);
HAL_Delay(100);
HAL_SuspendTick();
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, 0); // Just to indicate that the sleep mode is activated
HAL_PWR_EnableSleepOnExit ();
}
}
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) {
if (GPIO_Pin == GPIO_PIN_0)
{ // Change according to your setup
HAL_PWR_DisableSleepOnExit();
char *wake_msg = "WakeUP from SLEEP\r\n";
HAL_UART_Transmit(&huart2, (uint8_t *)wake_msg, strlen(wake_msg), 1000);
for (int i=0; i<5; i++)
{
HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_4);
HAL_Delay(5000);
}
char str[100]; // Declare str at the beginning
strcpy(str, "Going into SLEEP(above) MODE in 5 seconds\r\n");
HAL_UART_Transmit(&huart2, (uint8_t *)str, strlen (str), 100);
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, 1);
HAL_Delay(10000);
HAL_SuspendTick();
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, 0); // Just to indicate that the sleep mode is activated
HAL_PWR_EnableSleepOnExit (); }
}
Thank you