SPI Communication Failure Between ESP32 DevkitC V4 and PGA280AIPWR - Need Troubleshooting Help

glbergdorf
Posts: 2
Joined: Wed Mar 12, 2025 11:51 pm

SPI Communication Failure Between ESP32 DevkitC V4 and PGA280AIPWR - Need Troubleshooting Help

Postby glbergdorf » Thu Mar 13, 2025 12:37 am

Hardware Setup:

  • Microcontroller: ESP32 DevkitC V4
  • Analog IC: TI PGA280AIPWR (TSSOP-24 package)
  • Connection Method: SPI (VSPI on ESP32)
  • Power Supply:
    • ESP32: USB powered (3.3V logic)
    • PGA280: DVDD connected to ESP32's 3.3V
    • VSP: External power supply (+12V)
    • VSN: External power supply (-12V)
    • VSOP/VSON: 3.3V and GND respectively
Wiring Configuration:

  • PGA280 SDI (Pin 15) → ESP32 GPIO 23 (MOSI)
  • PGA280 SDO (Pin 14) → ESP32 GPIO 19 (MISO)
  • PGA280 SCLK (Pin 16) → ESP32 GPIO 18 (SCK)
  • PGA280 CS (Pin 17) → ESP32 GPIO 5 (CS)
  • PGA280 DVDD (Pin 13) → ESP32 3.3V
  • PGA280 DGND (Pin 12) → ESP32 GND
  • PGA280 VSP (Pin 6) → External +12V supply
  • PGA280 VSN (Pin 11) → External -12V supply
  • Added 0.1μF decoupling capacitor between DVDD and DGND
  • Added 10kΩ pull-up resistor on CS line
Software Configuration:

  • PlatformIO with ESP-IDF framework
  • ESP-IDF version: 5.1.2
  • Development Environment: VSCode with PlatformIO extension
  • SPI configuration:
    • Mode 0 (CPOL=0, CPHA=0)
    • Clock frequency: Tried multiple (1MHz, 2MHz, 5MHz, 10MHz)
    • MSB first
    • Hardware SPI using the ESP32's VSPI interface (SPI2_HOST)
Problem Description:

I'm unable to establish SPI communication between the ESP32 and the PGA280. I've tried three different PGA280 ICs with the same result, so I don't believe it's a hardware failure of the IC itself. When attempting to read from or write to the PGA280 registers, I either get no response (all zeros) or seemingly random data that doesn't match expected register values.

Troubleshooting Steps Already Taken:

  1. Verified all connections with a multimeter (continuity and voltage levels)
  2. Tried different SPI clock frequencies (1MHz, 2MHz, 5MHz, 10MHz)
  3. Verified power supply voltages at the PGA280 pins (including +12V at VSP and -12V at VSN)
  4. Added decoupling capacitors and pull-up/pull-down resistors
  5. Tried both VSPI (SPI2_HOST) and HSPI (SPI3_HOST) interfaces on the ESP32
  6. Tried different SPI modes (0, 1, 2, 3) with no success
  7. Tried three different PGA280 ICs with the same results
  8. Tried a different ESP32 board with the same configuration and experienced the same issues
Code Snippet:

Code: Select all

#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/spi_master.h"
#include "driver/gpio.h"
#include "esp_log.h"

#define TAG "PGA280"

// PGA280 SPI commands
#define PGA280_READ_CMD  0x01
#define PGA280_WRITE_CMD 0x00
#define PGA280_REG_ID    0x02  // ID register

// SPI pins
#define PIN_NUM_MISO 19
#define PIN_NUM_MOSI 23
#define PIN_NUM_CLK  18
#define PIN_NUM_CS   5

static spi_device_handle_t spi;

void app_main(void)
{
    esp_err_t ret;
    
    // Configure SPI bus
    spi_bus_config_t buscfg = {
        .miso_io_num = PIN_NUM_MISO,
        .mosi_io_num = PIN_NUM_MOSI,
        .sclk_io_num = PIN_NUM_CLK,
        .quadwp_io_num = -1,
        .quadhd_io_num = -1,
        .max_transfer_sz = 32,
    };
    
    // Configure SPI device
    spi_device_interface_config_t devcfg = {
        .clock_speed_hz = 1000000,  // 1 MHz
        .mode = 0,                  // SPI mode 0
        .spics_io_num = PIN_NUM_CS,
        .queue_size = 1,
        .flags = 0,
        .pre_cb = NULL,
        .post_cb = NULL,
    };
    
    // Initialize SPI bus
    ret = spi_bus_initialize(SPI2_HOST, &buscfg, SPI_DMA_CH_AUTO);
    ESP_LOGI(TAG, "SPI bus initialize: %s", esp_err_to_name(ret));
    
    // Add device to SPI bus
    ret = spi_bus_add_device(SPI2_HOST, &devcfg, &spi);
    ESP_LOGI(TAG, "SPI bus add device: %s", esp_err_to_name(ret));
    
    // Try to read ID register
    uint8_t id = read_register(PGA280_REG_ID);
    ESP_LOGI(TAG, "PGA280 ID: 0x%02X", id);
    
    while (1) {
        vTaskDelay(1000 / portTICK_PERIOD_MS);
    }
}

