Skip to main content
xpp07
Associate III
September 21, 2018
Solved

Reading current sensor via SPI (Solved)

  • September 21, 2018
  • 12 replies
  • 2823 views

I'm having problems to read my current sensor, which is located at the source leg of a power transistor. 

I'm using the sensor TLI4970

This is my routine every 10ms:

HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_RESET); //Bring slave select low
 
HAL_SPI_Receive(&hspi1, (uint8_t *)&SPIRx, 2, 10); //Receive data
 
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_SET); //Bring slave select high

However, I get random values even when the current is zero. I'm getting values like:

0x8800

0x8803

0x8801

0xA7FF

0x87FC

0x97FE

0xA802

0xA801

0x97FD

0x87FD

0xA800

0xA7FE

According to the datasheet, these are sensor status messages, but none of them are Sensor Current Messages. The hardware seems okay. This sensor is not so common I think. I haven't found much help. Am I doing something wrong in software?

    This topic has been closed for replies.
    Best answer by xpp07

    Fixed. My clock phase was wrong. I had SP1 mode 0 , but the right one is the Mode 1.

    12 replies

    xpp07
    xpp07AuthorBest answer
    Associate III
    September 22, 2018

    Fixed. My clock phase was wrong. I had SP1 mode 0 , but the right one is the Mode 1.

    T J
    Senior III
    September 23, 2018

    great please mark this question as answered, CPOL... CPHA