FSR Analog read too sensitive

Hi. We have a custom board featuring 4 FSR sensors on it, based on the Nrf52810.

Initially i tested those boards and the sensors using an STLink-V2, along with the Arduino IDE and the following library
https://github.com/sandeepmistry/arduino-nRF5

The sensors worked nicely exactly as they have worked on the Arduino based prototype.

Now porting our firmware to the Nrf52DK and Segger embedded studio the sensors seem to be capping too easily.
Just by touching the FSR the analog read reaches almost 60% progress while on the exactly same board with the Arduino firmware the progress is almost 5%. 

We have also tried copying the exact same analog read code from the Arduino library but still no difference.

Here is the code we are using. 

static void saadc_callback(nrf_drv_saadc_evt_t const * p_event)
{ 
    ret_code_t err_code;

    if (p_event->type == NRF_DRV_SAADC_EVT_DONE)
    {     
        err_code = nrf_drv_saadc_buffer_convert(p_event->data.done.p_buffer, SAMPLES_IN_BUFFER);
        APP_ERROR_CHECK(err_code);

        fsr_analog_values[0] = p_event->data.done.p_buffer[0];
        fsr_analog_values[1] = p_event->data.done.p_buffer[1];
        fsr_analog_values[2] = p_event->data.done.p_buffer[2];
        fsr_analog_values[3] = p_event->data.done.p_buffer[3];
        bat_analog_value     = p_event->data.done.p_buffer[4];

        bat_mv = ADC_RESULT_IN_MILLI_VOLTS(bat_analog_value) * VBAT_COMPENSATION;
        bat_level = batmv_to_percent(bat_mv);

#if ENABLE_ADC_LOG
        NRF_LOG_INFO("FSR: %d, %d, %d, %d", fsr_analog_values[0], fsr_analog_values[1], fsr_analog_values[2], fsr_analog_values[3]);
        NRF_LOG_INFO("BAT: %dmV, %d%%", bat_mv, bat_level);
#endif
    }
}
void handle_saadc_meas()
{
  if(adc_read_ready)
  {
    fsr_analog_values[0] = -(analogRead(FSR_PIN1)-1023);
    fsr_analog_values[1] = -(analogRead(FSR_PIN2)-1023);
    fsr_analog_values[2] = -(analogRead(FSR_PIN3)-1023);
    fsr_analog_values[3] = -(analogRead(FSR_PIN4)-1023);

    bat_analog_value     = analogRead(BATT_AD);

    bat_mv = ADC_RESULT_IN_MILLI_VOLTS(bat_analog_value) * VBAT_COMPENSATION;
    bat_level = batmv_to_percent(bat_mv);

#if ENABLE_ADC_LOG
    NRF_LOG_INFO("FSR: %d, %d, %d, %d", fsr_analog_values[0], fsr_analog_values[1], fsr_analog_values[2], fsr_analog_values[3]);
    NRF_LOG_INFO("BAT: %dmV, %d%%", bat_mv, bat_level);
#endif

    adc_read_ready = false;
  }

}
#ifdef __cplusplus
extern "C" {
#endif

#include "analog_read.h"

const uint32_t g_ADigitalPinMap[] = { 0,1,2,3,4,5,6,7,8,9,10,11,12, 13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31};

static uint32_t saadcReference = SAADC_CH_CONFIG_REFSEL_Internal;
static uint32_t saadcGain      = SAADC_CH_CONFIG_GAIN_Gain1_5;

static int readResolution = 10;
static int writeResolution = 8;

void analogReadResolution( int res )
{
  readResolution = res;
}

void analogWriteResolution( int res )
{
  writeResolution = res;
}

static inline uint32_t mapResolution( uint32_t value, uint32_t from, uint32_t to )
{
  if ( from == to )
  {
    return value ;
  }

  if ( from > to )
  {
    return value >> (from-to) ;
  }
  else
  {
    return value << (to-from) ;
  }
}

/*
 * Internal Reference is at 0.6v!
 * External Reference should be between 1v and VDDANA-0.6v=2.7v
 *
 * Warning : On Arduino Zero board the input/output voltage for SAMD21G18 is 3.3 volts maximum
 */
void analogReference( eAnalogReference ulMode )
{
  switch ( ulMode ) {
    case AR_DEFAULT:
    case AR_INTERNAL:
    default:
      saadcReference = SAADC_CH_CONFIG_REFSEL_Internal;
      saadcGain      = SAADC_CH_CONFIG_GAIN_Gain1_5;
      break;

    case AR_VDD4:
      saadcReference = SAADC_CH_CONFIG_REFSEL_VDD1_4;
      saadcGain      = SAADC_CH_CONFIG_GAIN_Gain1_4;
      break;
  }
}

uint32_t analogRead( uint32_t ulPin )
{
  uint32_t pin = SAADC_CH_PSELP_PSELP_NC;
  uint32_t saadcResolution;
  uint32_t resolution;
  int16_t value;

  if (ulPin >= PINS_COUNT) {
    return 0;
  }

  ulPin = g_ADigitalPinMap[ulPin];

  switch ( ulPin ) {
    case 2:
      pin = SAADC_CH_PSELP_PSELP_AnalogInput0;
      break;

    case 3:
      pin = SAADC_CH_PSELP_PSELP_AnalogInput1;
      break;

    case 4:
      pin = SAADC_CH_PSELP_PSELP_AnalogInput2;
      break;

    case 5:
      pin = SAADC_CH_PSELP_PSELP_AnalogInput3;
      break;

    case 28:
      pin = SAADC_CH_PSELP_PSELP_AnalogInput4;
      break;

    case 29:
      pin = SAADC_CH_PSELP_PSELP_AnalogInput5;
      break;

    case 30:
      pin = SAADC_CH_PSELP_PSELP_AnalogInput6;
      break;

    case 31:
      pin = SAADC_CH_PSELP_PSELP_AnalogInput7;
      break;

    default:
      return 0;
  }

  if (readResolution <= 8) {
    resolution = 8;
    saadcResolution = SAADC_RESOLUTION_VAL_8bit;
  } else if (readResolution <= 10) {
    resolution = 10;
    saadcResolution = SAADC_RESOLUTION_VAL_10bit;
  } else if (readResolution <= 12) {
    resolution = 12;
    saadcResolution = SAADC_RESOLUTION_VAL_12bit;
  } else {
    resolution = 14;
    saadcResolution = SAADC_RESOLUTION_VAL_14bit;
  }

  NRF_SAADC->RESOLUTION = saadcResolution;

  NRF_SAADC->ENABLE = (SAADC_ENABLE_ENABLE_Enabled << SAADC_ENABLE_ENABLE_Pos);
  for (int i = 0; i < 8; i++) {
    NRF_SAADC->CH[i].PSELN = SAADC_CH_PSELP_PSELP_NC;
    NRF_SAADC->CH[i].PSELP = SAADC_CH_PSELP_PSELP_NC;
  }
  NRF_SAADC->CH[0].CONFIG =   ((SAADC_CH_CONFIG_RESP_Bypass   << SAADC_CH_CONFIG_RESP_Pos)   & SAADC_CH_CONFIG_RESP_Msk)
                            | ((SAADC_CH_CONFIG_RESP_Bypass   << SAADC_CH_CONFIG_RESN_Pos)   & SAADC_CH_CONFIG_RESN_Msk)
                            | ((saadcGain                     << SAADC_CH_CONFIG_GAIN_Pos)   & SAADC_CH_CONFIG_GAIN_Msk)
                            | ((saadcReference                << SAADC_CH_CONFIG_REFSEL_Pos) & SAADC_CH_CONFIG_REFSEL_Msk)
                            | ((SAADC_CH_CONFIG_TACQ_3us      << SAADC_CH_CONFIG_TACQ_Pos)   & SAADC_CH_CONFIG_TACQ_Msk)
                            | ((SAADC_CH_CONFIG_MODE_SE       << SAADC_CH_CONFIG_MODE_Pos)   & SAADC_CH_CONFIG_MODE_Msk);
  NRF_SAADC->CH[0].PSELN = pin;
  NRF_SAADC->CH[0].PSELP = pin;


  NRF_SAADC->RESULT.PTR = (uint32_t)&value;
  NRF_SAADC->RESULT.MAXCNT = 1; // One sample

  NRF_SAADC->TASKS_START = 0x01UL;

  while (!NRF_SAADC->EVENTS_STARTED);
  NRF_SAADC->EVENTS_STARTED = 0x00UL;

  NRF_SAADC->TASKS_SAMPLE = 0x01UL;

  while (!NRF_SAADC->EVENTS_END);
  NRF_SAADC->EVENTS_END = 0x00UL;

  NRF_SAADC->TASKS_STOP = 0x01UL;

  while (!NRF_SAADC->EVENTS_STOPPED);
  NRF_SAADC->EVENTS_STOPPED = 0x00UL;

  if (value < 0) {
    value = 0;
  }

  NRF_SAADC->ENABLE = (SAADC_ENABLE_ENABLE_Disabled << SAADC_ENABLE_ENABLE_Pos);

  return mapResolution(value, resolution, readResolution);
}


#ifdef __cplusplus
}
#endif


I mostly suspect some voltage configuration issue, but i would appreciate some guidance of what could be a potential cause. 
Best,

Related