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.

TMAG5273: Software examples / drivers / library

Part Number: TMAG5273

Dear Team,

I was wondering if at this moment there is some software examples / drivers / library available for the TMAG5273?

I read in a different thread (from 5 months ago) that there wasn't at that time. But for this time it  seems to me that there needs to be, because;

I have the evaluation module of the TMAG5273, For this evaluation module I can download some firmware on your website on the following URL: TMAG5273 data sheet, product information and support | TI.com

This download only comes with the firmware-image and this works fine on the evaluation module. But now I want to implement this kind of software myself on a custom PCB. On this PCB I already implemented the I2C drives/software myself but it would be very handy (and speed up the development process) if there would be any posibility to get the source files. (or only the specific source files in which the protocol/communication to the sensor is implemented)

Sincerely,

Tim von Unen

  • Hi Tim,

    We still do not have a code example readily available for the TMAG5273; however, section 8.2.1.2 in the datasheet provides register configuration steps for an example TMAG5273 configuration.  Each of the registers mentioned in these steps can be set using the packet structure shown in Figures 7-7 or Figure 7-8.  The registers can also be read using the packet structure shown in Figures 7-9 and 7-10.

    If you can provide some more info on what type of code example you are looking for and your application, we can take this feedback for the future.  Are you just looking for example commands that are used to create the packets shown in Figures 7-7 through 7-10?  These commands would vary based on the selected microcontroller; however, the microcontroller software package may have generic code examples that provide more information on the type of microcontroller commands that can be pieced together to implement the necessary I2C packets for the TMAG5273.

    Regards,

    Mekre

  • Hi Mekre,

     

    Thanks for you resonse!

    It would just be nice to have some header files with defines for register maps, register addresses and their configurable bits. Maybe next to that some example functions on how to compose buffers to write a register for example. It's kind of hard to explain what i exactly mean because there can be a lot of misinpretation. Before I selected the TMAG5273 I used a similar 3D hall sensor of a different manufacturer which had a nice generic library example software which helped me speed up the development process a lot. I don't want to advertise them over here but I can send you a private message with the details so you can have a look at that example software so you know what I mean?

     

    Anyway I started the development and implemented the functions to write and read registers but something seems off:


    At first I want to write the following data using the packet structure shown in figure 7-7 (Standard I2C write) to some configuration registers:
    Device Config1 (Address 0x00): 0x28   (Crc disabled, TempCO = NdBFe, Con_Avg = 4X, I2C_RD = 3-byte read)
    Device Config2 (Address 0x01): 0x12   (Low noise mode, Continuous measure mode)
    Sensor Config1 (Address 0x02): 0x70   (XYZ channels enabled)

     

    The message that I composed an wrote to the chip (confirmed using an oscilloscope):
    0x6A              | 0x80                                               | 0x28                         | 0x12                    | 0x70                     |   
    | AddressWrite | RegAddr 0x00 with trigger bit high | DeviceConf1 Data | DeviceConf2 Data | SensorConf1 Data | 

     

    All bytes had the ack bit low, so acknowledged.

     

    After that I try to read out the registers using the packet structure shown in figure 7-9 to confirm that the write was done correctly. What I expect to see on the oscilloscope:
    0x6A              | 0x80                                   | 0x6B              | 0x28                 | 0x12                | 0x70                  |   

    | AddressWrite | RegAddr 0x00 trigger high | AddressRead | DevCon1 Data | DevCon2 Data | SensCon1 Data | 

     

    What I am seeing on the oscilloscope:

    0x6A              | 0x80                                   | 0x6B              | 0xFF | 0xFF | 0xFF |   

    | AddressWrite | RegAddr 0x00 trigger high | AddressRead | ???? | ???? | ???? | 

     


    Did I do something wrong composing the messages?

     

    Thanks in advance!

     

    Sincerely,

    Tim

  • Hi Tim,

    Can you verify that you have a restart condition between the 0x80 and 0x6B byte?  Here is a logic analyzer screen shot with the restart condition circled in red:

    To help, here is pseudo-code that shows the I2C read process:

    //dataRx array stores values read from registers, byteLength is number of registers to read, and dataTx[1] has address of starting register to read.
    void i2cReceiveArrays(uint8_t dataRx[], const uint8_t byteLength, uint8_t dataTx[])
    {
    
        int i;
    
        //Send start condition and write of register address
        MAP_I2CMasterSlaveAddrSet(I2C2_BASE, SLAVE_ADDRESS_EXT, false); 
        MAP_I2CMasterDataPut(I2C2_BASE, dataTx[1]); 
        MAP_I2CMasterControl(I2C2_BASE, I2C_MASTER_CMD_BURST_SEND_START);
    
        while(MAP_I2CMasterBusy(I2C2_BASE)){}
        while(MAP_I2CMasterBusy(I2C2_BASE)){}
        while(MAP_I2CMasterBusy(I2C2_BASE)){}
        while(MAP_I2CMasterBusy(I2C2_BASE)){}// Delay until transmission completes
    
    
        if(byteLength==1)
        { // If only read one register
    
            //Send restart condition and initiate single read
            MAP_I2CMasterSlaveAddrSet(I2C2_BASE, SLAVE_ADDRESS_EXT, true);
            MAP_I2CMasterControl(I2C2_BASE, I2C_MASTER_CMD_SINGLE_RECEIVE);
            
            while(MAP_I2CMasterBusy(I2C2_BASE)){}
            while(MAP_I2CMasterBusy(I2C2_BASE)){}
            while(MAP_I2CMasterBusy(I2C2_BASE)){}
            while(MAP_I2CMasterBusy(I2C2_BASE)){}// Delay until transmission completes 
            dataRx[0] = MAP_I2CMasterDataGet(I2C2_BASE); //Read register
        }
        else
        { //If read more than one register
    
            //Send restart condition and initiate multiple reads
            MAP_I2CMasterSlaveAddrSet(I2C2_BASE, SLAVE_ADDRESS_EXT, true);
            MAP_I2CMasterControl(I2C2_BASE, I2C_MASTER_CMD_BURST_RECEIVE_START);
            
            while(MAP_I2CMasterBusy(I2C2_BASE)){}
            while(MAP_I2CMasterBusy(I2C2_BASE)){}
            while(MAP_I2CMasterBusy(I2C2_BASE)){}
            while(MAP_I2CMasterBusy(I2C2_BASE)){}// Delay until transmission completes 
            dataRx[0] = MAP_I2CMasterDataGet(I2C2_BASE); //Read first register
    
    
            for (i = 1; i < byteLength-1; i++)
            {
                MAP_I2CMasterControl(I2C2_BASE, I2C_MASTER_CMD_BURST_RECEIVE_CONT);
                while(MAP_I2CMasterBusy(I2C2_BASE)){}
                while(MAP_I2CMasterBusy(I2C2_BASE)){}
                while(MAP_I2CMasterBusy(I2C2_BASE)){}
                while(MAP_I2CMasterBusy(I2C2_BASE)){}// Delay until transmission completes 
                dataRx[i] = MAP_I2CMasterDataGet(I2C2_BASE); //Read registers between first and last registers
            }
    
            MAP_I2CMasterControl(I2C2_BASE, I2C_MASTER_CMD_BURST_RECEIVE_FINISH);
            while(MAP_I2CMasterBusy(I2C2_BASE)){}
            while(MAP_I2CMasterBusy(I2C2_BASE)){}
            while(MAP_I2CMasterBusy(I2C2_BASE)){}
            while(MAP_I2CMasterBusy(I2C2_BASE)){}// Delay until transmission completes 
            dataRx[i] = MAP_I2CMasterDataGet(I2C2_BASE); //Read last register
        }
    
    }
    

    Regards,

    Mekre

  • Hi Merke,

    Well that was stupid of me. I didn't have that restart condition and I actually wrote a new funtion to be able to do a write and a read immediately after eachother without a start/stop condition in between because I thought it did not need to be there, I was just focused on the text of 7.5.1.3.3 Standard 3-Byte I2C Read (which, if i'm correct, doesn't mention that restart condition) and didn't notice the restart condition in figure 7-9...

    Now I've changed things to match your screenshot everything works fine, thank you very much for your help!

    One last question for now: Does the temperature compensation (MAG_TEMPCO bit of DEVICE_CONFIG_1) work when the temperature channel (T_CH_EN bit of T_CONFIG) is disabled? In other words, is there some dependency for the temperature compensation to work?

    Sincerely,

    Tim von Unen

  • Hi Tim,

    I am glad that solved the issue.   

    Also, the temperature compensation should still work when the temperature channel is disabled.  

    Regards,

    Mekre