Hello everybody,
i made my own project in the STM32 System Workbench and tried there to integrate the Embedded Wizard generated code. I use the STM32F469i-Discovery Board with a FreeRTOS. I know that the settings of my system are right, because when i initialize the display by my own and display some strings, it works fine. The problem is, when i integrate the task for the embedded wizard, the system runs into a undefined state. This is happening, when the task is trying to initialize the display.
Here is my code:
int main(void)
{
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* Configure the system clock */
SystemClock_Config();
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_USART6_UART_Init();
/* Testing the Display without Embedded Wizard 2 */
BSP_EEPROM_Init();
BSP_QSPI_Init();
BSP_SDRAM_Init();
BSP_LCD_Init();
BSP_LCD_LayerDefaultInit(0, 0xC0000000);
BSP_LCD_SelectLayer(0);
BSP_LCD_DisplayOn();
BSP_LCD_Clear(LCD_COLOR_WHITE);
BSP_LCD_SetBackColor(LCD_COLOR_BLACK);
BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
BSP_LCD_SetFont(myfont);
/* configure LED */
EwBspConfigLed();
/* initialize serial interface for debugging and connect xprintf module */
EwBspConfigSerial();
xdev_out(EwBspPutCharacter);
/* Create the thread(s) */
/* definition and creation of defaultTask */
osThreadDef(defaultTask, StartDefaultTask, osPriorityNormal, 0, 128);
defaultTaskHandle = osThreadCreate(osThread(defaultTask), NULL);
/* definition and creation of TaskEmbWiz */
osThreadDef(TaskEmbWiz, StartTaskEmbWiz, osPriorityIdle, 0, 1280);
TaskEmbWizHandle = osThreadCreate(osThread(TaskEmbWiz), NULL);
/* Start scheduler */
osKernelStart();
while (1) {
}
}
/* StartTaskEmbWiz function */
void StartTaskEmbWiz(void const * argument) {
CoreRoot rootObject;
XViewport* viewport;
XEnum cmd = CoreKeyCodeNoKey;
int touched = 0;
XPoint touchPos;
/* initialize display */
EwPrint("Initialize Display... ");
EwBspConfigDisplay( FRAME_BUFFER_WIDTH, FRAME_BUFFER_HEIGHT,
FRAME_BUFFER_ADDR);
EwPrint("[OK]\n");
/* initialize touchscreen */
EwPrint("Initialize Touch Driver... ");
EwBspConfigTouch( FRAME_BUFFER_WIDTH, FRAME_BUFFER_HEIGHT);
EwPrint("[OK]\n");
/* initialize tlsf memory manager */
/* please note, that the first part of SDRAM is reserved for framebuffer */
EwPrint("Initialize Memory Manager... ");
MemPool = tlsf_create_with_pool( MEMORY_POOL_ADDR, MEMORY_POOL_SIZE);
EwPrint("[OK]\n");
EwPrint("MemoryPool at address 0x%08X size 0x%08X\n", MEMORY_POOL_ADDR,
MEMORY_POOL_SIZE);
/* initialize the Graphics Engine and Runtime Environment */
EwPrint("Initialize Graphics Engine... ");
if (!EwInitGraphicsEngine(0))
return;
EwPrint("[OK]\n");
/* create the applications root object ... */
EwPrint("Create Embedded Wizard Root Object... ");
rootObject = (CoreRoot) EwNewObjectIndirect(EwApplicationClass, 0);
EwLockObject(rootObject);
CoreRoot__Initialize(rootObject, EwScreenSize);
EwPrint("[OK]\n");
/* create Embedded Wizard viewport object to provide uniform access to the framebuffer */
EwPrint("Create Embedded Wizard Viewport... ");
viewport = EwInitViewport(EwScreenSize,
EwNewRect(0, 0, FRAME_BUFFER_WIDTH, FRAME_BUFFER_HEIGHT), 0, 255,
FRAME_BUFFER_ADDR, DOUBLE_BUFFER_ADDR, 0, 0);
EwPrint("[OK]\n");
/* Initialize your device driver(s) that provide data for your GUI */
DeviceDriver_Initialize();
/* start the Embedded Wizard main loop and process all user inputs, timers and signals */
while (cmd != CoreKeyCodePower) {
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();
/* receive keyboard inputs */
cmd = GetKeyCommand();
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);
}
/* receive touch inputs and provide the application with them */
if (EwBspGetTouchPosition(&touchPos)) {
/* begin of touch cycle */
if (touched == 0)
CoreRoot__DriveCursorHitting(rootObject, 1, 0, touchPos);
/* movement during touch cycle */
else if (touched == 1)
CoreRoot__DriveCursorMovement(rootObject, touchPos);
touched = 1;
events = 1;
}
/* end of touch cycle */
else if (touched == 1) {
CoreRoot__DriveCursorHitting(rootObject, 0, 0, touchPos);
touched = 0;
events = 1;
}
/* 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) {
EmbWiz_Update( viewport, rootObject );
/* after each processed message start the garbage collection */
EwReclaimMemory();
/* print current memory statistic to serial interface - uncomment if needed */
// EwPrintProfilerStatistic( 0 );
}
/* otherwise sleep/suspend the UI application until a certain event occurs or a timer expires... */
else
EwBspWaitForSystemEvent(EwNextTimerExpiration());
}
/* Deinitialize your device driver(s) */
DeviceDriver_Deinitialize();
/* finished -> release unused resources and memory */
EwPrint("Shutting down application... ");
EwDoneViewport(viewport);
EwUnlockObject(rootObject);
EwReclaimMemory();
/* ... and deinitialize the Graphics Engine */
EwDoneGraphicsEngine();
EwPrint("[OK]\n");
tlsf_destroy(MemPool);
// // Aktivate to Test the Display without Embedded Wizard
// // dont forget to comment the code above
// for(;;){
// BSP_LCD_DisplayStringAt(0, 0, (uint8_t *)"Hello World", CENTER_MODE);
//
// for(int r=1;r<120;r+=1){
//
// BSP_LCD_SetTextColor(0xff000000+r*1398);
// BSP_LCD_DrawCircle(120, 160, r);
// HAL_Delay(5);
// }
// HAL_Delay(100);
// BSP_LCD_Clear(LCD_COLOR_BLACK);
// osDelay(1000);
// }
}
I don't know where there is the Problem. I only know, if the embedded wizard starts the EwBspConfigDisplay routine, the system runs into a undefined state. Maybe someone can help me :)
thanks anyway.
Greetz Torben