-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how to improve the speed of spi communication? #33
Comments
From your code, I can see that you have configured SPI at 50MHz
I think, you are confused about the sampling rate of your ADC with SPI speed. |
Cheers @SalmanKhaja, that's quite right. So the timing diagrams are: and for SPI: So looking at then we would need the following pins (aside from SPI):
You are waiting for BUSY I guess? -> while(gpioRead(18) == 0) {} You could try to change that? You could also could remove that while() altogether and just read all the time? is more or less what you are doing now. Also, I would remove the printfs() as well, dump the values on a file for 10 s or something and measure the time at the beginning and at the end and calculate the samples/ second there. |
reply: yes, actually the max frequency of ADC is more than 20MHz, and agx orin is 50Mhz, but when using spi to transmit the data from adc to agx orin is very slow, just 3khz. And i tested adc with MCU(stm32) up to 40khz, but connect MCU to agx orin is also slow. |
I follow your suggestion and it help improve the speed, but still far from 20KHz. |
You are right, I tried on the Orin AGX and the same result with Orin Nano, the number of samples/transfers per seconds is just above 3000, really low. I tried in the old Nano and I am getting over 23000... I really don't know the reason for this one, but there is some problem going on for the Orin family and the SPI I don't have a solution for this at this time. |
For documentation purposes only, the SPI driver is introducing a massive transfer delay for all Jetpacks from 5.1.2, this affects the whole Orin family, driver is the same. I verified this, latest 6 doesn't seem to solve the problem. Haven't tried to go back to 5.1.1 but that's a potential solution(https://developer.nvidia.com/embedded/jetpack-sdk-511) (One) Reference: https://forums.developer.nvidia.com/t/spi-ioc-message-ioctl-for-spi-extremely-slow/295460 |
I tried the connect the ad7606 with agx by parallel mode , but the problem is that 16 gpio pins of the agx orin don't change. I tested every pins, and many pins can get 0 and 1 as input. so i not sure that is the agx orin problem or else? |
@Hubuwenxin can you show me your code here please? |
here is the parallel code: // Giving meaningful names to pins in the Orin #define BILLION 1000000000L uint64_t diff; void ADC7606_Reset() { void Convert_Volt(const uint16_t* input, float* output, int inputSize, float xferFactor) { int main(void) {
} |
It is looking OK to me, the only thing I would make sure is: -Set the AD7606 pin PAR/SER/BYTE SEL to GND It should work, it you see the stuff on the oscilloscope then it has to show up in the Orin. |
I ran the "spi_loop.c " to get data from ad7606, the frequency is 3khz. But i need more than 20khz, Is there other method to improve the spi communication speed?
here is my modified code of SPI_loop.c:
//gcc -Wall -o spi_loop spi_loop.c -ljetgpio
//sudo ./spi_loop
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <jetgpio.h>
#include <time.h>
struct timespec start, end;
double elapsed_time;
void ADC7606_Reset()
{
gpioWrite(16, 1);
gpioWrite(16, 0);
}
void Convert_Volt(uint16_t* input, float* output, int inputSize) {
const float lsb_voltage = 5.0f / 32768.0f;
}
int main(int argc, char *argv[])
{
int Init;
int SPI_init;
int SPI_stat;
uint16_t tx[4] = {0,};
uint16_t rx[4] = {0,};
float voltages[4] = {0};
}
The text was updated successfully, but these errors were encountered: