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.

AM62A7: Using i2c in SBL before the System_init function

Part Number: AM62A7
Other Parts Discussed in Thread: SYSCONFIG

Tool/software:

Hi Ti:

We wanted to configure the PMIC using i2c before initializing the DDR in the first stage of the SBL, but found that the code to initialize both DDR and i2c was in the System_init function, which was automatically generated. What do I need to do to use I2C before initializing DDR?

  • Hello Wu,

    Thank you for your question.

    Kindly confirm if you are talking about the file directory mentioned on top of the screenshot?

    Allow us sometime to look inside System_init() to see where the I2C is being initialized, because as per my understanding Drivers_open() takes care of this functionality.

    Please expect responses in few business days.

    Regards,

    Vaibhav

  • Hello 

    What I'm talking about is exactly the file on the screenshot, I'm sorry I reconfirmed that I2c initialization is in the Drivers_open()  function.

    The initialization of the DDR is in System_init(), and it also configures the clock and so on.

    But we want to configure PMIC before DDR initialization, which requires I2c.

    As I understand it, I should not be able to modify System_init(), since it is automatically generated.

  • Hi Wu,

    Thanks for your patience.

    As I understand it, I should not be able to modify System_init(), since it is automatically generated.

    Yes, the above understanding is correct. You will not be able to edit the System_init() function as it is auto generated through the Sysconfig.

    To initialize the peripheral in user defined order, you can create another function with name _System_init() in the main file and copy the content of Sysconfig generated System_init() function. You can change the order of peripheral initialization in the custom function. 

    Now comment the System_init() function call in the main.c and call the custom function created.

    Please find below example code.

    /* main.c */
    
    
    void _System_init(void)
    {
        /* DPL init sets up address transalation unit, on some CPUs this is needed
         * to access SCICLIENT services, hence this needs to happen first
         */
        Dpl_init();
        /* We should do sciclient init before we enable power and clock to the peripherals */
        /* SCICLIENT init */
        {
    
            int32_t retVal = SystemP_SUCCESS;
    
            retVal = Sciclient_direct_init();
            DebugP_assertNoLog(SystemP_SUCCESS == retVal);
    
        }
    
        PowerClock_init();
        /* Now we can do pinmux */
        Pinmux_init();
        /* finally we initialize all peripheral drivers */
        OSPI_init();
    	
    	GTC_init();
    
        I2C_init();
        
        DDR_init(&gDdrParams);
        /* UDMA */
        {
            uint32_t        instId;
            int32_t         retVal = UDMA_SOK;
    
            for(instId = 0U; instId < CONFIG_UDMA_NUM_INSTANCES; instId++)
            {
                retVal += Udma_init(&gUdmaDrvObj[instId], &gUdmaInitPrms[instId]);
                DebugP_assert(UDMA_SOK == retVal);
            }
        }
        Drivers_uartInit();
    }
    
    
    void main()
    {
        // System_init();
        _System_init();
    }
    

    Please let us know if the above solution works.

    Regards,

    Tushar