No announcement yet.

uSD Programming

  • Filter
  • Time
  • Show
Clear All
new posts

  • uSD Programming

    Dear all,
    I'm using a uLCD-32PT_GFX2 with a uLCD-32PTGFX-R25.PmmC.
    During the life of my product I will have to be able to program on site the uSD memory card. When trying to do this through media_WrSector API, I'm facing a strange problem. The time to program a range of 256 sectors is very long. When programming the firsts 256 sectors it takes 2 seconds, and others takes 12 seconds.Since uSD memory board can be very large (2GB, 4GB, ...), the time to programm or reset a memory can become very very very important. inacceptable...
    Could you help me to find a solution to reduce this programming time.I uploaded a sample 4dg file.

  • #2

    I couldn't find your attached program.

    Anyway, this program shows 256 sectors are consistently written at about 1.7 seconds pretty much forever

    #platform "uLCD-32PT_GFX2"

    var sector[256] ;
    func main()

    var i, j, k, sect ;
    sect := 0 ;
    for (k := 0; k < 20; k++)
    sys_SetTimer(TIMER2,50000) ;
    for (i := 0; i < 256; i++)
    for (j := 0; j < 256; j++)
    sector[j] := sect ;
    media_SetSector(0, sect++);
    if (k == 0) print("First") ; else print("Next") ;
    print(" 256 sectors took ",50000-sys_GetTimer(TIMER2), "ms\n") ;

    Regardless, how are you proposing to get the data to the display? Serial comms is very slow if you intend to pass 2gb of data that way, the speed of writing to the card becomes insignificant.

    You would be much better off creating a new uSD card at the factory and replacing it on site.


    • #3

      Thank for you reply.
      I test you code, and the probleme is the same:With youre code, the first 16 sector write is quite quick (3 seconds), the next sector write are long (13 seconds).
      Unfortunatelly, i will not able to exchange uSD card on site after delivery. But, my need is not to write the all 2GByte but 5MByte approx.
      have you and idea to speed up the next sectors?
      (I tried to upload a photo but without success).


      • #4

        Here is the resulting image of your program.

        Attached files


        • #5

          What is the make and model of your uSD card? (Have you tried another?)

          How are you powering the display? (Try a better cable / more reliable power supply)


          • #6

            The display is powered through USB cable and MB5 adaptor.
            I use a Kingston 2GB microSD (SD-C02G). I've tested with 1GB ( SD-C01G) and the problem is attenuated.The 4 first output took 2 seconds, the next tooks 4 seconds (2 times longuer).
            I suspect a mismanagement of the memory SD card.
            Could you tell me how to proceed?


            • #7

              All SD cards are 'managed' the same, you send a command to them, then you wait until the card until the card stops returning a staus of 'Busy'.

              We talk to the cards using the SPI protocol, this is slower than the SD protocol, but doesn't need as much interface hardware and doesn't need licensing fees to be paid.

              Different cards have different read and write speeds, plus a lot of cards have a burst write speed and a sustained write speed, of course those speeds are only ever specified fro the SD protocol and whilst one would think they should be comparable they often aren't.

              Using a Kingston 2GB card of the same model as you have I get the same results as you, not good.

              The original results were obtained using a Kingmax 64mb card, which is slower to read than the Kingston, believe it or not.

              I tried again using a SanDisk 8GB card which I had available. This card took 2.5 secs for the first 4 lots of 256 sectors and then sped up to 2.1 secs for the rest.

              So I guess you will need to try a few different cards and capacities to find out which gives the best SPI write speed.


              • #8

                thank you for this comment.

                your comment means that we have to be carrefull on the uSD memory choice. so my question is the, are you able to specify a usd "type" which is adapted to provide a good reliability for the SPI communication?

                from my side, I will try SanDisk memory cards with several size.


                • #9

                  The short answer is no.

                  Most of the reasons why it can't be done are in my previous post.

                  Since the world changes so fast these days, even if we were to test a few cards, there's nothing to stop those tests being invalididated by the next batch produced by the manufacturer.

                  At any rate it sure looks like many manufacturers are not putting much effort into supporting 'fast' SPI mode writing. We will do some investigation when time permits.


                  • #10

                    no ???
                    so if you are not able to specify the equipment you are supporting, what is your workaround to allow a normal usage of your equipment, with a reasonable time?


                    • #11

                      If you find cards that do/do not work, you could add them to the following threads:
                      If you could add the symptom of how it does not work (slow write speed, etc) that would be great!
                      Best Regards,


                      • #12

                        is it a joke?
                        Sorry, but since the world change so fast these days, I'm not sure to have time for this.


                        • #13

                          The idea was to compile list of cards that do / do not work in one location for easy reference. If you do not feel like contributing, then by all means feel free not to do so.
                          Please keep in mind that these are user forums, and often times it is users helping out other users (although 4d does a very good job monitoring and assisting with user questions).
                          So, no, it's not a joke.
                          Best Regards,


                          • #14

                            thevilo, it's hard to see what you expect 4D to do here.

                            We support access to the uSD cards in SPI mode and all SPI mode cards work.

                            The card manufacturers each support SPI at varying speeds.*

                            How can you take 4D to task because a given manufacturer's particular card doesn't work at the speed that you require it to?

                            Surely that is an issue between you and the card manufacturer?

                            *The SD card association requires that all SD cards support SPI mode, we have noticed that some 'high end' cards do not support SPI mode. We have also noticed that many 'fake' cards do not support SPI mode.


                            • #15

                              sorry for my late answer, I was out of my office.
                              As a customer a expect from 4D help on using your product.I already spent a week to try to understand why the programming is so long.If your feeling is about SPI speed, please provide us your compatibility requirements. Let me know what speed do you supporting.