infineon4engineers Facebook

infineon@google+ Google+

infineon@linkedin linkedin

infineon4engi@twitter twitter

infineon@youtube youtube

+ Reply to Thread
Results 1 to 4 of 4

Thread: TLE5012B E1000 with Arduino Mega

  1. #1
    New Member New Member ManikantaRaju is on a distinguished road
    Join Date
    Mar 2017
    Posts
    2
    Points
    35

    TLE5012B E1000 with Arduino Mega

    I have recently purchased TLE5012B E1000 and trying to interface it with an Arduino Mega. I am receiving data but that seems like junk data. My SPI settings are SPI mode 0, SPI CLK 8 MHz. I am using the same circuit as in the datasheet for the SSC interface. I am using a delay of 10 microseconds before reading data from the sensor. The MOSI is configured as input before reading the data and then the data is read. Once the data is read MOSI pin is set back to output.
    Below is the debug data I get on my serial monitor.
    SPI: Sent 80, end of message
    SPI: Sent 1, end of message
    SPI: Received F0, end of message
    SPI: Received 40, end of message
    SPI: Received 5B, end of message
    SPI: Received C9, end of message

    This command is for enquiring the STAT register.

    Code:
    //read function in my library
    void TLE5012::Read(char addr) {
      uint8_t dataOut;
      // variable to hold the command data
      TLE5012_Command cmd;
    
      // 1. Prepare command to be sent
      // read one single word without safety word
      cmd.Bits.len = 1;
      // read updated values
      cmd.Bits.upd = 0;
      // set starting address
      cmd.Bits.addr = addr;
    
      // this is a magic cookie to lock access to sys regs.
      if (addr > 4) {
        cmd.Bits.lock = TLE5012_MAGIC_SYSREG;
      } else {
        cmd.Bits.lock = 0;
      }
    
      // read operation
      cmd.Bits.rw = 1;
    
      // 2. start SPI, enable CS
      spiStart();
    
      // 3. send data on MOSI pin
      spiSend(cmd.w >> 8);
      spiSend(cmd.w);
    
      // 10 nops should cause about 250ns stall
    	//delayMicroseconds(10);
    	delay(2000);
    
    	
      // 4. read adat from TLE5012
      dataOut = getByteFromSpi();
      dataOut = getByteFromSpi();
      dataOut = getByteFromSpi();
      dataOut = getByteFromSpi();
    
      // 5. Stop SPI, disable CS
      spiEnd();
    
      // return 0;
    }
    
    //main code
    #include <spi_helper.h>
    #include <TLE5012.h>
    
    TLE5012 AngleSensor;
    void setup() {
      // put your setup code here, to run once:
      Serial.begin(9600);
      AngleSensor.Init();
    //  delay(100);
    //  AngleSensor.Read(AVAL);
      delay(100);
      AngleSensor.Read(STAT);
    
    }
    
    void loop() {
      // put your main code here, to run repeatedly:
    
    }
    Can someone please help me out.

  2. #2
    Beginner Beginner forix is on a distinguished road
    Join Date
    Feb 2012
    Location
    Munich
    Posts
    57
    Points
    236.25
    Hi,
    Looking to the datasheet figure 4-7 SSC timing my guess is that the SPI mode should be 1 instead of 0. The TLE5012B is shifting out the data with the rising edge of the clock and the Arduino should read with falling edge of the clock.

  3. #3
    New Member New Member ManikantaRaju is on a distinguished road
    Join Date
    Mar 2017
    Posts
    2
    Points
    35
    Quote Originally Posted by forix View Post
    Hi,
    Looking to the datasheet figure 4-7 SSC timing my guess is that the SPI mode should be 1 instead of 0. The TLE5012B is shifting out the data with the rising edge of the clock and the Arduino should read with falling edge of the clock.
    Hi thanks for the reply. I am still unable to get valid data when I change SPImode to 1 instead of 0. below is the data for two different modes

    //mode 0
    MODE 4 reg
    SPI: Sent D0, end of message
    SPI: Sent E1, end of message
    SPI: Received 94, end of message
    SPI: Received 10, end of message
    SPI: Received 5F, end of message
    SPI: Received 35, end of message // crc from sensor

    calculated CRC8 3B

    //mode 1
    SPI: Sent D0, end of message
    SPI: Sent E1, end of message
    SPI: Received 9C, end of message
    SPI: Received 10, end of message
    SPI: Received 7F, end of message
    SPI: Received 3F, end of message //crc from sensor

    calculated CRC8 B0

  4. #4
    New Member New Member tony.mackenzie is on a distinguished road
    Join Date
    Jun 2018
    Posts
    1
    Points
    20
    Hi ManikantaRaju,

    Did you ever get this sensor to work?

+ Reply to Thread

Tags for this Thread

Disclaimer

All content and materials on this site are provided “as is“. Infineon makes no warranties or representations with regard to this content and these materials of any kind, whether express or implied, including without limitation, warranties or representations of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. No license, whether express or implied, is granted by Infineon. Use of the information on this site may require a license from a third party, or a license from Infineon.


Infineon accepts no liability for the content and materials on this site being accurate, complete or up- to-date or for the contents of external links. Infineon distances itself expressly from the contents of the linked pages, over the structure of which Infineon has no control.


Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Usage Terms of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Usage Terms of this site. Infineon reserves the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.