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.

BIOSPSP mmcsd changing the frequency

Hallo Community!

working on MMCSD fatfs example im writing now 20MB of data in 100 seconds. It looks like the program is still in 215kHz mode. how can i change the frequency to 25MHz?

or need i just leave the initialization mode? and how do this?

i hope some one can help me!

Eugen

  • Hi Eugen,

    Could you please mention which version of the BIOS PSP are you using?

    I guess the clock/freq details are available in the dda_mmcsdCfg.h file.

    Best Regards,

    Raghavendra

  • oh sorry!

    biospsp_03_00_01_00 for C6748 and OMAP L-138

  • i can find this definitions in dda_mmcsdCfg.h

    #define MMCSD_INIT_FREQ_MAX             400000U
    /**< The maximum init frequency during card identification                    */
    #define MMCSD_INIT_CLOCK                215000U
    /**< MMCSD Init clock in Hz(card identification mode should be < 400KHz)      */
    #define MMC_CLOCK                       20000000U
    /**< MMC clock in Hz during data transfer mode                                */
    #define SD_CLOCK                        25000000U
    /**< SD clock in Hz during data transfer mode                                 */
    #define SD_HIGH_SPEED_CLOCK             50000000U
    /**< SD High Speed clock in Hz                   */

    but no functions where this definitions are used

  • Eugen,

    They are used in ddc_mmcsd.c file in "mmcsdCalculateFreqForCard" function to calculate the clock divider values for the card.

    Best Regards,

    Raghavendra

  • Yes i found it, but what do i have to do to switch to 25MHz ?

    is there a command to check out the actual frequency?

  • Eugen,

    As mentioned earlier(dda_mmcsdCfg.h), the frerquency of the card is set to 25MHz itself. How did you calculate the data transfer performance? What is the buffer size used? 100 secs for 20MB is pretty high. The card frequency can be changed by using the IOCTL "PSP_MMCSD_IOCTL_SET_CARD_FREQUENCY". Please refer the Userguide for more details regarding this.

    Best Regards,

    Raghavendra 

  • ok, i was just devided 20MB by 100 and gets my 200Kb, but it looks to be wrong.

    i messured at SD CLK Pin 40MHz, so the frequency seems to be right! and if i change the frequences in dda_mmcsdCfg.h  it works slower...

    so how about buffer? i was allready looking for the buffer size, didn't change it because i cant find the configuration...

    where i have to look?

  • in biospsp_03_00_01_00/driver/blkmedia/include/psp_blkdev.h i found

    /**< Buffer for IO Cache alignment                                            */
    #define PSP_BUFFER_IO_SIZE          0x100000u

    /**< Buffer for ASYNC Cache alignment                                         */
    #define PSP_BUFFER_ASYNC_SIZE       0x7D000u

    changing this has no effect

  • No. Those buffers are used for cache alignment as mentioned. Are you using the BIOSPSP sample application itself or a modified one?. Buffer I meant, how many bytes you were transferring at a time?. 200kb?. So are you able to see the desired frequency for the SD now? 

    Best Regards,

    Raghavendra

  • Hallo Raghavendra,

    thank you for fast answer, sorry i dont know what you mean!

    i'm using BIOSPSP 3.00.01.00 sample application in drivers/examples/mmcsd_fatfs directory and i cant find other declarations for Buffer Size. my writing operation is

    fwrite(speicher, 1, 174, pFile);

    But the red 1 is not the Buffer Size i think, rising this make it much slower

    PS: I think its the problem of the buffer, because i can messure 40MHz with oscilloscope clock Pin of SD Card

    Eugen

  • Eugen,

    I meant, how many bytes you desire to transfer? As per the above post, you seem to transfer 174 bytes. 

    Best Regards,

    Raghavendra

  • oh yes, i have a string of 174bytes! and i'm wqriting it 20000 times on the SD-Card.

    shood i do it bigger? or smaller? i can devide the string or add more together, but i dont think it will be make somethink better

  • Eugen,

    Try with 100KB, 250KB and 400 KB Buffer size and check if there is any difference in performance. 

    Attached is a code snippet of how you can/might implement it. Try it and let me know the results. Hope this is helpful.

    Best Regards,

    Raghavendra

  • Eugen,

    When you write 174 bytes for 20,000, the performance would surely degrade. The flash memory beneath can read/write large data fast, but on the other hand, there is a disadvantage that rewriting a part of data is inefficient. Similarly the FATFS poses a constraint in the performance if the data is not a multiple of block length.  To avoid such bottleneck and increase the write performance, number of blocks per write transaction must be large as possible – twice, thrice or more if possible.

    Source: You can refer FATFS homepage and "improving performance" for more information related to this.

    Hope this helps.

    Best Regards,

    Raghavendra

  • Hallo Raghavendra

    now i tryed every thing if i do just 174 * 20000 i get a time of 1:45, (167*3) 502 * 6666 i get a time of 1:36 but if i do it more the time is not changing, its allways between 1:34 and 1:36. here the changings in mmcsdSample_io.c program: i'm writing 16 Numbers in a line and do it 120000 times and a timestamp will be later at the beginning of every line

    #define PSP_MMCSD_SAMPLE_DRIVE            1U
    /* This is the driver number associated with MMCSD drive                       */
    #define MMC_INST_ID                     0U
    /*Instance no of mmcsd                                                        */

    /*#define NUM_SECTORS                     6144U*/
    #define NUM_SECTORS                        6144U
    /*No of Bytes in drive to format                                              */
    #define FILESYS_BYTE_COUNT                      (NUM_SECTORS * 512U)

    /*No of sectors read or written                                               */
    #define WRITE_SECTORS                 10
    /* No of bytes to write or read                                               */
    #define BYTE_COUNT                      (WRITE_SECTORS *512U)


    #define INCLUDE_MEDIA_WP_TEST           0
    /*This will enable the WP test on the media.                                  */

    #define INCLUDE_ACTUAL_CARD_FREQ_IOCTL  0

    /*This will actually alter the freq of the card.
    Please note that the further operation of the card takes place at this freq*/

    //#define BUFFER_ALINED_CACHE_LENGTH
    /* Enable this if user want to pass cache length aligned buffer, In polled mode
       buffer must be 4 byte aligned */

    #define DATA_ALIGN                      128


    char *filename = "fat:1:marum.txt";//                                                                    FILENAME
    TCHAR *path = "fat:1:marum.txt";//                                                                        FILENAME
    #define READ_BLOCK_SIZE 64

    Void checkMediaCard(UInt32 instanceId);

    Void checkMediaCard(UInt32 instanceId)
    {
        Int32                                   result = IOM_COMPLETED, flag = 1;
        PSP_MmcsdCardType   cardType = PSP_MMCSD_CARDTYPE_NONE;

        while (flag)
        {
            result = PSP_mmcsdCheckCard(&cardType, instanceId);//biosp../drivers/mmcsd/src/dda_mmcsdBios.c
            if (IOM_COMPLETED == result)
            {
                if ((PSP_MMCSD_CARDTYPE_MMC == cardType) ||
                    (PSP_MMCSD_CARDTYPE_SD == cardType))
                {
                    break;
                }
                else
                {
                    MMCSD_SAMPLE_PRINT(" MMCSD_SAMPLE: Please insert the card\r\n");
                    Task_sleep(1000U);
                }
            }
            else
            {
                MMCSD_SAMPLE_PRINT(" MMCSD_SAMPLE: checkCard failed\r\n");
            }
        }
    }

     Void runMmcsdSample()
    {

        Int32 retVal = IOM_COMPLETED;
        FILE *pFile;
        UInt32 loop = 0;
        UInt32 i = 0;
       

        char zwischenspeicher[9] = "";
        char speicher[146] = ""; //without timestamp
        int messung = 16777215;

        checkMediaCard(MMC_INST_ID);
        MMCSD_SAMPLE_PRINT(" MMCSD_SAMPLE:Card is inserted\r\n");

        retVal = PSP_blkmediaFATfsRegister(MMC_INST_ID, PSP_MMCSD_SAMPLE_DRIVE);
        if (IOM_COMPLETED == retVal)
        {
            MMCSD_SAMPLE_PRINT(" MMCSD_SAMPLE: Media is registered with FATfs \r\n");
        }
        else
        {
            MMCSD_SAMPLE_PRINT(" MMCSD_SAMPLE: Media is registering with FATfs FAILED\r\n");
            return;
        }
        pFile = fopen(filename, "a");

        if (NULL == pFile)
        {
            MMCSD_SAMPLE_PRINT("ERROR: FatFs fxn 'fopen' returned NULL.\n");
            return;
        }

        for (i = 1; i < 16; i++ )         //generating the string  like timestamp; 1st 8Byte; 2nd 8Byte,... 16th 8 Byte; \n                                       
            {
                sprintf(zwischenspeicher, "%d;", messung);
                strcat(speicher,zwischenspeicher);

                strcat(speicher,"\n");
                messung--;
            }

        printf("Start...\n");
        loop = 0;
        while (loop < 120000)
        {

            fwrite(speicher, 1, 146, pFile);

            fflush(pFile);

            loop++;

    }

        printf("fertig! \n");
        if ((fclose(pFile)) != 0)
        {
            MMCSD_SAMPLE_PRINT("ERROR: FatFs fxn 'fclose' returned error.\n");
        }

        /*The Media Driver clients like Mass Storage drivers shall use this
        function to un-register from a Block media device*/
        retVal = PSP_blkmediaFATfsUnregister(PSP_MMCSD_SAMPLE_DRIVE);
        if (IOM_COMPLETED == retVal)
        {
            MMCSD_SAMPLE_PRINT(" MMCSD_SAMPLE: Media for remote client is"
                                " unregsitered\r\n");
        }
        else
        {
            MMCSD_SAMPLE_PRINT(" MMCSD_SAMPLE: Media for remote client is"
                                " not unregsitered\r\n");
        }
    }

    i dont know how to get more performence, writing of 120000 lines must be under 2 secends i think.

  • Hallo Community,

    sorry for disturbing again! I'm still working on the Speed of the SD Card

    im using LogicPD board with OMAP L-138 and biospsp 3.00.01.00 i try to write data to SD Card, and it schould be faster then 1MB/sek but the fastest i get is 200kB/sek

    is there a trick to get it much faster? what is the maximum speed of the card, i cant believe its the fastest, the Controller can do!

     writeSize = fwrite(srcmmcsdBuf, 1, cnt, pFile);

    i try to variate cnt, but i got not more speed...

  • Hi Eugen,

    As mentioned in the previous conversation, please make the buffer size as 100KB, 200KB, 400KB etc and then measure the performance.

    To do so, you can modify "speicher" to a size of 100KB or 200KB or 400KB etc.

    Let me know the result.

    Regards,

    Sandeep K

  • i did it, but there is no effect, the time is still the same

  • Eugen,

    Can you please provide me the application which you had modified for 100KB?

    BTW, can you please move the statement "fflush(pFile);" to outside the loop and try it?

    Regards,

    Sandeep K

  • here it is Sandeep

    http://e2e.ti.com/members/3516130/files/mmcsdsample_5F00_io.c.aspx

    put fflush(); out of loop has no effect too

  • Eugen,

    Yes, I have also tried above experiments, and results were same as you have observed.

    Can you please try out one more application available in the PSP (biospsp_03_00_01_00\drivers\examples\evm6748\mmcsd) which will directly talk to the blockmedia->mmcsd? This will bypass the filesystem.   

    Let me know the result.

    Regards,

    Sandeep K

  • Hallo Sandeep,

    in other task WRITE_MULTIPLE_BLOCK was meantioned, but i dont know if this is active, i cant find any macros to activate it, so i think its automaticlly.

    i must change the paths in files for the biospsp_03_00_01_00\drivers\examples\evm6748\mmcsd example.

    did you build a CCS project from the fatfs example? because i have to compile it allways over the command window like it is told in the user guide

  • No, I do not have CCS project for both mmcsd_fatfs and mmcsd examples.

    Regards,

    Sandeep k

  • Hallo Sandeep,

    and you have no idea why its so slow?

  • Hi Eugen,

    >174 * 20000 i get a time of 1:45, (167*3) 502 * 6666 i get a time of 1:36

    If you write such  a small data chunk (174), then overheads will comparatively be higher. You can tweak the data size to get better performance.

    BTW, as suggested by Sandeep in one of his earlier posts, please use the example application for  blockmedia/mmcsd to measure the performance. That has to be build from commadline using makefile. 

    - Shanmuga

  • Hi Eugen,

    I'm running the same example but I have a problem detecting the card i.e. getting the message "MMCSD_SAMPLE: Please insert the card". I'm using a 2G SD card. Is this not supported?

    Regards,
    Abebe Hailu

  • Hi Abebe

    i was using many different cards, all work! i had one 2GB-Card too. So this is supported

    keep trying. i stop using it, because its to slow for my stuff

  • Hi,

    do you have a working project that you can send to me? It would be very helpful for me.

    Regards,
    Abebe Hailu