Hi, I have created a global variables header file that I use through out my project. The variables are static volatile and intialized to zero.
When I update them with a new value (i.e. a =150) and try to print them to serial console of Segger, in main(), the printed values are all zero.
If I update them and print them in a function, located in another source file of the project , the variables are updated correctly.
I attach the header file code here in case you see something that I don't
#ifndef GLOBAL_VARIABLES_H
#define GLOBAL_VARIABLES_H
#ifdef __cplusplus
extern "C" {
#endif
#include "nrf_drv_twi.h"
#include "app_error.h"
#include "ICM20948.h"
#define TWI_INSTANCE_ID 0
static const nrf_drv_twi_t m_twi = NRF_DRV_TWI_INSTANCE(TWI_INSTANCE_ID);
static volatile bool m_xfer_done = false;
static volatile ret_code_t err_code;
static volatile bool flag = false;
static volatile int16_t accel_X = 0;
static volatile int16_t accel_Y = 0;
static volatile int16_t accel_Z = 0;
static volatile int16_t gyro_X = 0;
static volatile int16_t gyro_Y = 0;
static volatile int16_t gyro_Z = 0;
static volatile uint16_t testVariable = 0;
#ifdef __cplusplus
}
#endif
#endif // GLOBAL_VARIABLES_H
Thank you