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.

ADS1120EVM: Unable to write or read register

Part Number: ADS1120EVM
Other Parts Discussed in Thread: ADS1120, HALCOGEN

Hi

 I am new to this converter and testing my ADS1120 with simple write register and read register commands to learn how this works.  I am testing this with Mibspi protocol.

I am using Halcogen to generate drivers. I have created 3 transfer group for this. TS0 5 bytes, TS1 1 byte, TS2 3 bytes and TS3 4bytes.

I am running this code in RM48 as master.

Here is my code:

void main(void)

{

/* USER CODE BEGIN (3) */

uint16_t resetCmd = 0x06;

uint16_t startCmd = 0x08;

uint16_t writeRegCmd[5] = {0x43, 0x08, 0x04, 0x10, 0x00};

uint16_t readRegCmd = 0x23;

uint16_t rxBuffer[4] = {0};

/* Initialize RTI driver */

rtiInit();

/* Enable RTI Compare 0 interrupt notification */

rtiEnableNotification(rtiNOTIFICATION_COMPARE0);

/* Enable IRQ - Clear I flag in CPS register */

/* Note: This is usually done by the OS or in an svc dispatcher */

_enable_IRQ();

/* Initialize MibSpi*/

mibspiInit();

//Reset ADC1120

mibspiSetData(mibspiREG1, 1, &resetCmd);

mibspiTransfer(mibspiREG1, 1);

while(!(mibspiIsTransferComplete(mibspiREG1, 0)));

// Write values to all 4 registers

mibspiSetData(mibspiREG1, 0, writeRegCmd);

mibspiTransfer(mibspiREG1, 0);

while(!(mibspiIsTransferComplete(mibspiREG1, 0)));

// Read values back from all 4 registers

mibspiSetData(mibspiREG1, 1, &readRegCmd);

mibspiTransfer(mibspiREG1, 1);

while(!(mibspiIsTransferComplete(mibspiREG1, 1)));

//Get data

mibspiGetData(mibspiREG1, 3, rxBuffer);

mibspiTransfer(mibspiREG1, 3);

while(!(mibspiIsTransferComplete(mibspiREG1, 1)));

mibspiSetData(mibspiREG1, 1, &startCmd);

mibspiTransfer(mibspiREG1, 1);

while(!(mibspiIsTransferComplete(mibspiREG1, 1)));

/* Start RTI Counter Block 0 */

rtiStartCounter(rtiCOUNTER_BLOCK0);

/* Run forever */

while(1);

/* USER CODE END */

}

here is how I connected ADS to RM48

/* Wire connections

* ADS1120   ----    RM48

* TP5 - Black ->   DOUT

* TP3 - Orange -> - DIN

* TP2 - White ->  SCLK

* TP1 - Purple ->  CS

*/

When I try to read the register values, I am getting FF for all 4 registers. Now I am stuck at this point and need some help to move forward.

Here is what protocol analyzer shows:


Thanks

