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/RM48L952: SPI with External ADC

Part Number: RM48L952
Other Parts Discussed in Thread: HALCOGEN, ADS8922B

Tool/software: Code Composer Studio

Hi all,

I am currently working on a project, and I have currently run into an issue that has halted my progress.

First, some details which may help in troubleshooting:

>Relevant system components:

--> CCSv7

--> HALCoGen v4.07

--> RM48

--> ADS8922B

>Basic overview of what I am trying to accomplish:

--> Acquire ADC conversions from the daisy-chain configuration with the RM48

--> Store the conversions onto a microSD card

>Current Setup/Configuration:

--> MIBSPI1/SPI1 module is connected to the ADC daisy-chain (this will be the module I use to send data to/receive data from the ADCs)

-----> The daisy-chain topology that I am using is straight from the ADS892xB data sheet; and has been validated

--> The baud rate for the SPI module is set to 400 kHz

--> nCS[3] is configured as GIO for bit banging (remaining SPI pins are SPI functional)

--> MIBSPI1/SPI1 module pin map:

         RM48 pin            ->   ADC pin  ->  Brief Detail

-----> MIBSPI1NCS_3  ->  nCS          ->  nCS lines of all 3 ADCs are tied together as per the data sheet

-----> MIBSPI1SIMO    ->  SDI           ->  SIMO line is connected to SDI pin of the first ADC (x-axis) in the daisy-chain

-----> MIBSPI1SOMI    ->  SDO-0      ->  SOMI line is connected to SDO-0 pin of the last ADC (z-axis) in the daisy-chain

-----> MIBSPI1CLK      ->  SCLK        ->  SCLK lines of all 3 ADCs are tied together as per the data sheet

-----> GIOA_5              ->  CONVST  ->  CONVST lines of all 3 ADCs are tied together as per the data sheet

-----> Each nRST & RVS pin for every ADC is connected to a GPIO

The Problem:

I have been using a saleae logic analyzer to observe communications across the relevant SPI lines. I am currently able to view and verify the data that I am sending. I am also consistently getting some sort of junk data response from the daisy-chain ("junk" meaning that I am currently not feeding a signal into the ADC for it to convert, so the responses I am getting are random values). All I am trying to do as of now is successfully store the "junk" I am getting into a buffer. I am using the spiTransmitAndReceive() function to send/receive data. **The source buffer data is being sent and has been validated, but the destination buffer ends up with all 1s (which typically indicates no connection) rather than what the saleae is seeing on the MISO line**.

My Test Code:

int main(void)
{
/* USER CODE BEGIN (3) */

     /* ENABLE INTERRUPT REQUEST */
     _enable_IRQ();

     /* MODULE INITIALIZATION */
     rtiSetup(); // Initialize the RTI module
     pinLevels(); // Initialize ADC pin levels
     sciInit(); // Initialize the SCI (UART) module
     mibspiInit(); // Initialize the MibSPI module
     spiInit(); // Initialize the SPI module
     gioInit(); // Initialize GIO module
     adcInit(); // Initialize the ADC module

     /* DEFINE CONVST BIT */
     uint32 CONVST = 5;

     //
     // BEGIN SPI COMPATIBLE CODE
     //
     spiDAT1_t config1;

     config1.CS_HOLD = FALSE;
     config1.WDEL = TRUE;
     config1.DFSEL = SPI_FMT_0;
     config1.CSNR = SPI_CS_3;

     /* Send NOP command to provide 22*N (66) cycles */
     /* Refer to data sheet for table of acceptable commands */
     //TODO: verify that I should send when attempting to receive data
     uint16 NOP[6] = {0};

     /* receive buffer */
     uint16 rxBuff[6] = {0};

     /* Start UART terminal user interface */
     // TexIn_UI();

     while(1)
     {
         /* DATA TRANSFER TEST */
         /* ------------------ */
         /* Convert Data */
         // PULL CONVST HI TO START CONVERSION
         gioSetBit(gioPORTA, CONVST, 1);

         // DELAY
         _delay_cycles(1);

         // PULL CONVST LO TO STOP CONVERSION
         gioSetBit(gioPORTA, CONVST, 0);

         // DELAY
         _delay_cycles(10);

         /* ------------------ */
         /* [F] */
         /* STRAIGHT FROM DATA SHEET pg.29-30 */
         // 1) PULL CS LOW TO START THE DATA TRANSFER FRAME
         // CS -> LO
         gioSetBit(spiPORT1, SPI_PIN_CS3, 0);

         // 2) PROVIDE 22*N CLOCKS WHERE N IS THE NUMBER OF DEVICES IN DAISY-CHAIN
         // send 66 bits of data
         // 11-bit bursts
         // use spiTransmitAndReceiveData()???
         spiTransmitAndReceiveData(spiREG1, &config1, 6, NOP, rxBuff);

         // 3) PULL CS HI TO END THE DATA TRANSFER FRAME
         // CS -> HI
         gioSetBit(spiPORT1, SPI_PIN_CS3, 1);

         // 4) DELAY
         _delay_cycles(10);
     }

/* USER CODE END */
}

Questions:

> Is the code in the while(1) loop expected to result in a single conversion for every iteration of the loop? (timing may be an issue?)

> After completing a single conversion, how do I store that data into the receive buffer (rxBuff)?

> Is an interrupt required when trying to receive data from an external device? Or can I just use the polling function spiTransmitAndReceiveData() in order to successfully receive data?

In summary:

> I am going to use the default ADC configurations (as of now, may change if necessary)

> I have verified the data being sent is what I expect

> I am getting some type of response from the daisy-chain (as observed by the saleae). However, this data has not been validated and I have not successfully stored the data into the receive buffer

I am not really sure what I am missing as of right now. My intuition is telling me that talking to an external ADC is the same concept as setting up two SPI modules as master and slave, and sending data between the 2 modules (an external loopback). Either my intuition is wrong, or my attempt at executing my idea is incorrect - just not sure at the moment.

As always, thank you for your time and consideration!

  • Hello Calvin,

    1. The minimum delay for ADC data conversion is 30ns. Is _delay_cycles(1) long enough for ADC to complete data sampling and conversion?
    2. The maximum data length (SPI) is 16-bit, and the ADC data length is 22bit, so I suggest you use 11-bit of SPI data length.
    3. If WDEL is set, the wait delay will be applied between the two transactions (11 bits for each transaction). I don't recommend to use WDELAY.
    4. Can you try multi-buffer mode?