Evgeny Erenburg

TWR-K70F120 + TWR-LCD-RGB Problem

Discussion created by Evgeny Erenburg on Oct 6, 2016

I have a problem to get the LCD going on the tower system.

I've created a project in Kinetis Design Studio and compiled D4D library.


D4D_SCREEN screen_entry;

int main(void)


    /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/


    /*** End of Processor Expert internal initialization.                    ***/


    status = D4D_Init((D4D_SCREEN*)&screen_entry);








  /*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/


    PEX_RTOS_START();                  /* Startup of the selected RTOS. Macro is defined by the RTOS component. */


  /*** End of RTOS startup code.  ***/

  /*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/


  /*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/

} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/


When I step into the code with a debugger I get to the D4DLCDHW_Init_K70LCDC function and here



    // Allocate frame buffer memory




      d4dlcdhw_k70_lcdc_desc.fb_start_addr = 0;


    d4dlcdhw_k70_lcdc_desc.fb_start_addr = (unsigned long)D4D_MemAlloc(D4DLCDHWFB_X_MAX * D4DLCDHWFB_Y_MAX * D4DLCDHWFB_BPP_BYTE);


      return 0;



the line d4dlcdhw_k70_lcdc_desc.fb_start_addr = (unsigned long)D4D_MemAlloc(D4DLCDHWFB_X_MAX * D4DLCDHWFB_Y_MAX * D4DLCDHWFB_BPP_BYTE); returns 0 – it fails allocate frame buffer memory.

Should I use the dynamic allocation? Or I can set the start address manually.

Anyway if I configure it manually: #define D4DLCDHWFB_START_ADDRESS 0x80400000

Then I get to D4D_InvalidateScreen(D4D_SCREEN* pScreen, Byte bComplete)

And on the line pScreen->pData->flags |= D4D_SCR_FINT_REDRAWC; I get into some exception interrupt:



  /* This code can be changed using the CPU component property "Build Options / Unhandled int code" */




At this point I have no idea what to do.


The D4D library quite complicated with a lot of settings to define. May be something is not properly configured?

What should be the configurations in order to use D4D with TWR-K70F120 + TWR-LCD-RGB?