C2000: Receive/Transmit more than 16Bits from external ADC

13 次查看(过去 30 天)
Dear all,
I am trying to read the data from an external ADC using the Embedded Coder Support package for C2000 processors.
The problem i am struggling with is that i need 32Bits to set up the ADC and 64Bits to receive the Value (it are 2 ADCs that are daisy-chained).
However the SPI Transmit and Receive block are restricted to uint16. So i am not able to send and receive the data.
My questions raised now are the following:
  1. Is there a work around for creating a solution not using the SPI receive block to receive serial data and process it to a format where i can extract the values of the ADCs? It are 36Bits out of the 64 that i receive.
  2. In the help of the SPI transmit block it is stated that the input signal is of the form vector. How does the SPI block handels a vector of length 2. Because then i could send the first 16Bit in the first part and the rest in the second part of the vector?
Any help or tips would be much appreciated.
Thanks in advance.
Additional info: I build my test on the base of the example model c28x_spitest_ert.

回答(1 个)

Rishav
Rishav 2023-5-4
Hi Marius,
It seems like you are facing a problem with the data format when communicating with the ADCs using the SPI protocol. The SPI Transmit and Receive blocks in Embedded Coder Support package for C2000 processors are restricted to uint16, which is not sufficient to send and receive 32-bit and 64-bit data.
To work around this issue, you can try the following solutions:
  1. Use a combination of SPI Transmit and Receive blocks: You can use multiple SPI Transmit and Receive blocks to send and receive the data in smaller chunks. For example, you can use two SPI Transmit blocks to send the 32-bit data in two 16-bit chunks and use two SPI Receive blocks to receive the data in the same format. Similarly, you can use three SPI Transmit blocks to send the 64-bit data in three 16-bit chunks and use three SPI Receive blocks to receive the data in the same format.
  2. Use a custom SPI driver: You can write a custom SPI driver that can handle 32-bit and 64-bit data formats. This driver can be integrated with the Embedded Coder Support package to communicate with the ADCs. However, this solution requires a good understanding of the SPI protocol and C programming.
Regarding your question about the input signal format of the SPI Transmit block, it accepts a vector of uint16 values, where each element of the vector represents a 16-bit value to be transmitted. Therefore, you can split your 32-bit and 64-bit data into multiple 16-bit values and send them using the SPI Transmit block.
Regards,
Rishav Saha

产品


版本

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by