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.

SM470R1B1M SPI with ADS1243

Other Parts Discussed in Thread: ADS1243

Hello,

I have what might be a very trivial problem for someone more experienced with these older processors than me. 

I am trying to communicate with the ADS1243 ADC via SPI. On the scope everything seems fine however when I try to read the SPIBUF register in the code I always receive a "stupid" response. Normally either 0x00 or 0xFF. 

This sample code snippet with debug (written for Keil but easily understandable) shows me simply trying to read the Mux register which is at its PORST value of 0x01 (and proven by the scope). It always returns a value of 0xFF. Does anyone have any ideas to point me in the right direction? (I know there are one or two redundant lines like the "clearing" of the SPIBUF before continuing - I could just ignore that and move on, but for the purposes of showing what I had tried with flag clearing etc, I left them in. 

	SelectADC();
    spiVal = pSPI2->SPIBUF;
	// Send Write Register command 
	pSPI2->SPIDAT0 = (ADC_READ_FROM_REG | ADC_REG_MUX);
   	// discard spibuf contents
    spiVal = pSPI2->SPIBUF;
	// length to respond - write (value + one) byte 
	pSPI2->SPIDAT0 = 0x00;
    // discard spibuf contents
    spiVal = pSPI2->SPIBUF;
   if (pSPI2->SPICTRL3 & 0x01)
   {
      TXByteUART(0x11); //prove flag is clear before moving on
   }
    // allow byte to be returned 50 cycles min
    for (i = 0; i<32; i++ );                      // wait for result to be produce
    pSPI2->SPIDAT0 = ADC_READ_DUMMY;	 			// tx no data to receive resp.
   TXByteUART(0xAA);
   while (!(pSPI2->SPICTRL3 & 0x01));              //wait for message, should be redundant in sync protocol 
   if (pSPI2->SPICTRL3 & 0x01)
   {
      TXByteUART(0x22); //just to check flag is set!
   }
   spiVal = pSPI2->SPIBUF;
   TXByteUART(spiVal);
   TXByteUART(0xAD);
   TXByteUART('\n');
   //sprintf( textBuf, "Ret'd Val 0x%2X\n", spiVal );
   //TXStringUART((unsigned char*)textBuf);
	DeselectADC();  

Kindest thanks in advance,

Andrew
  • Andrew, just to be clear, from probing the ADC is working and sending "real" data?
    The issue is reading proper data from SPI BUF?
    Have you examined the code used in the HEATEVM?
    http://www.ti.com/tool/heatevm?keyMatch=heatevm&tisearch=Search-ENRegards,
    Wade
  • Hello,

    Thanks for your comment, yes - the ADC is returning real data on the SPI. However after spending today working on this I have discovered that the actual issue is that the data is not ready in SPIBUF immediately after the SPI is complete. adding a short delay between the dummy transmission and reading the SPIBUF register overcomes the issue. The interrupt flag is set before the data is valid (this was my original check which doesn't work - this is how it is implemented in the example code).

    If you know anything further about this issue please feel free to comment. If not, my workaround is acceptable for my application and I suggest we can move on.

    Kind thanks.