Good day, I am a intern trying to get the AD7616 to work with STM32h743ZI2. My main objective is to use the AD7616 in software mode and convert the analog input and read them over SPI

I have gone through the wiki page of AD7616.

From there I found the Github repository for analog devices for NO-OS AD7616.

I have a query, which is regarding the coding part of ad7616.

int32_t ad7616_write(ad7616_dev *dev, uint8_t reg_addr, uint16_t reg_data)


dev - The device structure.(with example or code)

I would appreciate any kind of input from you.

Look forward to your response.

Thank You.

adding tags
[edited by: Lluis at 3:12 PM (GMT -4) on 7 Sep 2020]
Parents Reply
  • +1
    •  Analog Employees 
    on Sep 14, 2020 12:45 PM 1 month ago in reply to dawn98f

    Hello dawn98f,

    The driver for AD7616 part can be found here (for MCU):

    The main application for AD7616-sdz contains the information about how to initialize the device using the ad7616_setup function.

    You need to create in your main application an initialization structure for the ad7616 device:

    ad7616_init_param default_init_param = {
    		/* SPI */
    		SPI_AD7616_CS,			// spi_chip_select
    		SPI_MODE_2,				// spi_mode
    		SPI_ENGINE,				// spi_type
    		-1,						// spi_device_id
    		/* GPIO */
    		PS7_GPIO,				// gpio_type
    		GPIO_DEVICE_ID,			// gpio_device_id
    		-1,						// gpio_hw_rngsel0
    		-1,						// gpio_hw_rngsel1
    		GPIO_ADC_RESET_N,		// gpio_reset
    		-1,						// gpio_os0
    		-1,						// gpio_os1
    		-1,						// gpio_os2
    		/* Device Settings */
    		AD7616_SW,				// mode
    		{AD7616_10V, AD7616_10V, AD7616_10V, AD7616_10V,
    		 AD7616_10V, AD7616_10V, AD7616_10V, AD7616_10V},	// va[8]
    		{AD7616_10V, AD7616_10V, AD7616_10V, AD7616_10V,
    		 AD7616_10V, AD7616_10V, AD7616_10V, AD7616_10V},	// vb[8]
    		AD7616_OSR_0,			// osr

    And then pass it to the setup function:

    ad7616_setup(&dev, &core, default_init_param);

    Your device descriptor now contains the information provided by the initialization structure.

    An example on how to use the read from the device function is provided in the main app:

    	for (reg_addr = 2; reg_addr <= 0x07; reg_addr++) {
    		ad7616_read(dev, reg_addr, &reg_data);
    		printf("0x%x = 0x%x\n", reg_addr, reg_data);