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.

LP-MSPM0G3507: TMAG3001

Part Number: LP-MSPM0G3507
Other Parts Discussed in Thread: MSPM0G3507, TMAG3001, OPT3001

Tool/software:

Hi, I made this board according to the TMAG3001 documentation, but I don't know how to use MSPM0G3507 to read its angle value. Can you provide a sample code?

  • Hi, thanks for the question! As far as the I2C goes, there are many examples in the CCS MSPM0 SDK for both controller mode as well as peripheral mode. Assuming you have gone through the TMAG3001 datasheet and set all of your configurations to your specific use case, you should be able to send a read request to the TMAG like this:

    #define I2C_TX_PACKET_SIZE (2)
    
    #define I2C_RX_PACKET_SIZE (6)
    
    #define I2C_TARGET_ADDRESS (0x??)
    
    gTxPacket[2] = [0x12, ......] ; // register of x axis MSB
    
    gRxPacket[6];  // assuming you are going to read all 6 registers of MSB/LSB for all axes
    
    DL_I2C_fillControllerTXFIFO(I2C_INST, &gTxPacket[0], I2C_TX_PACKET_SIZE);
    
    DL_I2C_startControllerTransfer(I2C_INST, I2C_TARGET_ADDRESS, DL_I2C_CONTROLLER_DIRECTION_RX, I2C_RX_PACKET_SIZE);
    
    for (uint8_t i = 0; i < I2C_RX_PACKET_SIZE; i++) {
        while (DL_I2C_isControllerRXFIFOEmpty(I2C_INST))
               ;
        gRxPacket[i] = DL_I2C_receiveControllerData(I2C_INST);
    }
    
    

    I am using the i2c_controller_rw_multibyte_fifo_poll as an example, but you can choose another to best suit your needs. Hope this helps!

  • Thank you so much. Now I read the angle value of the x-axis by the mode"I2C Read Command for 8-Bit Data With CRC Disabled, X-Axis Enabled"

    , but I don't know how to configure each register in this mode.The picture3 shows the code I wrote. Can you help me take a look

  • So this should be similar to the read, you will need to have the address of the register you are writing/configuring, so something like this:

    The specifics for the config registers is more of an OPT3001 question, but this is one way to write to the registers. Hope this helps!