SLVAFV8A July   2024  – July 2025 TPS25751

 

  1.   1
  2.   Abstract
  3.   Trademarks
  4. 1Introduction
  5. 2ADCINX Setting
  6. 3Unique Address Interface Protocol
  7. 4PTCH Mode to APP Mode
    1. 4.1 Step of PTCH Mode to APP Mode
    2. 4.2 Step of Generating Low Region Binary
  8. 5Example Code
  9. 6References
  10. 7Revision History

Example Code

The image file generated from the GUI was slightly modified as shown in the following code.


#include "ti_msp_dl_config.h"
#include "lrb.h"

const uint8_t tps25751_lowRegion_i2c_array[SIZEOFLRB] = {
0x01, 0x00, 0xe0, 0xac, 0xfe, 0xff, 0xff, 0xff, 0x80, 0x06, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 
0x71, 0x3e, 0x9c, 0xb8, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
...
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; 

The file, lrb.h, is shown in the following code for context.


#define SIZEOFLRB  0x2C80   // 11392
/* Maximum size of TX packet, MCU 0xFFF */
#define I2C_TX_MAX_PACKET_SIZE
/* SIZEOFLRB/I2C_TX_MAX_PACKET_SIZE +1 */
#define LRB_NUMBER_OF_PACKETS  (0x0003) 
/* SIZEOFLRB % I2C_TX_MAX_PACKET_SIZE */
#define LRB_REMAINDER         (0x0C82)
extern const uint8_t tps25751_lowRegion_i2c_array[SIZEOFLRB];

The following example code is based upon the MSPM0C110x Driver Library(1) and the steps found in Section 4.1.

    
    /*
     *  1. Wait for Ready for Patch interrupt
     */    
    debounce = 1;
    /* Skip glitch at boot */
    while(debounce)
    {
        while(DL_GPIO_readPins(
                GPIO_SWITCHES_PORT, GPIO_SWITCHES_USER_SWITCH_1_PIN)); 
        delay_cycles(DELAY_500us);
        if(!DL_GPIO_readPins(
                GPIO_SWITCHES_PORT, GPIO_SWITCHES_USER_SWITCH_1_PIN))
        {
             debounce = 0;
        }
    }    
    /*
     *  2. Mode == PTCH
     */    
    readRegister(MODE_REGISTER, MODE_BYTE_CNT, gRxPacket);
    if(gRxPacket[1] != 0x50)
    { 
        delay_cycles(DELAY_10ms);
        readRegister(MODE_REGISTER, MODE_BYTE_CNT, gRxPacket);
    }
    /*
     *  3a. Configure I2Ct_IRQ for CMD1 Complete
     */                                                */
    gTxPacket = (uint8_t*)maskIntReg;
    writeRegister(INT_BYTE_CNT, (uint8_t*)gTxPacket);
    waitingForPD = 1;
    while(waitingForPD)
    {
        /*
         *  3b. Clear Interrupts
         */ 
        gTxPacket = (uint8_t*)clrIntReg;
        writeRegister(INT_BYTE_CNT, (uint8_t*)gTxPacket);
        //  Wait for interrupt to clear
        while(DL_GPIO_readPins(GPIO_SWITCHES_PORT, GPIO_SWITCHES_USER_SWITCH_1_PIN)==0);
        waitingForGoodData = 1;
        while(waitingForGoodData)
        {
            /*
             *  4. Send PBMs Data
             */           
            gTxPacket = (uint8_t*)PBMsData;
            writeRegister(DATA_BYTE_CNT, gTxPacket);
            delay_cycles(DELAY_500us);
            /* 
             * 5. Data Good
             */
            readRegister(DATA_REG, (DATA_BYTE_CNT-1), gRxPacket);
            if(gRxPacket[1] == 0x80)
            {
                waitingForGoodData = 0;
            }
        }
        /*
         *  6. Send PBMs to CMD1
         */
        gTxPacket = (uint8_t*)PBMsCmd;
        writeRegister(CMD_BYTE_CNT, gTxPacket);
        /*
         *  7. Wait for I2Ct_IRQ
         */
        while(DL_GPIO_readPins(
                    GPIO_SWITCHES_PORT, GPIO_SWITCHES_USER_SWITCH_1_PIN));
        /*
         *  8. CMD1 Clear
         */
        readRegister(CMD_REG, (CMD_BYTE_CNT-1), gRxPacket);
        /*
         *  9. DATA1 Clear
         */
        readRegister(DATA_REG, (DATA_BYTE_CNT-1), gRxPacket);
        if(gRxPacket[1] == 0x0)
        {
            waitingForPD = 0;
        } 
    }
    /*
     *  10. Burst Data
     */
    ii = LRB_NUMBER_OF_PACKETS;
    while(ii)
    {
        if(ii == 1)
        {
            gTxLen = LRB_REMAINDER;
        }
        else 
        {
            gTxLen = I2C_TX_MAX_PACKET_SIZE;        
        }
        /* The FIFO is 8-bytes deep, and this function returns number of bytes written to FIFO */
        gTxPacket = (uint8_t*)&tps25751_lowRegion_i2c_array[(LRB_NUMBER_OF_PACKETS-ii)*I2C_TX_MAX_PACKET_SIZE];
        ii = ii-1;
        gTxCount = DL_I2C_fillControllerTXFIFO(I2C_INST, gTxPacket, gTxLen);
        DL_I2C_enableInterrupt(
                I2C_INST, DL_I2C_INTERRUPT_CONTROLLER_TXFIFO_TRIGGER);
        gI2cControllerStatus = I2C_STATUS_TX_STARTED;
        while (!(
            DL_I2C_getControllerStatus(I2C_INST) & DL_I2C_CONTROLLER_STATUS_IDLE))
            ;
        DL_I2C_startControllerTransfer(
            I2C_INST, I2C_TGT_BURST_ADDRESS, DL_I2C_CONTROLLER_DIRECTION_TX, gTxLen);
        while ((gI2cControllerStatus != I2C_STATUS_TX_COMPLETE) &&
            (gI2cControllerStatus != I2C_STATUS_ERROR)) {
            __WFE();
        }
        while (DL_I2C_getControllerStatus(I2C_INST) &
            DL_I2C_CONTROLLER_STATUS_BUSY_BUS)
            ;
        /* Trap if there was an error */
        if (DL_I2C_getControllerStatus(I2C_INST) &
            DL_I2C_CONTROLLER_STATUS_ERROR) {
            __BKPT(0);
        }
        while(!(
            DL_I2C_getControllerStatus(I2C_INST) & DL_I2C_CONTROLLER_STATUS_IDLE))
            ;
        delay_cycles(DELAY_500us);
    }
    /*
     *  11. Clear Interrupts
     */
    gTxPacket = (uint8_t*)clrIntReg;
    writeRegister(INT_BYTE_CNT, (uint8_t*)gTxPacket);
    //  Wait for interrupt to clear
    while(DL_GPIO_readPins(
        GPIO_SWITCHES_PORT, GPIO_SWITCHES_USER_SWITCH_1_PIN)==0)
        ;
    /*
     *  12. Send PBMc to CMD1 Register
     */
    gTxPacket = (uint8_t*)PBMcCmd;
    writeRegister(CMD_BYTE_CNT,gTxPacket);
    /*
     *  13. I2Ct_IRQ == Low, CMD1 complete
     */
    while(DL_GPIO_readPins(
        GPIO_SWITCHES_PORT, GPIO_SWITCHES_USER_SWITCH_1_PIN));
    /*
     *  14. Read CMD1
     */
    readRegister(CMD_REG, (CMD_BYTE_CNT-1), gRxPacket);
    /*
     *  15. Delay 20ms
     */
    delay_cycles(DELAY_20ms);
    /*
     *  16. Read Data1 
     */
    readRegister(DATA_REG, 0x28, gRxPacket);
    /*
     *  17. MODE === APP 
     */          
    waitingForPD = 1;           
    while(waitingForPD)
    {
        readRegister(MODE_REGISTER, MODE_BYTE_CNT, gRxPacket);
        if(gRxPacket[1] == 0x41)
        {
            waitingForPD = 0;
        }
        else 
        {
            delay_cycles(DELAY_10ms);
        }
    }
MSPM0 SDK (2.05.00.05)/Examples/Development Tools/LP_MSPM0C1104 LaunchPad/DriverLib/i2c_controller_rw_multiple_fifo_interrupts