March 28, 2024, 05:13:41 PM

ICE40-ADC with Arduino/Pi Pico

Started by tomh381, January 28, 2023, 06:30:18 PM

Previous topic - Next topic

tomh381

Hi guys. I'm trying to use an ICE40-ADC with a Pi Pico (programming with Arduino IDE) to make a high-frequency oscilloscope. I cannot find anywhere an explanation of how to wire the ICE40-ADC up. I found the schematic but it makes no sense to me at all. Any advice/knowledge about this would be much appreciated.
TIA

josephberg

Quote from: tomh381 on January 28, 2023, 06:30:18 PMHi guys. I'm trying to use an ICE40-ADC with a Pi Pico (programming with Arduino IDE) to make a high-frequency oscilloscope. I cannot find anywhere an explanation of how to wire the ICE40-ADC up. I found the schematic but it makes no sense to me at all. Any advice/knowledge about this would be much appreciated.
TIA
The ICE40-ADC is a board that contains an ICE40 FPGA and an ADC chip that can sample analog signals up to 100 MHz. The Pi Pico is a microcontroller board that can run MicroPython or C/C++ code.

To wire the ICE40-ADC to the Pi Pico, you need to connect the following pins:

Connect the 3.3V pin of the ICE40-ADC to the 3V3 OUT pin of the Pi Pico.
Connect the GND pin of the ICE40-ADC to any GND pin of the Pi Pico.
Connect the SPI pins of the ICE40-ADC (SCK, MOSI, MISO, CS) to the corresponding SPI pins of the Pi Pico (GP2, GP3, GP4, GP5).
Connect the INT pin of the ICE40-ADC to any GPIO pin of the Pi Pico that supports interrupts (e.g. GP6).
Here is a diagram that shows how to wire the ICE40-ADC to the Pi Pico:

To program the ICE40-ADC and the Pi Pico using the Arduino IDE, you need to do the following steps:

Install the Arduino IDE and the Raspberry Pi Pico / RP2040 board support package3.
Select the Raspberry Pi Pico as the board and the appropriate COM port as the port in the Tools menu.
Write your code using the Wire library for SPI communication and the attachInterrupt function for handling interrupts.
Upload your code to the Pi Pico by pressing the BOOTSEL button and then the upload button in the Arduino IDE.
Here is an example code that reads the ADC value from the ICE40-ADC and prints it to the serial monitor:

#include "Wire.h"

#define CS_PIN 5 // chip select pin
#define INT_PIN 6 // interrupt pin

volatile uint16_t adc_value = 0; // ADC value

void setup() {
  Wire.begin(); // initialize SPI
  Serial.begin(9600); // initialize serial
  pinMode(CS_PIN, OUTPUT); // set CS pin as output
  digitalWrite(CS_PIN, HIGH); // set CS pin high
  pinMode(INT_PIN, INPUT); // set INT pin as input
  attachInterrupt(digitalPinToInterrupt(INT_PIN), readADC, FALLING); // attach interrupt handler
}

void loop() {
  Serial.println(adc_value); // print ADC value
  delay(1000); // wait for 1 second
}

void readADC() {
  digitalWrite(CS_PIN, LOW); // set CS pin low
  Wire.requestFrom(0x48, 2); // request 2 bytes from ADC
  if (Wire.available() == 2) { // if 2 bytes are available
    uint8_t high = Wire.read(); // read high byte
    uint8_t low = Wire.read(); // read low byte
    adc_value = (high << 8) | low; // combine high and low bytes
  }
  digitalWrite(CS_PIN, HIGH); // set CS pin high
}

I hope this helps you with your project.

scmahang

#2
Quote from: josephberg on November 06, 2023, 11:37:50 AM
Quote from: tomh381 on January 28, 2023, 06:30:18 PMHi guys. I'm trying to use an ICE40-ADC with a Pi Pico (programming with Arduino IDE) to make a high-frequency oscilloscope. I cannot find anywhere an explanation of how to wire the ICE40-ADC up. I found the schematic but it makes no sense to me at all. Any advice/knowledge about this would be much appreciated.
TIA
The ICE40-ADC is a board that contains an ICE40 FPGA and an ADC chip that can sample analog signals up to 100 MHz. The Pi Pico is a microcontroller board that can run MicroPython or C/C++ code.

To wire the ICE40-ADC to the Pi Pico, you need to connect the following pins:

Connect the 3.3V pin of the ICE40-ADC to the 3V3 OUT pin of the Pi Pico.
Connect the GND pin of the ICE40-ADC to any GND pin of the Pi Pico.
Connect the SPI pins of the ICE40-ADC (SCK, MOSI, MISO, CS) to the corresponding SPI pins of the Pi Pico (GP2, GP3, GP4, GP5).
Connect the INT pin of the ICE40-ADC to any GPIO pin of the Pi Pico that supports interrupts (e.g. GP6).
Here is a diagram that shows how to wire the ICE40-ADC to the Pi Pico:

To program the ICE40-ADC and the Pi Pico using the Arduino IDE, you need to do the following steps:

Install the Arduino IDE and the Raspberry Pi Pico / RP2040 board support package3.
Select the Raspberry Pi Pico as the board and the appropriate COM port as the port in the Tools menu.
Write your code using the Wire library for SPI communication and the attachInterrupt function for handling interrupts.
Upload your code to the Pi Pico by pressing the BOOTSEL button and then the upload button in the Arduino IDE.
Here is an example code that reads the ADC value from the ICE40-ADC and prints it to the serial monitor:

#include "Wire.h"

#define CS_PIN 5 // chip select pin
#define INT_PIN 6 // interrupt pin

volatile uint16_t adc_value = 0; // ADC value

void setup() {
  Wire.begin(); // initialize SPI
  Serial.begin(9600); // initialize serial
  pinMode(CS_PIN, OUTPUT); // set CS pin as output
  digitalWrite(CS_PIN, HIGH); // set CS pin high
  pinMode(INT_PIN, INPUT); // set INT pin as input
  attachInterrupt(digitalPinToInterrupt(INT_PIN), readADC, FALLING); // attach interrupt handler
}

void loop() {
  Serial.println(adc_value); // print ADC value
  delay(1000); // wait for 1 second
}

void readADC() {
  digitalWrite(CS_PIN, LOW); // set CS pin low
  Wire.requestFrom(0x48, 2); // request 2 bytes from ADC
  if (Wire.available() == 2) { // if 2 bytes are available
    uint8_t high = Wire.read(); // read high byte
    uint8_t low = Wire.read(); // read low byte
    adc_value = (high << 8) | low; // combine high and low bytes
  }
  digitalWrite(CS_PIN, HIGH); // set CS pin high
}

I hope this helps you with your project.
????
Connect the 3.3V pin of the ICE40-ADC to the 3V3 OUT pin of the Pi Pico.
Connect the GND pin of the ICE40-ADC to any GND pin of the Pi Pico.
Connect the SPI pins of the ICE40-ADC (SCK, MOSI, MISO, CS) to the corresponding SPI pins of the Pi Pico (GP2, GP3, GP4, GP5).