Hi,
I am contemplating using an ADC with a "daisy chain" capability. There are now quite a few of these; as examples. see the ADS 8881 for 18 bits and the ADS 8861 for 16 bits.
How this works: To form the daisy chain, the clocks and convert pins are all (each) driven together, the SDO of the first ADC is connected to the SDI of the next, and so on, and the SDO of the last goes to the MCU SPI interface. Each ADC tacks the bits it receives onto the frame that it sends to the next. The last ADC sends a frame with length equal to the number of ADC times the number of bits from each ADC.
For example, with two 18 bit ADCs, the transfer to the MCU is a frame of length 36 bits. For four 16 bit ADCs, the transfers size would be 64 bits. Finally, for performance, these transfers need to be contiguous, i.e. a single frame of 36 bits or 64 bits in these examples.
Now the SPI question:
The I.MXRT106x processors seem to be capable of contiguous SPI transfers up to 4096 bits long. (See I.MRXT1060 Reference Manual, rev 3, TCR on page 2885, and bit field FRAMESZ on oage 2888).
But the transmit and receive data registers are 32 bits. (The TDR is page 2889 and the RDR is on page 2890).
I assume the way one transfers more than 32 bits is to loop over writing the TDR and reading the RDR. In a 36 bit transfer, the second read is ready after 4 bits?
For purposes of illustration, I am thinking of something like the following.
Comments? Suggestions?
Thank you
I am contemplating using an ADC with a "daisy chain" capability. There are now quite a few of these; as examples. see the ADS 8881 for 18 bits and the ADS 8861 for 16 bits.
How this works: To form the daisy chain, the clocks and convert pins are all (each) driven together, the SDO of the first ADC is connected to the SDI of the next, and so on, and the SDO of the last goes to the MCU SPI interface. Each ADC tacks the bits it receives onto the frame that it sends to the next. The last ADC sends a frame with length equal to the number of ADC times the number of bits from each ADC.
For example, with two 18 bit ADCs, the transfer to the MCU is a frame of length 36 bits. For four 16 bit ADCs, the transfers size would be 64 bits. Finally, for performance, these transfers need to be contiguous, i.e. a single frame of 36 bits or 64 bits in these examples.
Now the SPI question:
The I.MXRT106x processors seem to be capable of contiguous SPI transfers up to 4096 bits long. (See I.MRXT1060 Reference Manual, rev 3, TCR on page 2885, and bit field FRAMESZ on oage 2888).
But the transmit and receive data registers are 32 bits. (The TDR is page 2889 and the RDR is on page 2890).
I assume the way one transfers more than 32 bits is to loop over writing the TDR and reading the RDR. In a 36 bit transfer, the second read is ready after 4 bits?
For purposes of illustration, I am thinking of something like the following.
Comments? Suggestions?
Thank you
C-like:
void setSpectialTransferSize(uint8_t nbits) {
uint32_t tcr = port().TCR;
port().TCR = (tcr & 0xfffff000) | LPSPI_TCR_FRAMESZ(nbits-1);
}
// For transfers of size "nbits" <= 16
uint16_t specialTransfer16(uint16_t data) {
int n = 0;
port().TDR = data; // output 16 bit data.
while ((port().RSR & LPSPI_RSR_RXEMPTY)) ; // wait while the RSR fifo is empty...
return port().RDR;
}
// For transfers of size "nbits" <= 32
uint32_t specialTransfer32(uint32_t data) {
port().TDR = data;
while ((port().RSR & LPSPI_RSR_RXEMPTY));
return port().RDR;
}
// For transfers of size "nbits" <= 64
uint64_t specialTransfer64(uint64_t data) {
uint64_t d64;
port().TDR = data>>32;
while ((port().RSR & LPSPI_RSR_RXEMPTY));
d64 = port().RDR;
d64 <<= 32
port().TDR = data&0xFFFFFFFF;
while ((port().RSR & LPSPI_RSR_RXEMPTY));
d64 |= port().RDR;
return d64;
}