uint8_t read_register(uint8_t reg)
{
    esp_err_t ret;
    uint8_t tx_data[3] = {PGA280_READ_CMD, reg, 0x00};
    uint8_t rx_data[3] = {0};
    
    spi_transaction_t t = {
        .length = 8 * 3,            // 3 bytes (command, register, data)
        .tx_buffer = tx_data,
        .rx_buffer = rx_data,
    };
    
    ret = spi_device_transmit(spi, &t);
    if (ret != ESP_OK) {
        ESP_LOGE(TAG, "SPI transmit failed: %s", esp_err_to_name(ret));
        return 0;
    }
    
    return rx_data[2];  // Return the data byte
}
Oscilloscope Observations:

Critical Issue: When connecting an oscilloscope to the SPI lines (MOSI, MISO, SCLK, CS), I'm not detecting any signals at all. This suggests that either:
  • The SPI interface is not being properly initialized
  • The GPIO pins are not being configured correctly
  • There might be a fundamental compatibility issue between ESP32 and PGA280
  • The SPI transactions are not being triggered as expected in the code
ESP-IDF Configuration:

  • Using default SPI driver configuration
  • DMA enabled for SPI transfers
  • No custom menuconfig settings for SPI
Specific Questions:

  1. Why might the ESP32 not be generating any SPI signals on the configured pins, even when testing with different ESP32 boards?
  2. Are there any known issues with ESP-IDF's SPI implementation that could prevent signals from appearing?
  3. Could there be a configuration issue in the ESP-IDF SPI driver that's preventing the signals from being generated?
  4. Are there any known compatibility issues between ESP32 and PGA280?
  5. Is there a specific initialization sequence required for the PGA280 that I might be missing?
  6. Could the ESP32's 3.3V logic levels be insufficient for reliable communication with the PGA280?
  7. Are there any specific timing requirements for the PGA280 that the ESP32 might not be meeting?
  8. Would a different development board (like an MSP430 LaunchPad) be more compatible with the PGA280?
  9. Are there any ESP-IDF specific settings or configurations that might affect SPI communication with precision analog ICs?
  10. Could the DMA transfers be causing timing issues with the PGA280?
  11. Given that I've tried multiple ESP32 boards with the same result, is there a fundamental architectural limitation or incompatibility I should be aware of?
  12. Does the PGA280 require specific power sequencing between the digital supply (DVDD) and the analog supplies (VSP/VSN) that might affect SPI communication?
Any help or suggestions would be greatly appreciated. I've spent weeks trying to get this working and I'm at my wit's end.

Thank you!

username
Posts: 594
Joined: Thu May 03, 2018 1:18 pm

Re: SPI Communication Failure Between ESP32 DevkitC V4 and PGA280AIPWR - Need Troubleshooting Help

Postby username » Wed Mar 19, 2025 1:22 am

That is the most informative post I have ever seen!!!

I'll have to see if I have a ESP32 Devkit around and see if mine does the same.

Sprite
Espressif staff
Espressif staff
Posts: 10617
Joined: Thu Nov 26, 2015 4:08 am

Re: SPI Communication Failure Between ESP32 DevkitC V4 and PGA280AIPWR - Need Troubleshooting Help

Postby Sprite » Thu Mar 20, 2025 12:42 am

Agree that this is a very good post. Unfortunately, I can't spot anything in what you posted that is obviously wrong, so I'm scratching my head on what the issue could be.

chegewara
Posts: 2505
Joined: Wed Jun 14, 2017 9:00 pm

Re: SPI Communication Failure Between ESP32 DevkitC V4 and PGA280AIPWR - Need Troubleshooting Help

Postby chegewara » Thu Mar 20, 2025 8:29 am


Critical Issue: When connecting an oscilloscope to the SPI lines (MOSI, MISO, SCLK, CS), I'm not detecting any signals at all.
Hi,
first thing i would check/test is this. Just disconnect all wires and then check if you can see any signals on SPI pins.
That will confirm if SPI is working or not on esp32 side.

glbergdorf
Posts: 2
Joined: Wed Mar 12, 2025 11:51 pm

Re: SPI Communication Failure Between ESP32 DevkitC V4 and PGA280AIPWR - Need Troubleshooting Help

Postby glbergdorf » Mon Mar 24, 2025 7:35 am

Thank you guys for all your help! I asked ChatGPT to help me write a descriptive post so that I could get targeted help. I'm glad it was useful. But I'm still having trouble with it and it's looking like the issue is with the PGA. It has a very specific SPI command structure and timing requirements. I managed to get SPI communication going with a bit-bang approach. However, it's not amplifying the input signals, which is its one job ^_^'

Anyway, I will be taking my questions to the TI forum.

Thanks again!

Who is online

Users browsing this forum: No registered users and 3 guests