Hi,
We are using Apalis_T30 with our Custom Carrier Board. There are two ADCs of exactly same type, ADC1 (Connected to SPI1) and ADC2 (Connected to SPI5). The register settings are exactly the same for both the SPI controllers and the data is read MSB first from the ADCs.
The ADC1 data captured from SPI1 is correct and the ADC2 data captured from SPI5 is NOT correct.
The input to the Channel_1 of ADC1 is 3.3V DC and the digital sample value that we got is around 0x5402 which results in around 3.3V after applying to the Digital to Voltage conversion formula.
Now, the same 3.3V DC is fed to the Channel_1 of ADC2 and the sample value that we got is around 0xA804 which results in around 6V after applying to the Digital to Voltage conversion formula.
So, why is this value getting doubled in SPI5. We have probed (using oscilloscope) the CLK and DATA lines of SPI1 and SPI5, and the data looks almost the same. But, when the raw data is read by the SPI5 driver we are seeing that the value is getting doubled.
What I suspect is, for some reason the first MSB bit may be getting missed or all the bits may be getting Left Shifted by one bit position which results in the value getting doubled.
So Kindly, help us to solve this issue ASAP as we are close to the delivery date.
Thanks & Regards
Vijay H.S
Hi Marcel,
Thanks for your response.
Please find the answers below for your queries.
-
What exact BSP software versions of things are you talking about?
We are using “Apalis-T30_LXDE-Image_2.8b3”.
-
Concerning your hardware, how exactly are the ADCs connected?
The ADCs are connected on the SPI lines - SPI_CS, SPI_CLK, SPI_MISO, SPI_MOSI. We need only SPI_MISO to read the data from ADC. And SPI_MOSI is not required as there is nothing to write to the ADC. We have configured SPI as Mode2 (Clock is negative polarity and the data is latched on the
negative edge of SCK)
-
Any buffers or other special circuitry around it?
NO.
-
What exact ADCs are you using?
We are using “AD7609” ADCs.
-
What exact driver/software talks to the ADCs?
We are using the driver written in “linux-toradex/drivers/spi/spi-tegra.c” file. We are using the GO Mode of operation.
-
What SPI bus frequencies have you tried?
We have tried with 4MHz and 15MHz SPI bus frequencies. But, our requirement is 15MHz (ADC1 connected on SPI1 is working fine with 15MHz).
Thanks & Regards
Vijay H.S
Thanks for your response.
You are very welcome.
Let me comment on your answers.
- Please note that BSP 2.8b3 is no longer supported as per the following.
- Are you sure about SPI mode 2? Have you tried any other modes (e.g. the most common mode 3)? How/where exactly did you specify this?
- OK.
- OK.
- So you are using spidev or how/what exactly talks to the ADCs? How about trying IIO where at least certain Analog Devices chips should be supported?
- OK.
Hi Marcel,
The ADC device supports Mode2 and NOT Mode3. So, we are using Mode2 (And this works fine when the ADC is connected to SPI1 with Mode2).
The Mode2 is selected by setting the SLINK_COMMAND_0 register bits as below
IDLE_SCLK = 01
CK_SDA = 0
Actually, we have modified the SPI core driver (Because we are unable to meet our requirement while using the default spi-tegra driver). To meet our requirements we have modified the spi-tegra driver. And in this, we are able to achieve our requirements. This change works perfectly fine on SPI1 to meet our requirements.
We have used the below code in the spi_tegra_probe() function to get the access to the SPI5 registers and did the register settings according to our requirements (and again, this works fine for SPI1)
base_ptr = ioremap_nocache(0x7000dc00 , 3072); //to get the base pointer for the controller 5.
Then an interrupt handler (This is the DRDY-Data Ready interrupt from the ADC) is registered in the spi_tegra_probe() and when we get an interrupt, the GO bit (in the SLINK_COMMAND_0 register) is set to trigger the SPI communication and then the data is read from the SLINK_RX_FIFO_0.
Thanks & Regards
Vijay H.S
hi
The ADC device supports Mode2 and NOT Mode3. So, we are using Mode2 (And this works fine when the ADC is connected to SPI1 with Mode2). The Mode2 is selected by setting the SLINK_COMMAND_0 register bits as below IDLE_SCLK = 01 CK_SDA = 0
This means, the SPI Communication is working fine on SPI1.
Actually, we have modified the SPI core driver (Because we are unable to meet our requirement while using the default spi-tegra driver).
What are you requirements? What exactly did you modify?
Could you send a logic diagram showing the difference between working and non working communication when receiving a known value form ADC? Thanks.
Hi Jaski,
Sorry, for my late reply. Actually, I was busy with some other project work.
What are you requirements? What exactly did you modify?
I have explained my requirement and modification in the below link
https://toradex.com/community/questions/32758/target-system-hangs-when-spi1-and-spi5-drivers-run.html?childToView=32906#comment-32906
Could you send a logic diagram showing the difference between working and non working communication when receiving a known value form ADC?
I have attached the logic diagrams link text. The signals are captured with 3.3V DC as ADC input and the values are almost the same on both the SPI1 and SPI5 buses. Each sample size is 18-bits.
Thanks & Regards
Vijay H.S
So the logic diagram you sent shows that that you don’t have the same data on SPI1 and SPI5. So what is the Issue?
Hi Jaski,
According to logic diagrams, ADC1 = 0x5517 and ADC2 = 0x5491. So, when I read from the SPI2 driver for ADC2 the value should be 0x5… but I am getting as 0xA… which is almost double. So, I couldn’t understand why is this behaviour in the SPI2 driver?
Thanks & Regards
Vijay H.S
There seems to be some issue on your change SPI driver. Could you switch the ADCs SPI connection to be sure that the problem is really coming from your changed SPI driver? Thanks
Hi Jaski,
I also tried without any of my changes. I took original SPI core driver, original Spidev driver and read the samples from user space and the result is the same for ADC2 (sample value is still 0xA…).
Regards
Vijay H.S
I would suggest for you to hook up an oscilloscope to both ADCs to really see what is going on.