This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/TM4C123GH6PM: SPI read difficulty

Part Number: TM4C123GH6PM
Other Parts Discussed in Thread: ADS127L01

Tool/software: Code Composer Studio

Hi Folks,

I am having trouble reading data from a 24 bit ADC (ADS127L01) using SPI. I originally set up using module 3 but switched to module 0  to see if that helped anything.  It did not.  The ADC pulls a pin (digital ready, DRDY) low when data is ready so I am trying to trigger ADC reads using a GPIO based interrupt. I need to collect data at 250 kHz, so I set up to collect the 24 bits of data at 8 MHz. On my scope, I can see the GPIO toggle.  The GPIO interrupt service routine sets a flag called triggerADC that seems to be working (discussed below):

void DRDYIntHandler(void){ // initiate ADC data transfer
    GPIOIntClear(GPIO_PORTE_BASE, GPIO_INT_PIN_1);
    triggerADC = true; 
}

  In the main loop, I have the following code:
   if(triggerADC == true){
     uint8_t i = 0;
     for (i = 0; i<3; i++){
       SSIDataGet(SSI0_BASE, &dataPoint[i]);
        }
    triggerADC = false;
    }

The problem is that I do not see the SCK pin toggle when I try to read data.  If I replace the SSIDataGet with a SSIDataPut command, then the SCK pin does toggle, giving the expected three sets of eight pulses at the expected frequency.  That indicates that the ISR is working and the flag is being set and cleared when I want it.  I have also tried reading a single value (not using the for(int i ...) loop) but that does not work either.  I have also tried reading using the non-blocking command but that did not work.

I suspect I am missing something pretty simple about the SSIDataGet command but I just do not know what it is.  Any help will be appreciated.

Thanks,

Jack

  • My understanding is that it is only the SSI transmit operation which generate the SCK.

    If you to only read data then you need to repeat the sequence of:

    a. Call SSIDataPut() to transmit some "dummy" data which generates the SCK.

    b. Call SSIDataGet() to read the SSI receive data.

    Admittedly the TivaWare Peripheral Driver Library USER’S GUIDE doesn't make this clear.

  • ok, thanks.  I will see if I can figure out if this allows me to read the ADC.  It will take me a while to test, but I will click the "issue resolved" button if it does.

    Thanks again,

    Jack

  • Hi Jack,

      Thanks to Chester and he is correct about the dummy data needed to start the SPI clock. The SSIDataGet() merely reads the data out of the RX FIFO. It does not start the transmission. It is the SSIDataPut() that starts the transmission. Although your slave device may not need the MOSI input but it does need the clock to synchronize the return data on the MISO pin. Therefore, you need to create the three 8-bit dummy data to receive the 24-bit data. 

  • Ok.  Thanks to both Chester and Charles.  I will close the thread.

    Best,

    Jack