BLE constant disconnecting/connecting caused by reading ADS7042

Hello,

I am migrating to a new custom board where NRF52832 reads ADC ADS7042 and transfers data through the BLE. My previous board works just fine, and in the new design the only difference is in the pin mapping. In the new mapping P0.20 is the chip select for ADS7042. My code is as follows:

ret_code_t spi_ads7042_read_data(void)
{
	ret_code_t err_code;
	
	uint8_t a,b;

	ADC7042_CS_LOW;

	err_code = nrf_drv_spi_transfer(&m_spi_master_1, NULL, 0, adc_data.tmp, 2);

	
	ADC7042_CS_HIGH;
	
	a = adc_data.tmp[0];
	b = adc_data.tmp[1];
	
	adc_data.tmp[0] = b;
	adc_data.tmp[1] = a;
	
	adc_data.result>>=2;

	return err_code;	
}

and pin configuration is as follows:

#define ADS7042_CS 20
#define SPI1_MISO 19
#define SPI1_SCK  17

#define ADC7042_CS_LOW   nrf_gpio_pin_clear(ADS7042_CS)
#define ADC7042_CS_HIGH  nrf_gpio_pin_set(ADS7042_CS)

SPI initialisation routine:

uint32_t init_spi_1(void)
{
		uint32_t err_code;
		
		nrf_gpio_cfg_output(ADS7042_CS);
		nrf_gpio_pin_write(ADS7042_CS, 1);
		
	    nrf_delay_ms(1000);

		nrf_drv_spi_config_t       config;
		
		config.sck_pin      = SPI1_SCK;
        config.mosi_pin     = NRF_DRV_SPI_PIN_NOT_USED; // This line actually not used by the ADC
        config.miso_pin     = SPI1_MISO;
        config.ss_pin       = NRF_DRV_SPI_PIN_NOT_USED;
		config.frequency    = NRF_DRV_SPI_FREQ_4M;
		config.mode         = NRF_DRV_SPI_MODE_1;
		config.bit_order    = NRF_DRV_SPI_BIT_ORDER_LSB_FIRST;
		config.irq_priority = 2;
        config.orc          = 0xFF;
		
		err_code = nrf_drv_spi_init(&m_spi_master_1, &config, NULL, NULL);
	
    return err_code;   
}

With this configuration, after spi_ads7042_read_data passes for several times, the device finally goes through disconnecting and reconnecting of the BLE. Meanwhile, data are not transferred through the BLE.

Changing of ADS7042_CS to another port number, commenting out the two lines ADC7042_CS_LOW; and ADC7042_CS_HIGH;, commenting out the line err_code = nrf_drv_spi_transfer(&m_spi_master_1, NULL, 0, adc_data.tmp, 2); or removing the ADC7042 from the board makes the constant disconnecting stop and data (though not the one read from the ADC) is successfully transferred through the BLE channel.

Provided that the same code worked just fine in the previous board, I am a bit out of ideas how to find the reason for this behaviour. Any help would be appreciated.

Parents Reply Children
No Data
Related