Page 17 of 18

Re: GDISP driver

Posted: Mon Sep 17, 2012 6:39 pm
by mobyfab
Here how I've done it. I will test tonight:

Code: Select all

   
if (area > 1000) { // Do not use DMA for small areas
      dmaStreamSetPeripheral(LCD_DMA_STREAM, &color);
      dmaStreamSetMemory0(LCD_DMA_STREAM, LCD_RAM);
      uint32_t i;
      uint16_t splitarea;
      for (i = (area/65535)+1; i > 0; i--) {
        if (i <= 1) splitarea = area%65535;
        else splitarea = 65535;
        dmaStreamSetTransactionSize(LCD_DMA_STREAM, splitarea);
        dmaStreamSetMode(LCD_DMA_STREAM, STM32_DMA_CR_PSIZE_HWORD | STM32_DMA_CR_MSIZE_HWORD | STM32_DMA_CR_DIR_M2M | STM32_DMA_CR_EN); 
        while ((LCD_DMA_STREAM)->stream->NDTR > 0) chThdSleepMilliseconds(5);
      }
    }
    else {
      for(index = 0; index < area; index++)
        GDISP_LLD(writedata)(color);
    }


This function has to copy the content of a variable to the FSMC, no need to increase any address since the data has to remain the same. (just filling rectangles)

So basically I'm waiting for completion since the GLCD library runs on another thread.
Is that correct?

Thanks.

Re: GDISP driver

Posted: Mon Sep 17, 2012 6:49 pm
by Giovanni
You shouldn't access DMA registers directly, this is an example from testhal/STM32F4xx/DMA_STORM/main.c

Code: Select all

    /* Copy pattern 2.*/
    dmaStartMemCopy(STM32_DMA2_STREAM6,
                    STM32_DMA_CR_PL(0) | STM32_DMA_CR_PSIZE_BYTE |
                                         STM32_DMA_CR_MSIZE_BYTE,
                    patterns2, buf1, sizeof (patterns2));
    dmaStartMemCopy(STM32_DMA2_STREAM7,
                    STM32_DMA_CR_PL(0) | STM32_DMA_CR_PSIZE_BYTE |
                                         STM32_DMA_CR_MSIZE_BYTE,
                    patterns2, buf2, sizeof (patterns2));
    dmaWaitCompletion(STM32_DMA2_STREAM6);
    dmaWaitCompletion(STM32_DMA2_STREAM7);


Giovanni

Re: GDISP driver

Posted: Mon Sep 17, 2012 7:34 pm
by mobyfab
The problem is that dmaStartMemCopy sets some options I don't want to use. (the increment options)

so I have to call each macro with the correct parameters.

Re: GDISP driver

Posted: Mon Sep 17, 2012 7:42 pm
by Giovanni
I was referring mainly to dmaWaitCompletion().

Giovanni

Re: GDISP driver

Posted: Mon Sep 17, 2012 8:04 pm
by mobyfab
Well this one is an empty loop, I don't really like wasting resources.

In this case using DMA would be useless if it is to waste the cpu cycles waiting for it to finish, except under heavy load.

Edit: switched the DMA channel, it works now but there is a ~15% performance decrease. (21.3m vs 17.9m pps)
It might be related to how I implemented it, I will make some tests. Avoiding DMA for small areas does not increase performance for some reason.

You can see the implementation here:
https://github.com/mobyfab/ChibiOS-LCD-Driver/blob/master/drivers/gdisp/SSD1963/gdisp_lld.c

Re: GDISP driver

Posted: Tue Sep 18, 2012 9:53 pm
by mobyfab
I made some more tests.

At low CPU load using DMA does cause a performance decrease of around 15%.
at high CPU using DMA can increase performance up to 70%. (almost as fast as if there was no load, just 5% slower)

However to achieve this, system tick needs to be increase dramatically. Up to 100 or even 200Khz.
Increasing systick gives much better performance and responsiveness at high load, using DMA or not.

High load means another thread running an endless loop with no delays.
I guess the more threads I add, the more difference I will see.

Re: GDISP driver

Posted: Wed Sep 19, 2012 10:05 pm
by mobyfab
So results of the tests so far.

CH_FREQUENCY 50000
CH_TIME_QUANTUM 2

4 threads with normal priority:
- Blinker with 500ms delay
- 2 while loops with no delay putting some load
- LCD thread

Without DMA: 6.5 Millions pixels per second
With DMA: 16.9 Millions pixels per second

if I disable the load threads, without touching anything else:
Without DMA: 20.2 Millions pixels per second
With DMA: 17.9 Millions pixels per second

Re: GDISP driver

Posted: Wed Sep 19, 2012 10:27 pm
by Badger
can you post the same results for 1Khz CH_FREQUENCY ?

thanks!

Re: GDISP driver

Posted: Wed Sep 19, 2012 10:40 pm
by mobyfab
CH_FREQUENCY 1000
CH_TIME_QUANTUM 20

Which are the default values in the examples.

No load:
Without DMA 21.2 M
With DMA: 17.9 M

Load:
Without DMA 7.1 M
With DMA: 6.1 M

Re: GDISP driver

Posted: Thu Sep 20, 2012 2:07 pm
by Abhishek
I have to tidy up my S6D1121 GPIO access layer, and also implement readback support in it. Will take up this part (since I guess I'm the only one still GPIO at the moment), as I will go into some more programming after my midsems.

Please let me know your suggestions regarding the common API for all interfaces. I'll post back when done.

Abhishek