Announcement

Collapse
No announcement yet.

Gathering Data from SPI independent of main function

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Gathering Data from SPI independent of main function

    The difficulty

    The display when it has to change, is taking long time, like 750ms. And this is taken mostly by the functions like PrintDisk() and str_Printf(). That means, the SPI communication is on hold during that time. But we want SPI communication to continue in the specified interval (50ms). Is there any method to achieve this? Like an ISR, or a different task or something? Please see the below figure and details:
    Communication and Display together creating problem
    Figure illustrate the problem that while display change is executed in the library function, SPI comm is stopped

    Additional details - Pseudocode

    Code:
    // Here is the logic of our loop in the main()
    repeat
      /* Time elapsed */
      if (TRUE == SPI_delayTimeElapsed()) // 50ms expired?
      {
        :
        SPI2_Read();  // 1
        SPI2_Read();  // 2
        :
        SPI2_Read(); // 12
        :
        /* Reset the delay wait time */
        ResetTimerUsedForDelay();
      }
      /* Look for changes to the display that needed to be updated, if updated then update the display */
      if(TRUE == displayNeedsToUpdate())
      {
        /* Update the display */
        txt_FontID(customFont);
        txt_FGcolour(BLACK);
        txt_BGcolour(WHITE);
        gfx_MoveTo(X_LOC, Y_LOC);
        if(TRUE == loadTheTextFromTable())
        {
          /* print the display */
          usePrintDisk();
        }
        else
        {
          /* print the display */
          use_str_Printf_OR_putstr();
        }
      }
      :
      :
    forever
    Additional Explanation of the Font used

    Following are some notes that might increases the understanding of what is happening.
    • The customFont is a Windows Font, i.e. a font file available in windows
    • The customFont is having a font height of 275px
    • The area that these fonts are displayed are having an approximate width of 700px
    • 4 characters are displayed, when changed (i.e. when using PrintDisk(), or str_Printf)
    • And it is taking about 750ms to update these characters.

    So what would be the other possible options to have the data via SPI to regularly happen?

  • #2
    Hi,

    It is possible to have timer events to call a function but I don't think this will solve your issue.

    It would be best to try to get the time taken to draw the text output down but this would depend on the type of data you are displaying. If it is just numrical data then one method you could use is to create a set of Userimages that contain the lowest value to the highest value.

    The Diablo16 processor is capable of 1,220,000 pixels per second.

    So with a dimension of 700 * 275 it would be possible to draw each frame at approx less than 300ms. If you were to reduce the size further then this would improve again.

    Another option could be to have an attached Serial MCU such as an Arduino that deals with the SPI read and then sends the value to the display via Serial which would allow the Arduino to read SPI and then send to the display.

    Information about the Diablo timers can be found on page 327 of the manual,

    https://4dsystems.com.au/mwdownloads...d/link/id/719/

    It would be helpful if you could let me know the range and type of data that is being displayed.

    Best regards

    Paul

    Comment


    • #3
      It is true, unless this timer event can interrupt the current main loop, and execute SPI read, it is not possible for to use the timer event.

      Unfortunately, the data we are displaying is varying in nature. That is it is mainly of textual type. So the content of this textual type is not that predictable. There is a section that deals with predictable text, and we are using printDisk() function to display that, but the other data is of varying nature of the text.

      That is strange, just before and after that I have called the printDisk or str_Printf(), I have sampled the time using sys_T(). The result of the difference between them is approximately 775ms, which is matching with scope output. So if Diablo16 can process that under 300ms, then why would this take 775ms? Is there anything I am missing, like increasing the processor speed? Or is it printing the characters beyond its limit? I am using Null terminated string for str_Printf() (of course byte aligned ptr) and inserted the predictable string using GUI, which is separated by '\n' character. Both display is taking approx same time 775ms to complete.

      As stated previously, the type is text, and content is dynamic. So we are looking into the printable characters in the ASCII. Does that help?

      Comment


      • #4
        Hi

        When using custom fonts, the font data is being retreived from the SD card so each character drawn is retreived from SD. This is a fast process but it is a large font and hence the reason for the time taken to display all characters.

        I will carry out some tests here to see if I can find an alternative method.

        Can I ask what your project is and the desired look of digits that you need just in case there is an alternative faster method that we can suggest.

        Best regards

        Paul

        Comment


        • #5
          Hi Paul,

          Thank you for doing the tests.

          Below is the summary for the explanation for the project.

          Display is receiving the commands and triggers to play the voices and to generate the text to be displayed via SPI. When there is a voice to be triggered, it will be played from the SD card, the corresponding wavefile. The display can be any text. But the height of the text needs to be 2.5" (2 and half inch) in the screen. So that is the reason why we needed to use a custom font. There is not a specific restriction on how the font has to look, but it has to be legible, and cursive type is not recommended.

          The content of the text will be be random, based on what is contained in the SPI command. I have tried font magnification, but the text look not very nice. Based on the data given in the SPI command, the text displayed will use "PrintDisk()", if the content is to be displayed from a table or str_Printf() function, if the content is to be displayed is random.

          This is basically the summary of the project.

          Comment


          • #6
            Hi,

            Thank you for the summary. I will try a few things here and get an example ready for you as soon as possible.

            Best regards

            Paul

            Comment

            Working...
            X