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.

TMS320F28379D: Issues while using SPI to rad data from Sensors

Part Number: TMS320F28379D

We are using TMS302F28379D to read ADXRS290 gyroscope data. According to datasheet, SPI mode is POL1 and PHA 1 but we are only able to read and write correct data from ADXRS290, if we set POL1 and PHA0.
We also checked with an IMU, which has similar SPI mode requirement and have observed similar behaviour that the correct data is received only when SPI configuration is set to POL1 and PHA0. Below is the configuratiuon which worked for us.

GPIO_setPinConfig(GPIO_58_SPISIMOA);
	   GPIO_setPadConfig(58, GPIO_PIN_TYPE_STD);
	   GPIO_setQualificationMode(58, GPIO_QUAL_ASYNC);

	   GPIO_setPinConfig(GPIO_59_SPISOMIA);
	   GPIO_setPadConfig(59, GPIO_PIN_TYPE_STD);
	   GPIO_setQualificationMode(59, GPIO_QUAL_ASYNC);

	   GPIO_setPinConfig(GPIO_60_SPICLKA);
	   GPIO_setPadConfig(60, GPIO_PIN_TYPE_STD);
	   GPIO_setQualificationMode(60, GPIO_QUAL_ASYNC);

	   GPIO_setPinConfig(GPIO_61_SPISTEA);
	   GPIO_setPadConfig(61, GPIO_PIN_TYPE_STD);
	   GPIO_setQualificationMode(61, GPIO_QUAL_ASYNC);

	   SPI_disableModule(SPIA_BASE);

	// SETTING CLOCK FREQUENCY 1MHz
	   SPI_setConfig(SPIA_BASE, DEVICE_LSPCLK_FREQ, SPI_PROT_POL1PHA0, 
	   SPI_MODE_CONTROLLER, 1000000, 16); // 
	   SPI_setPTESignalPolarity(SPIA_BASE, SPI_PTE_ACTIVE_LOW);

	   SPI_disableFIFO(SPIA_BASE);                          
	   SPI_disableLoopback(SPIA_BASE);
	   SPI_setEmulationMode(SPIA_BASE, SPI_EMULATION_FREE_RUN);
	   SPI_enableModule(SPIA_BASE);

1. What could be reason for the same?

2. We are using the below function to read data from gyroscope and the data is comming correctly

   SPI_writeDataNonBlocking(SPIA_BASE, 0x1002); //0x1002 to enable measurement | 0x1000 to disable measurement
   PWR_CTL=SPI_readDataBlockingNonFIFO(SPIA_BASE);
   DELAY_US(100);
//      Read PWR_CTRL Register
   SPI_writeDataNonBlocking(SPIA_BASE, 0x9000);
   PWR_CTL=SPI_readDataBlockingNonFIFO(SPIA_BASE);

 
   the configuration setting was as below:

GPIO_setPinConfig(GPIO_58_SPISIMOA);
	   GPIO_setPadConfig(58, GPIO_PIN_TYPE_STD);
	   GPIO_setQualificationMode(58, GPIO_QUAL_ASYNC);

	   GPIO_setPinConfig(GPIO_59_SPISOMIA);
	   GPIO_setPadConfig(59, GPIO_PIN_TYPE_STD);
	   GPIO_setQualificationMode(59, GPIO_QUAL_ASYNC);

	   GPIO_setPinConfig(GPIO_60_SPICLKA);
	   GPIO_setPadConfig(60, GPIO_PIN_TYPE_STD);
	   GPIO_setQualificationMode(60, GPIO_QUAL_ASYNC);
	   
	   GPIO_setPinConfig(GPIO_61_SPISTEA);
	   GPIO_setPadConfig(61, GPIO_PIN_TYPE_STD);
	   GPIO_setQualificationMode(61, GPIO_QUAL_ASYNC);
     

   SPI_writeDataNonBlocking(SPIA_BASE, 0x8000);
   Gyro_ID=SPI_readDataBlockingNonFIFO(SPIA_BASE);
   SPI_writeDataNonBlocking(SPIA_BASE, 0x8900);
   MEMS_ID=SPI_readDataBlockingNonFIFO(SPIA_BASE);



// other codes

    for(;;)
    {
           SPI_writeDataNonBlocking(SPIA_BASE, 0x8800);
           xoutlow=SPI_readDataBlockingNonFIFO(SPIA_BASE);
//         Read Higher bit ox X Gyro
           SPI_writeDataNonBlocking(SPIA_BASE, 0x8900);
           xouthigh=SPI_readDataBlockingNonFIFO(SPIA_BASE)
}

The data being read is correct in this case.

 

We also tried the multi-byte read operation and the data was found to be correct when the read and write operation was performed in the main function but outside the "for" loop but when the multi byte read operation is being performed inside the for loop, the incoming data is errorneous.

We configured CS as GPIO when using in this mode.

 

   	   GPIO_setPinConfig(GPIO_58_SPISIMOA);
	   GPIO_setPadConfig(58, GPIO_PIN_TYPE_STD);
	   GPIO_setQualificationMode(58, GPIO_QUAL_ASYNC);

	   GPIO_setPinConfig(GPIO_59_SPISOMIA);
	   GPIO_setPadConfig(59, GPIO_PIN_TYPE_STD);
	   GPIO_setQualificationMode(59, GPIO_QUAL_ASYNC);

	   GPIO_setPinConfig(GPIO_60_SPICLKA);
	   GPIO_setPadConfig(60, GPIO_PIN_TYPE_STD);
	   GPIO_setQualificationMode(60, GPIO_QUAL_ASYNC);
	   
     GPIO_setPinConfig(GPIO_61_GPIO61);                      
     GPIO_setDirectionMode(61, GPIO_DIR_MODE_OUT);
     
      GPIO_writePin(61,1);
   SPI_writeDataNonBlocking(SPIA_BASE, 0x8000);
   Gyro_ID=SPI_readDataBlockingNonFIFO(SPIA_BASE);
   SPI_writeDataNonBlocking(SPIA_BASE, 0x0000);
   MEMS_ID=SPI_readDataBlockingNonFIFO(SPIA_BASE);
         GPIO_writePin(61,0);
//We get correct data here

// other codes

    for(;;)
    {
           SPI_writeDataNonBlocking(SPIA_BASE, 0x8800);
           xoutlow=SPI_readDataBlockingNonFIFO(SPIA_BASE);
           SPI_writeDataNonBlocking(SPIA_BASE, 0x0000);
           xouthigh=SPI_readDataBlockingNonFIFO(SPIA_BASE)
// The data read from sensor comes errorneous.
}

 

3. We are also runnign a 100us timer 0. if this read operation is performed inside the loop, no matter if it is a single byte read operation or multi bye the data received is erroneous.


Request you to help us out in identifying the issue.