900 views
in System Integration by

Hello

I am facing issue integrating the application. I am having a custom board made with STM32L471VG controller and having a Black&White LCD(255x160). All the required drivers are already available.

> I have an RTOS running on it.

> I have a seperate software component running in 100ms raster, which will take care of initializing the LCD and updates the LCD every 100ms. The component have an LCD buffer "char LcdRam[255*160];". After the data is filled into the buffer, LCD gets updated in the next immeidate job cycle.

> I have configured the EmWiSystemTicks variable to increment on every 1ms

> Since its a Black and White display, i have choosen Index8 as color format.

> At the minimum, i am expecting to see something on display. Below is the code.

#include "tlsf.h"

#include "ewrte.h"
#include "ewgfx.h"
#include "ewextgfx.h"
#include "ewgfxdefs.h"
#include "Core.h"
#include "Graphics.h"

tlsf_t MemPool;
extern BYTE LcdRam[LCD_RAM_BUFFER_SIZE];
#define LCD_FB_START_ADDRESS (LcdRam)


void EmWiMainLoop( const void* arg );

/* define pyhiscal dimension of the LCD framebuffer */
#define FRAME_BUFFER_WIDTH    LCD_LENGTH_PIXELS // ->255
#define FRAME_BUFFER_HEIGHT   LCD_HEIGHT_PIXELS // ->160

/* calculated addresses for framebuffer(s) and memory manager */
#define FRAME_BUFFER_SIZE     FRAME_BUFFER_WIDTH * FRAME_BUFFER_HEIGHT * FRAME_BUFFER_DEPTH
#define FRAME_BUFFER_ADDR     (void*)(LCD_FB_START_ADDRESS)

#define MEMORY_POOL_SIZE      0x1000
const BYTE memPool[MEMORY_POOL_SIZE]={0};
#define MEMORY_POOL_ADDR      (void*)memPool

#undef EW_ENABLE_COLOR_TABLE
#define EW_SURFACE_ROTATION 0
#define FREE_RTOS 0

CoreRoot   rootObject;
XViewport* viewport;

XEnum      cmd = CoreKeyCodeNoKey;

void Update( XViewport* aViewport, CoreRoot aApplication )
{
    XBitmap*       bitmap     = EwBeginUpdate( aViewport );
    GraphicsCanvas canvas     = EwNewObject( GraphicsCanvas, 0 );
    XRect          updateRect = {{ 0, 0 }, { 0, 0 }};

    /* let's redraw the dirty area of the screen. Cover the returned bitmap
    objects within a canvas, so Mosaic can draw to it. */
    if ( bitmap && canvas )
    {
        GraphicsCanvas__AttachBitmap( canvas, (XUInt32)bitmap );
        updateRect = CoreRoot__UpdateGE20( aApplication, canvas );
        GraphicsCanvas__DetachBitmap( canvas );
    }

    /* complete the update */
    if ( bitmap )
    {
        EwEndUpdate( aViewport, updateRect );
    }

    /* check if there is a dirty area so that the screen should be updated */
    if (( updateRect.Point2.X - updateRect.Point1.X <= 0 ) || ( updateRect.Point2.Y - updateRect.Point1.Y <= 0 ))
    {
        return;
    }

    /* start the update of the LCD via DSI */
    //EwBspUpdateDisplay(); -> This is already done by different component
}

BYTE emWizInit(void) // <- Called at the main function.
{
    int intGraphics;
     SetBackLight(TRUE);
    
    /* initialize tlsf memory manager */
    MemPool = tlsf_create_with_pool( MEMORY_POOL_ADDR, MEMORY_POOL_SIZE );
    
    /* initialize the Graphics Engine and Runtime Environment */
    intGraphics = EwInitGraphicsEngine( 0 );
    if ( intGraphics == 0)
        return 1;
    }
    rootObject = (CoreRoot)EwNewObjectIndirect( EwApplicationClass, 0 );
    EwLockObject( rootObject );
    CoreRoot__Initialize( rootObject, EwScreenSize );
    
    viewport = EwInitViewport( EwScreenSize, EwNewRect( 0, 0, FRAME_BUFFER_WIDTH, FRAME_BUFFER_HEIGHT ),
                                0, 255, FRAME_BUFFER_ADDR, DOUBLE_BUFFER_ADDR, 0, 0 );
    
    return 0;
}

void EmWiMainLoop( const void* arg ) // This function is called every 100ms by the OS.
{
            int timers  = 0;
            int signals = 0;
            int events  = 0;
            int devices = 0;

            /* process data of your device driver(s) and update the GUI
               application by setting properties or by triggering events */
            //devices = DeviceDriver_ProcessData(); <- Not focusing this as of now.

            /* receive keyboard inputs */
            //cmd = GetKeyCommand(); <- Not focusing this as of now.

            if ( cmd != CoreKeyCodeNoKey )
            {
                /* feed the application with a 'press' and 'release' event */
                events |= CoreRoot__DriveKeyboardHitting( rootObject, cmd, 0, 1 );
                events |= CoreRoot__DriveKeyboardHitting( rootObject, cmd, 0, 0 );
            }

            /* process expired timers */
            timers = EwProcessTimers();

            /* process the pending signals */
            signals = EwProcessSignals();

            /* refresh the screen, if something has changed and draw its content */
            if ( devices || timers || signals || events )
            {
                Update( viewport, rootObject );

                /* after each processed message start the garbage collection */
                EwReclaimMemory();
            }
}

after execution, EwInitGraphicsEngine function returns zero. I do not have serial console facility.

What is going wrong here, Am I missing something ? What are all the minimum things we should configured.

Please give your advice.

--

Maha

1 Answer

0 votes
by
Hi Maha,

A MEMORY_POOL_SIZE of 4k will be definitely too less. Depending on your application at least 32k will be necessary.
The memory pool is needed to allocate memory for Embedded Wizard objects of graphic surfaces for example.

And the memPool must not be constant. Some RAM area is needed there.

You could add some indicator (LED, GPIO, ...) in EwAlloc(), ewextrte.c, to find out if memory allocation has failed.

Best regards,
Martin

Embedded Wizard Website | Privacy Policy | Imprint

...