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/TMS570LS1224: TMS570LS1224 : L3GD20H three axis SPI Sensor

Part Number: TMS570LS1224
Other Parts Discussed in Thread: HALCOGEN,

Tool/software: Code Composer Studio

could anyone help me in getting device id value which is 0xD7 from WHO_AM_I register 

my halcogen configurations are enabled the SPI1 driver  , check clock polarity (1)and clock phase (0)  and SPI frequency is 10 MHz. (Baudrate set to 300K HZ) with charlen 8 (as device id should be only 8 bits) ,In SPI1 Port i enabled each (SIMO[0],SOMI[0],CLK  and  (SCS[0] ) as SPI and the others as GIO    ) then i  generated the code

in my code i received 0xFF and the oscilloscope shows SDO is always high ,i don't know why

#include "sys_common.h"

/* USER CODE BEGIN (1) */
#include "spi.h"


/* USER CODE BEGIN (2) */
uint16 TX_Data_Master[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint16 RX_Data_Master[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

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

    // The chip select signal is held continuously active during several consecutive data word transfers
    dataconfig1_t.CS_HOLD = TRUE;

    /* After a transaction, WDELAY of the corresponding data format will be loaded into the delay counter.
     No transaction will be performed until the WDELAY counter overflows. The SPISCS pins will be deactivated
     for at least (WDELAY + 2) * VCLK_Period duration. */
    dataconfig1_t.WDEL    = TRUE;

    // Data word format 0 is selected
    dataconfig1_t.DFSEL   = SPI_FMT_0;

    // Chip select number. CSNR defines the chip-select that will be activated during the data transfer (0 in our case).
    dataconfig1_t.CSNR    = 0xFE;

    spiInit();
    
    while(1)
    {
      
        TX_Data_Master[0] =0x80|0x0F;  //0x8F who_am_i address
        spiTransmitAndReceiveData(spiREG1, &dataconfig1_t, 2, TX_Data_Master, RX_Data_Master);

        printf("Device ID = %x\r\n",RX_Data_Master[1]);

      }
}


  • Hello,

    Is it possible to share your project ( both HALCoGen and CCS ) ?

    What happens on SIMO pin? Did you probe it with oscilloscope.

  • Hello Miro ,

    the oscilloscope shows the correct signal of SDA (SIMO)

    but THE SDO (SOMI) shows the signal is always high

    i think the problem is with CS

    here is my project

    8203.spi_2.rar

  • Hello,

    Also, did you check the wiring?

  • Hello Miro,

    SIMO shows the correct signal which is (10001111)

    sOMI shows (always high signal ) (11111111)

    also 

    my connection is 

    L3G     Vin -------------  5V       TMS570LS1224 

               GND ------------GND

              SDA--------------- J9.6 (MIBSPI1SIMO)

             CLK ----------------J6.7 MIBSPI1CLK

             SDO--------------J9.7  (MIBSPI1SOMI)

             CS----------------J9.3 (MIBSPI1NCS[0])

           

    3531.spi_2.rar

  • Hello,

    According to sensor datasheet Absolute maximum for Vdd is 4.8V and if you are connecting Vdd to 5V the sensor could be damaged. Please check whether Vdd_IO is powered as well. VCCIO for TMS570LS1224 is 3.3V as well. Later I'll take a look at code.

  • Hello,

    i connected the sensor with arduino and it works perfectly giving device id, each of x,y, and z readings

    so it was't damaged 

  • Hello,

    I've just import the attached project. SIMO sends the correct value (according to datasheet). I don't see any issues from MCU side. If wiring is fine and sensor is powered according to datasheet, you should read WHO_AM_I value. Be careful and follow Absolute maximum ratings when powering the sensor. VCCIO of TMS570LS1224 is 3.3V.

    Since I am not familiar with this sensor I can't be more specific. Please, try to reach sensor manufacturer forum for assistance (MCUs SPI is working as expected).

  • how to use bangbits approach with hercules (to use clk,cs,SIMO,SOMI ) as GPIO

    i find this function.
    any help

    void SendBitsAD(uint16_t bits16) { uint16_t x; for (x = 0; x < 16; x++) { if (bits16 & 0x8000) { GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_7, 0xFF);////Set SDATA according to MSB in cmd (HIGH) } else { GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_7, 0x00);////Set SDATA according to MSB in cmd (LOW) } SysCtlDelay(0x800);//data setup time GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_4, 0xFF);//// //CLK transistion to latch the bit into the AD99 high SysCtlDelay(0x800); GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_4, 0x00);//// //CLK transistion to latch the bit into the AD99 low SysCtlDelay(0x800); bits16 <<= 1; //Shift to next bit in cmd } GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_7, 0x00);////Set SDATA stall low }

  • Hello,

    I assume you succeed with reading the sensor using SPI and that is why I am going to close this thread? If you have more questions about using SPI module you can reopen this thread with writing at the end or you can open another thread.