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.

I2c driver modification in combination of audioSample.pjt and mmcsdSample.pjt C6747 EVM

Hi all,

I try to merge audioSample.pjt with mmcsdSample.pjt because i want to record the sound and store the data in SD card.

As stated in: http://e2e.ti.com/support/dsp/tms320c6000_high_performance_dsps/f/115/p/51523/183305.aspx#183305

i2c0 are used both for AIC31 and the SD control, so i have to set different device address for these two divice.

First, i check the init function:

Void mmcsdUserI2cInit()
{
    I2c_init();

    mmcsdI2cParams = I2c_PARAMS;
    mmcsdI2cParams.busFreq = 200000u;
    mmcsdI2cParams.hwiNumber = 8u;

    /* configure I2c for edma mode                                            */
    mmcsdI2cParams.opMode = I2c_OpMode_INTERRUPT;

    /* power on the MMCSD device in the Power sleep controller                */
    Psc_ModuleClkCtrl(Psc_DevId_1, CSL_PSC_MMCSD0, TRUE);
    /* Bring the GPIO module out of sleep state                               */
    Psc_ModuleClkCtrl(Psc_DevId_1, CSL_PSC_GPIO, TRUE);
}

and

void audioUserI2cInit()
{
    I2c_init();
    audioI2cParams = I2c_PARAMS;
    audioI2cParams.hwiNumber = 8u;
    audioI2cParams.opMode = I2c_OpMode_INTERRUPT;
}

I did not find where to set the slave device (here they are AIC31 and that for mmcsd part) address.

I found:(in Aic31.h)

