I am using the F28377D 'Delfino" DSC. I am using an external ADC (AD7986) to get 18 bit samples. The ADC will do 2MSps, but that requires a clock frequency of 100MHz. The DSC has 50MHz SPI ports, but I am unable to use them, I am using the pins for EMIF. So I have the PLLSYSCLK set to 25MHz (40ns period). The SPI port is transferring two 9 bit values since the bit width is limited to 16.
I can acquire and store the data, code below. When I look at the time between samples it varies from 3.76 us to 3.84 us. This equates to +/- 1 clock cycle (40 ns).
Is it possible to get the time tighter to a consistent value? I am currently not using interrupts or CPU clock timer, will either of these help?
Uint32 Read_SPI(){
int i;
Uint32 vsread
// Transmit ADC dummy data
for(i=0; i<2; i++){
SpibRegs.SPITXBUF = 0; //SPI-B
}
// Wait until data is received
while(SpibRegs.SPIFFRX.bit.RXFFST !=2) {}
//Convert SPI-B data
vsread = SpibRegs.SPIRXBUF; //load MS 9b
vsread <<= 9; //shift left 9 bits
vsread |= SpibRegs.SPIRXBUF; //load and merge LS 9b
vsread = vsread ^ 0x20000; //convert from 2's complement
return vsread;
}