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: Trouble getting data from External ADC

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

Tool/software: Code Composer Studio

Hello, 

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

Context: I tried posting this earlier and got some weird error so here goes attempt #3.

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,

    I don't know too much about ADS8922B. If the delay in the while(1) loop meets the delay requirement in ADS8922B datasheet, it should work. The buffer length in ADS is 22 bits, what is the CHARLEN used in SPI configuration?
  • CHARLEN is set to 11 bits (max is 16). Also, for a successful data transfer frame with the ADS8922B, I have to provide 22*N clock cycles (N is the number of ADCs in the daisy chain). So from what I understood, this means that I need to set CS low and then provide 66 clock cycles if I want to successfully send/receive data with all 3 of my ADCs. But again, I can see data being sent from the ADCs. My problem is that I am struggling with taking that data and storing it into rxBuff.

     

    This is an example of what I have seen on with the saleae:

    Channel 0 -> CS

    Channel 1 -> SOMI

    Channel 2 -> SIMO

    Channel 3 -> CLK

    Channel 4 -> CONVST

    Channels 5, 6, and 7 are GPIOs connected to the nRST pin of the ADCs

    And this is what I end up storing in rxBuff:

    Theoretically, rxBuff should instead be filled with the values observed on the SOMI line. In this case, rxBuff should have been:

    rxBuff[0] = 1952   ->   0x7A0   ->   11110100000

    rxBuff[1] = 1744   ->   0x6D0   ->   11011010000

    rxBuff[2] = 124     ->   0x07C   ->   00001111100

    rxBuff[3] = 768     ->   0x300   ->   01100000000

    rxBuff[4] = 7         ->   0x007   ->   00000000111

    rxBuff[5] = 1728   ->   0x6C0   ->  11011000000

    Which is not the case. What am I missing?