static Bool aic31I2cRead(Aic31_Object         *instHandle,
                         Uint32                deviceId,
                         ICodec_RegData       *rdRegData)
{
    Uint8                count;    /* Local count variable                    */
    Uint32               regIndex; /* Register index to be written            */
    Uint8               *regData;  /* Pointer to array of register write data */
    Uint8                data[10]; /* Temporary data                          */
    I2c_DataParam        dataBuffer;
    IOM_Packet           ioPacket;
    ......

    /* Read all the registers                                                 */
    for (count = 0; count < rdRegData->regCount; count++)
    {
        /* The following the procedure to read data from Aic31 codec

           Step A: Write the address of the register to be read.
                   Note: The I2C stop should not be issued.
           Step B: Issue I2C restart.
           Step C: Read the value of the register.                            */
        data[0] = regIndex;

        /* Prepare the data to be written to the audio codec                  */
        dataBuffer.slaveAddr = deviceId;
        dataBuffer.buffer    = &data[0];
        .......

But i don't known when function aic31I2cRead() was called in audioSample.pjt and how the parameter deviceId was passed.

is this deviceId the same as that "device id" which is set during create user defined device object i2c0 in Tconf?

Will anyone list a abstract what i need to modify? Some helpful hints will also be welcomed.

Bo Li

  • I looked at the following doc:

    pspdrivers_1_30_01\docs\C6747\C6747_BIOSPSP_Userguide.pdf

    I see the following on page 34:

    Any device that sits on an I2C bus has a corresponding address.  This information would be found inside the data sheet of the given device (e.g. the audio codec, etc.).  Often there are configuration pins to allow you to modify 1 or 2 bits of the address (i.e. for support of multiple devices).

  • Hi,

    For the MMCSD i2c initializations refer to the file "mmcsd_evmInit.c".

    For the AIC31 address are taken directly by the codec driver. If you need to modify the slave addresses refer to the "Aic31Local.h"

    General steps for merging the projects:

    1. Merge the "audio_evmInit.c" and "mmcsd_evmInit.c" files. Take care that the PINMUX for all the devices are initialized properly(Mcasp,i2c,Mmcsd).

    2. Then merge both the examples projects

        1. Merge the "audioSample.tci" and the "mmcsd.tci" files. Remove the duplicate entries for the I2c driver.

        2. Merge the audioSample.tcf and mmcsdSample.tcf files next.

        3. Now merge the sample files .

    Since the I2c driver is used by both the projects, some of the initializations functions would have been called from both the projects.Hence while merging the projects take care that the initialization functions are not duplicated and are called only once.

    regards,

    imtiaz SMA

     

     

     

     

  • Thanks, i am trying to merge the files, Hope i can fix it.

  • Hi imtiaz,

    I follow your steps to merge the two projects. The new project is built alright. Unfortunately, "Error getting drive ID." happens returned by excuting "result = getdriveid(BFS_DEVICE_TYPE_MMC, 0 , 0, driveId);"  I try to debug into the function getdriveid(), but the file rtfsPosix.c cannot be found, and I cannot search it neither. When I comment "result = getdriveid(BFS_DEVICE_TYPE_MMC, 0 , 0, driveId);", I can hear the audio from HPout. So i think device "i2c0" is initialized OK.

    The two projects are: audioSample.pjt in pspdrivers_01_30_01 and mmcsdSample.pjt in rtfs_1_10_01_31 example.

    EDMA version: edma3_lld_01_11_01_04

    cgt 6.1.9; ccs: 3.3; BIOS: 5.41.07.24

    Following is the detailed steps I conduct:

    1,

    Imtiaz SMA said:

    1. Merge the "audio_evmInit.c" and "mmcsd_evmInit.c" files. Take care that the PINMUX for all the devices are initialized properly(Mcasp,i2c,Mmcsd).

    I merge file "audio_evmInit.c" and "mmcsd_evmInit.c"  into "audio_mmcsd_evmInit.c", and their header files "Audio_evmInit.h" and "Mmcsd_evmInit.h" into "Audio_Mmcsd_evmInit.h", then in project "evmInit.pjt", I substitue the old files by new merged files and rebuild it.

    Here is the content: audio_mmcsd_evmInit.c and Audio_Mmcsd_evmInit.h

    2,

    Imtiaz SMA said:

    2. Then merge both the examples projects

        1. Merge the "audioSample.tci" and the "mmcsd.tci" files. Remove the duplicate entries for the I2c driver.

        2. Merge the audioSample.tcf and mmcsdSample.tcf files next.

    I comment the line "utils.importFile("ti/pspiom/platforms/evm6747/mmcsd.tci")" and use the devices created by unchanged audioSample.tci. Also, i modify the init function called by i2c0 to _audiommcsdUserInit and paramerter to _audiommcsdParam. What's more, i adopt only one task.

    Here is the merged audio_libo.tcf and audio_libo.tci. (I modified the project audioSample.pjt a bit into audio_libo.pjt, and it works fine before i merge it with mmcsdSample.pjt)

     3,

    Imtiaz SMA said:

       3. Now merge the sample files .

     

    First, I merge the main function:

    main said:

    Void main(Void)
    {
        LOG_printf(&trace,"\r\nAudio Sample Main\n");

        /* call the function to configure the evm specific options                */
        configureAudio();

      /* DSP/BIOS File System initialization */
        rtfsPosixInit();

        /* Create semaphore for card insert/remove interrupt mode */
        cardDetectSem = SEM_create(0, NULL);
       
        return;
    }

    Second, i move the configureMmcsd() and mmcsdStorageInit(), etc al into audio echo task:

    echo task said:

    ........

    Void Audio_echo_Task()
    {
        volatile int i32Count;
        Int nmadus = 0;
         Int16 *rcv,*xmt;
     /*  From mmcsdSample.c ======================= */
     Int32       result;
        char        driveId[3];

        LOG_printf(&trace,"\r\nMMC/SD Application Task Starting.");

        /* Configure MMC/SD */
        configureMmcsd((PSP_mmcsdGpioInputIsr)mmcsdGpioInputIsr);

        LOG_printf(&trace,"\r\nConfigured MMC/SD card.");

        /* Initialize for MMC/SD storage device */
        result = mmcsdStorageInit();
        if (result == SUCCESS) {
            LOG_printf(&trace,"\r\nBlock Driver initialization succeeded.");
        }
        else {
           /* Most likely not enough memory */
            LOG_printf(&trace,"\r\nBlock Driver initialization failed, error = %d.", result);
            return;
        }

        /* verify that the MMC/SD card is present before continuing */
        PollDeviceReady();

        /* Get drive letter associated with MMC/SD       */
        result = getdriveid(BFS_DEVICE_TYPE_MMC, 0 , 0, driveId);
        if (result != -1) {
            LOG_printf(&trace,"\r\nGet drive ID DONE. %s", driveId);
        }
        else {
            LOG_printf(&trace,"\r\nError getting drive ID.\n");
            return;
        }
     
     LOG_printf(&trace,"\r\nMMCSD File Operations Starting.");
        //doFileIO(driveId);

        /* initialise the edma library                                            */
        edma3init();

        /* Call createStream function to create I/O streams                       */
        createStreams();

        /* Call prime function to do priming                                      */
        prime();

        /* Forever loop to continously receviec and transmit audio data           */
        for (i32Count = 0; i32Count >= 0; i32Count++)
        {

            ....audio process.....   

        }
       
        LOG_printf(&trace,"\r\nStarting rtfs shell.");
        //bfs_shell();

        /* Shutdown the MMCSD storage device */
        result = mmcsdStorageDeInit();
       
        if (result == SUCCESS) {
            LOG_printf(&trace,"\r\nmmcsdStorageDeInit succeeded.");
        }
        else {
            LOG_printf(&trace,"\r\nmmcsdStorageDeInit failed, error = %d.", result);
        }
    }  

    regards,

    Bo Li 

  • Hi Bo Li,

    Are you using the example project from the PSP drivers package for the mmcsd? If no, can you please try using this code.

    Also check if the card detect logic in triggerring an interrupt and the i2c channels are properly in the mmcsd configuration function

    regards,

    imtiaz

     

  • Imtiaz SMA said:

    Are you using the example project from the PSP drivers package for the mmcsd? If no, can you please try using this code.

    I use the example project from rtfs_1_10_01_31, cause i want to read the data in SD card into the computer after I recorded data and saved them in SD. I think i have to implement a filesystem on SD card.

    Anyway, I will try the example project from PSP drivers package.

    Regards,

    Bo Li

  • Hi Bo Li!

    I'm working in merged the two sample projects to save the audio into SD card? Can you fix your problem? I'm new in this kind of thing and I have a lot of questions. Can you give me some advice?

     

    Thanks!

     

     Paulina