Hi
Am using Emwin for LPC546xxx with customized board.Display model number is TM104SDHG05, Tianma model. Anyone can suggest me how i can initialize emwin.
Hello,
There is emwin_examples under SDK, you can refer to:
BR
Alice
Thanks for your reply and we have downloaded the emwin sdk for lpc546xx and integrated the emwin libraries in our project currently we are facing the issue of in the GUI_init();So far we have not used the debugger in our project and we are using the uart for verifying the program flow .
as per program flow:
GUI_INIT----------------->LCD_INIT-------------->Hung or may be in hardfault exceptions.
We are using the external ram for storing the display buffer and gui buffer .Please go through the images i have attached for your reference.
We ae using tianma lcd part number TM104SDHG05
--------------------CODE-------------------------------------
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#include "timers.h"
#include "semphr.h"
#include "GUI.h"
#include "WM.h"
#include "GUIDRV_Lin.h"
#include "board.h"
#include "fsl_ctimer.h"
#include "fsl_sctimer.h"
#include "fsl_gpio.h"
#include "fsl_lcdc.h"
#include "fsl_i2c.h"
#include "fsl_usart.h"
#include <cr_section_macros.h>
#include "fsl_device_registers.h"
#include "pin_mux.h"
#include "board.h"
#include "stdint.h"
#include "DIALOG.h"
#include "GUI.h"
#include "stdio.h"
#include "stdlib.h"
#include "fsl_ctimer.h"
#include "fsl_sctimer.h"
#include <stdio.h>
#include "board.h"
#include "peripherals.h"
#include "pin_mux.h"
#include "clock_config.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include "board.h"
#include "fsl_lcdc.h"
#include "fsl_i2c.h"
#include "fsl_usart.h"
#include "fsl_gpio.h"
#include <cr_section_macros.h>
#include "fsl_iocon.h"
#include "pin_mux.h"
#include "fsl_sctimer.h"
#include "fsl_ctimer.h"
#include "fsl_rtc.h"
#include "peripherals.h"
#include "fsl_DualUart.h"
#include "fsl_sd.h"
#include "fsl_power.h"
#include "fsl_i2s.h"
#include "fsl_codec8814.h"
#include "fsl_dma.h"
#include "fsl_i2s_dma.h"
#include "fsl_enet.h"
#include "fsl_phy.h"
#include "fsl_inputmux.h"
#define SDRAM_BASE_ADDR 0xA0000000
#define GUI_BLOCKSIZE 0x128
#define CTIMER CTIMER3
#define VRAM_SIZE (960000)
static volatile int32_t s_LCDpendingBuffer = -1;
GUI_PID_STATE pid_state;
static SemaphoreHandle_t xQueueMutex;
static SemaphoreHandle_t xSemaTxDone;
#include "board.h"
#include "peripherals.h"
#include "fsl_inputmux.h"
#include "pin_mux.h"
#include "clock_config.h"
#include "LPC54618.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include "board.h"
#include "fsl_lcdc.h"
#include "fsl_i2c.h"
#include "fsl_usart.h"
#include "fsl_gpio.h"
#include "fsl_gint.h"
#include <cr_section_macros.h>
#include "pin_mux.h"
#include "fsl_sctimer.h"
#include "fsl_ctimer.h"
#include "fsl_rtc.h"
#include "fsl_RTC8563.h"
#include "peripherals.h"
#include "fsl_DualUart.h"
#include "fsl_sd.h"
#include "fsl_power.h"
#include "fsl_i2s.h"
#include "fsl_codec8814.h"
#include "fsl_dma.h"
#include "GUI.h"
#include "LCD.h"
#include "WM.h"
#include "stdint.h"
extern unsigned char GuiNumberofBytes[GUI_NUMBYTES];
extern unsigned short V_RamframeBuff[480000];
void APP_LCD_IRQHandler(void)
{
uint32_t intStatus = LCDC_GetEnabledInterruptsPendingStatus(APP_LCD);
LCDC_ClearInterruptsStatus(APP_LCD, intStatus);
if (intStatus & kLCDC_VerticalCompareInterrupt)
{
if (s_LCDpendingBuffer >= 0)
{
/* Send a confirmation that the given buffer is visible */
GUI_MULTIBUF_Confirm(s_LCDpendingBuffer);
s_LCDpendingBuffer = -1;
}
}
__DSB();
}
/*******************************************************************************
* Application implemented functions required by emWin library
******************************************************************************/
void LCD_X_Config(void)
{
///V_RamframeBuff size is 960000 bytes and allocated in external ram
status_t status;
GUI_MULTIBUF_Config(1);
if(GUI_DEVICE_CreateAndLink(GUIDRV_LIN_16, GUICC_M565, 0, 0))
{
}
else
{
}
LCD_SetSizeEx(0, 800, 600);
LCD_SetVSizeEx(0, 800, 600);
LCD_SetVRAMAddrEx(0, (void *)V_RamframeBuff);
status = APP_LCDC_Init();
if (status != kStatus_Success)
{
}
}
int LCD_X_DisplayDriver(unsigned LayerIndex, unsigned Cmd, void *p)
{
return 0;
}
void GUI_X_Config(void)
{
int i=0,j=0;
char xyz[10];
///GuiNumberofBytes size is 2MB and allocated in external ram
GUI_ALLOC_AssignMemory((unsigned char *)GuiNumberofBytes, GUI_NUMBYTES);
/* Select default font */
GUI_SetDefaultFont(GUI_FONT_6X8);
GUI_SetDefaultColor(GUI_BLACK);
USART_WriteByte(NIBP_USART,'3');USART_WriteByte(NIBP_USART,'4');
}
void GUI_X_Init(void)
{
}
/*********************************************************************
*
* Multitasking:
*
* GUI_X_InitOS()
* GUI_X_GetTaskId()
* GUI_X_Lock()
* GUI_X_Unlock()
*
* Note:
* The following routines are required only if emWin is used in a
* true multi task environment, which means you have more than one
* thread using the emWin API.
* In this case the
* #define GUI_OS (1)
* needs to be in GUIConf.h
*/
/*! @brief Init OS.Creates the resource semaphore or mutex typically used by GUI_X_Lock() and GUI_X_Unlock().*/
void GUI_X_InitOS(void)
{
// USART_WriteByte(NIBP_USART,'O');USART_WriteByte(NIBP_USART,'S');
/* Create a Mutex lock*/
xQueueMutex = xSemaphoreCreateMutex();
configASSERT(xQueueMutex !=NULL);
vSemaphoreCreateBinary(xSemaTxDone);
configASSERT(xSemaTxDone != NULL);
//USART_WriteByte(NIBP_USART,'1');USART_WriteByte(NIBP_USART,'1');
}
/*! @brief Locks the GUI*/
void GUI_X_Lock(void)
{
//USART_WriteByte(NIBP_USART,'O');USART_WriteByte(NIBP_USART,'S');
xSemaphoreTake(xQueueMutex , portMAX_DELAY);
//USART_WriteByte(NIBP_USART,'1');USART_WriteByte(NIBP_USART,'2');
}
/*! @brief Unlocks the GUI */
void GUI_X_Unlock(void)
{
//USART_WriteByte(NIBP_USART,'O');USART_WriteByte(NIBP_USART,'S');
xSemaphoreGive(xQueueMutex);
//USART_WriteByte(NIBP_USART,'1');USART_WriteByte(NIBP_USART,'3');
}
/*! @brief Get the Task handle */
U32 GUI_X_GetTaskId(void)
{
return ((uint32_t)xTaskGetCurrentTaskHandle());
}
void GUI_X_WaitEvent (void)
{
//USART_WriteByte(NIBP_USART,'O');USART_WriteByte(NIBP_USART,'S');
while( xSemaphoreTake(xSemaTxDone, portMAX_DELAY ) != pdTRUE );
//USART_WriteByte(NIBP_USART,'1');USART_WriteByte(NIBP_USART,'4');
}
void GUI_X_SignalEvent (void)
{
//USART_WriteByte(NIBP_USART,'O');USART_WriteByte(NIBP_USART,'S');
xSemaphoreGive( xSemaTxDone );
//USART_WriteByte(NIBP_USART,'1');USART_WriteByte(NIBP_USART,'5');
}
void GUI_X_ExecIdle(void)
{
}
GUI_TIMER_TIME GUI_X_GetTime(void)
{
//USART_WriteByte(NIBP_USART,'O');USART_WriteByte(NIBP_USART,'S');
return ((int) xTaskGetTickCount());
//USART_WriteByte(NIBP_USART,'1');USART_WriteByte(NIBP_USART,'6');
}
/*! @brief Returns after a specified time period in milliseconds. */
void GUI_X_Delay(int ms)
{
//USART_WriteByte(NIBP_USART,'O');USART_WriteByte(NIBP_USART,'S');
vTaskDelay(ms);
//USART_WriteByte(NIBP_USART,'1');USART_WriteByte(NIBP_USART,'7');
}
void *emWin_memcpy(void *pDst, const void *pSrc, long size)
{
return memcpy(pDst, pSrc, size);
}
status_t APP_LCDC_Init(void)
{
// Initialize the display.
lcdc_config_t lcdConfig;
// lcdc_cursor_config_t cursorConfig;
LCDC_GetDefaultConfig(&lcdConfig);
lcdConfig.panelClock_Hz = LCD_PANEL_CLK;
lcdConfig.ppl = LCD_PPL;
lcdConfig.hsw = LCD_HSW; //LCD_HSW;
lcdConfig.hfp = LCD_HFP;
lcdConfig.hbp = LCD_HBP;
lcdConfig.lpp = LCD_LPP;
lcdConfig.vsw = LCD_VSW;
lcdConfig.vfp = LCD_VFP;
lcdConfig.vbp = LCD_VBP;
lcdConfig.polarityFlags = LCD_POL_FLAGS;
lcdConfig.upperPanelAddr = (unsigned int)V_RamframeBuff;
lcdConfig.bpp = kLCDC_16BPP565;
lcdConfig.display = kLCDC_DisplayTFT;
lcdConfig.swapRedBlue = true;
lcdConfig.dataFormat = kLCDC_WinCeMode;
LCDC_Init(APP_LCD, &lcdConfig, LCD_INPUT_CLK_FREQ);
LCDC_EnableCursor(APP_LCD, false);// LCDC_EnableCursor(APP_LCD, true);
LCDC_Start(APP_LCD);
LCDC_PowerUp(APP_LCD);
return kStatus_Success;
}
we are using 800X600 10.4 inch lcd
Please help us to resolve the problem
Please help us to resolve this issue as soon as possible because I am already lagging too much on time
Regards
Nithin N