Receive a 4MSPS CMOS parallel ADC binary using nucleo-H743ZI2 on Arduino

Post here all questions related to STM32 core if you can't find a relevant section!
Post Reply
Ahmed Eltayeb
Posts: 5
Joined: Tue Aug 09, 2022 5:39 am

Receive a 4MSPS CMOS parallel ADC binary using nucleo-H743ZI2 on Arduino

Post by Ahmed Eltayeb »

HI there
I am trying to read an ADC a parallel binary data https://datasheets.maximintegrated.com/ ... AX2771.pdf at the speed of 4MSPS with nucleo-H743ZI2. The data is sent with from 2 bins (I0,I1), CLK_out and GNS pin, my main goal is to read the data then save into a file.

Code: Select all

//#define CLK_OUT PC0 //A1
#define CLK_OUT_READ PB1 //A3
#define READ_I1 PA3 //A0
//volatile byte ledState = LOW;

void setup() {
  Serial.begin(4000000);
//  pinMode(CLK_OUT, OUTPUT);
  pinMode(CLK_OUT_READ, INPUT);
  pinMode(READ_I1, INPUT);
  attachInterrupt(digitalPinToInterrupt(CLK_OUT_READ), IDataRead, FALLING);
}
void loop() {
//  ledState = !ledState;
//  digitalWrite(CLK_OUT, ledState);
//  const uint8_t BIT = (GPIOB->IDR & 0x00000008) >> 1;
}
void IDataRead() {
uint8_t I1 = (GPIOA->IDR & 0x00000008) >> 3;
  Serial.println(I1);
}
the code works. Unfortunately I don't know if my code (nucleo Board) is fast enough and if I am getting a missing data.
Q1: how can I test if the the processer is fast enough?
Q2: Is the serial.Print() fast enough , if not what is a faster way to transmit and save the data ?
ps: the Code reads only 1 bit data from bin I1, the ADC can be set from 1 bit output and up to 3 bit
thank you in advance.
dannyf
Posts: 446
Joined: Sat Jul 04, 2020 7:46 pm

Re: Receive a 4MSPS CMOS parallel ADC binary using nucleo-H743ZI2 on Arduino

Post by dannyf »

Q1: how can I test if the the processer is fast enough?
the not so smart way is to speed up the code until you get unrealiable results. the smarter way is to look at the datasheet and see how fast the interface can go.
Q2: Is the serial.Print() fast enough ,
that will depend on your transmission protocol: how often do you want to read the chip; and how would want to read the chip...
if not what is a faster way to transmit and save the data ?
look up the datasheet. it looks to be some sorts of a spi device. fasters ways to read it include:
1. use the spi module on your chip, via polling;
2. use the spi module on your chip, via interrupt;
3. use the spi module on your chip, via dma;
...

but first you need to decide how do you want to read the chip? every second? every 0.1 second?...
Ahmed Eltayeb
Posts: 5
Joined: Tue Aug 09, 2022 5:39 am

Re: Receive a 4MSPS CMOS parallel ADC binary using nucleo-H743ZI2 on Arduino

Post by Ahmed Eltayeb »

look up the datasheet. it looks to be some sorts of a spi device. fasters ways to read it include:
1. use the spi module on your chip, via polling;
2. use the spi module on your chip, via interrupt;
3. use the spi module on your chip, via dma;
...
unfortunately the SPI is only used to program the board and it is not used for transmition, the only output pins provided are the ADC's pins(I0,I1) and sampling clock(CLK_OUT).

I have tried transmitting the data with this code, but as you guessed the data is wrong.

Code: Select all

#define READ_I0 PA3 //A0
#define READ_I1 PC0 //A1
#define CLK_OUT_READ PB7 //D0
void setup() {
  SerialUSB.begin(9600);
  pinMode(READ_I1, INPUT);
  pinMode(READ_I0, INPUT);
  pinMode(CLK_OUT_READ, INPUT);
  attachInterrupt(digitalPinToInterrupt(CLK_OUT_READ), IDataRead, FALLING);
  

void IDataRead() {
I = ((GPIOC->IDR & 0x00000001) << 1) + ((GPIOA->IDR & 0x00000008) >> 3); // Read I0+I1
//print I data to USB in its intger value
switch(I){ 
  case 0:
    SerialUSB.write(1);
  break;
  
  case 1:
    SerialUSB.write(3);
  break;
  
   case 2:
    SerialUSB.write(-1);
  break;
  
  case 3:
    SerialUSB.write(-3);
  break;
}
I would really appreciate any kind of help I can get.
I have been stuck for the past few weeks
ag123
Posts: 1653
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: Receive a 4MSPS CMOS parallel ADC binary using nucleo-H743ZI2 on Arduino

Post by ag123 »

if your data is serial, use SPI. if your data is parallel, & you need those high speeds, you may need to resort to DMA. for that, look up the ref manual, explore HAL etc.
H743 i'd think has 'many' SPI devices, so there should be 'spare'
dannyf
Posts: 446
Joined: Sat Jul 04, 2020 7:46 pm

Re: Receive a 4MSPS CMOS parallel ADC binary using nucleo-H743ZI2 on Arduino

Post by dannyf »

I have tried transmitting the data with this code, but as you guessed the data is wrong.
repeating myself here: you will need to figure out how you want to communicate with the chip. for example, do you want to do burst reads or continuous reads of the chip... They determine which path you will take.

in terms of your code, you will NOT achieve anywhere close to 4MSPS if you have serial transmission (very slow) in the ISR. Each (chip) bit is ~10 bits of UART transmission. At (assuming) 9600bps, that means the maximum speed of transmission with the chip is 960bps.

your options are, assuming burst reads:
1. bit bang just those four bits, process them and then transmit via uart; or
2. use the spi module to read 8 bits, process them and then transmit via uart.

Either approach will mean a drastic departure from your corrent approach.
Post Reply

Return to “General discussion”