Thomas

  • Hi Thomas,

    Welcome to the forum!  Could you please try inserting the analyzer shots again?  This information would be very helpful.  Also, you must make sure that you wait long enough after the RESET command for the device to restart before attempting to communicate with the ADS1120.

    Best regards,

    Bob B

  • Thanks for the quick response. Now I have added ad delay a after reset command.
    //Reset ADC1120
    mibspiSetData(mibspiREG1, 1, &resetCmd);
    mibspiTransfer(mibspiREG1, 1);
    while(!(mibspiIsTransferComplete(mibspiREG1, 1)));
    __delay_cycles(500000);

    Here is the analyzer output with new delay:
    # Level Index m:s.ms.us Dur Len Err Record Data
    0 0 0:00.000.000 Capture started [08/01/17 13:43:09]
    0 1 0:03.543.064 8.000 us 1 B Transaction 600
    0 4 0:03.558.985 39.800 us 5 B Transaction 43FF 08FF 04FF 10FF 00FF
    0 7 0:03.559.027 8.000 us 1 B Transaction 23FF
    0 10 0:03.559.038 31.800 us 4 B Transaction 00FF 00FF 00FF 00FF
    0 13 0:03.559.072 8.100 us 1 B Transaction 08FF
    0 16 9:01.789.045 Capture stopped [08/01/17 13:52:11]

    Regards

    Thomas
  • Hi Thomas,

    Thanks for the additional info.  For the ADS1120, the communication is 8-bit (byte) oriented whereas the mibspi is 16-bit (word).  So the data length must match correctly.  I'm not that familiar with the mibspi peripheral, so I don't know if you can configure to 8-bit (byte) only transfers.  Monitoring the communication with an oscilloscope or logic analyzer can help to verify the transaction length and data.  The scope shots can also verify that the correct SPI format is being used.  Also, if CS is being used, then CS must stay low throughout the entire communication transaction.  It CS toggles between bytes or words, then the communication will reset on the ADS1120 and the desired action will be canceled.

    If the peripheral requires 16-bit lengths, then the bytes must be assembled together to form the correct communication.  As an example the transmit transaction for the WREG is indicated above as 43FF 08FF 04FF 10FF 00FF, which is incorrect.  However the data can be reassembled to now appear as 4308 0410 00FF where the correct byte order is now transferred to the ADS1120.  The received words must be disassembled to bytes.  

    Best regards,

    Bob B

  • I am also experimenting with Mibspi but looks like I am able to send 8-bit data. In order to d that I need to create Transfer Group with length 1 byte. In my sample code that is what I am using to send reset command. Protocol analyzer shows the following result:
    0 1 0:03.543.064 8.000 us 1 B Transaction 600
    here I am sending 0x06 but you will see 600. That is 06 00, the second byte it the output from ADS. Same for WREG breakdown.
    0 4 0:03.558.985 39.800 us 5 B Transaction 43FF 08FF 04FF 10FF 00FF
    This mean Master sending 0x43 08 04 10 00 the "FF" followed by each send byte are the output from ADS. So the command looks good to me. Then I send a 0x23 and the result is "FF" and try to read the buffer and it show all FFs.
    0 10 0:03.559.038 31.800 us 4 B Transaction 00FF 00FF 00FF 00FF.
    I do have scope connected and I see there is no change it is stays high(FF).

    Regards
    Thomas
  • Hi Thomas,

    You need to verify that only 8 clocks are sent for each transfer of data.  You also need to make sure that CS is low throughout the entire communication transaction.  Can you send me a picture of the connected scope during the WREG data transfer?  (A camera phone shot will be ok, I would just like to verify that the communication is correct.)

    Thanks,

    Bob B

  • Thanks Bob. Here is the Scope result for WREG command.

  • Hi Thomas,

    Use rich formatting on your reply and then click on the insert media icon to upload the image.

    Thanks,

    Bob B

  • Hi Thomas,

    That works!  I have some concerns regarding the spikes on CS.  Those spikes are significant enough to cancel the communication.  Otherwise it appears the communication is correct.  Can you capture the same info, but for the read? 

    Thanks,

    Bob B

  • Here is the output for RREG command.

  • Hi Thomas,

    This plot is much more interesting.  Note CS is not staying low throughout the entire read register communication.  The initial read register command is issued, but then canceled when CS goes high.  You might try holding CS low continuously to see if this helps.  My guess is CS is going high in the write register too, but the communication cycle is happening much more quickly and is only showing as a glitch on the scope.

    Best regards,

    Bob B

  • Yes you are right. I went to Halcogen and selected "Chip Select Hold" from MIBSPI1 Transfer Groups and it did the job.
    Now the read result show in analyzer as:
    0 4 0:01.887.588 40.300 us 5 B Transaction 43FF 08FF 04FF 10FF 00FF
    0 7 0:01.887.632 40.200 us 5 B Transaction 23FF 0008 0004 0010 0000

    Thanks for your help. I was spending way too much time to resolve this issue.

    Thanks
    Thomas