Problem with multistack and STM32F4 Discovery LCD

Forum related to ERIKA Enterprise and RT-Druid version 2

Moderator: paolo.gai

Post Reply
Daniel_C
Newbie
Posts: 4
Joined: Sun Mar 16, 2014 7:53 pm

Problem with multistack and STM32F4 Discovery LCD

Post by Daniel_C » Fri May 16, 2014 8:00 am

Hi, I'm trying to use the LCD/Touchscreen provided by element14 expansion set (for the touch, STMPE811QTR) with erika.
I have developed an erika project in which a task (TaskLCD) waits in polling for an event in the touch, as shown in the demo by element14.
Other tasks handle events related to the object on the screen.
This program works, but since the LCD task remains blocked I want to make the LCD task stack private instead shared, to avoid problems.
In order to do this, I used the pic30 demo for multistack as example, but doing this the program does not work anymore: after the first "touch event", which is detected, the program crashes.
Which may be the cause?
I attach my oil file (in the c file, each task has TerminateTask() as last instruction).
Thanks,
Daniel

Code: Select all

CPU mySystem {

	OS myOs {

		EE_OPT = "DEBUG";
		
		CPU_DATA = CORTEX_MX {
			MODEL = M4;
			APP_SRC = "code.c";
			APP_SRC = "LCD_Touch_Lib.c";
			APP_SRC = "pictures.c";
			APP_SRC = "Objects.c";
			APP_SRC = "Tasks.c";
			APP_SRC = "Utility.c";
			APP_SRC = "STMPE811QTR.c";
			//COMPILER_TYPE = KEIL;
			COMPILER_TYPE = GNU; 
			MULTI_STACK = TRUE{
				IRQ_STACK = TRUE {
					SYS_SIZE=64;
				};
			};
		};

		
	
	EE_OPT = "__USE_SYSTICK__";

		MCU_DATA = STM32 {
			MODEL = STM32F4xx;
		};

		KERNEL_TYPE = ECC2; 
        	EE_OPT = "__OO_STARTOS_OLD__";

		/*STATUS = EXTENDED;
		STARTUPHOOK = FALSE;
		ERRORHOOK = FALSE;
		SHUTDOWNHOOK = FALSE;
		PRETASKHOOK = FALSE;
		POSTTASKHOOK = FALSE;
		USEGETSERVICEID = FALSE;
		USEPARAMETERACCESS = FALSE;
		USERESSCHEDULER = FALSE;*/
		STATUS = EXTENDED;
		STARTUPHOOK = FALSE; 
		ERRORHOOK = FALSE;
		SHUTDOWNHOOK = FALSE;
		PRETASKHOOK = FALSE;
		POSTTASKHOOK = FALSE;
		USEGETSERVICEID = FALSE;
		USEPARAMETERACCESS = FALSE;
		USERESSCHEDULER = TRUE;
		
		EE_OPT = "__ADD_LIBS__";
		
		LIB = ENABLE { NAME = "ST_CMSIS"; };
		LIB = ENABLE { NAME = "STM32F4XX_SPD"; 
			STM32F4XX_SPD = ENABLE {
				USEGPIO = TRUE;
				USESPI = TRUE;
				USEEXTI = TRUE;
				USEMISC = TRUE;
				USEFLASH = TRUE;
				USEI2C = TRUE;
				USEDMA = TRUE;
				//USEUSART = TRUE;
				//USESYSCFG = TRUE;
			};
		};
		LIB = ENABLE { NAME = "STM32F4_DISCOVERY";
			STM32F4_DISCOVERY = ENABLE {
				USELCD = TRUE;
				};
		};
		//LIB = ENABLE { NAME = "ST_GUI"; };	
		//LIB = ENABLE { NAME = "ST_GUI_HAL"; };
	};
	
    	COUNTER myCounter {
        	MINCYCLE = 2;
		MAXALLOWEDVALUE = 0xFFFF ;
        	TICKSPERBASE = 1;
    	};
	

	ALARM AlarmTaskLCDTouch {
		COUNTER = myCounter;
		ACTION = ACTIVATETASK { TASK = TaskLCDTouch; };
	};
	
	ALARM AlarmTaskButton {
		COUNTER = myCounter;
		ACTION = ACTIVATETASK { TASK = TaskButton; };
	};
	
	ALARM AlarmTaskSwitch {
		COUNTER = myCounter;
		ACTION = ACTIVATETASK { TASK = TaskSwitch; };
	};
	
	ALARM AlarmTaskSlideRed {
		COUNTER = myCounter;
		ACTION = ACTIVATETASK { TASK = TaskSlideRed; };
	};
	
	ALARM AlarmTaskSlideGreen {
		COUNTER = myCounter;
		ACTION = ACTIVATETASK { TASK = TaskSlideGreen; };
	};
	
	ALARM AlarmTaskSlideBlue {
		COUNTER = myCounter;
		ACTION = ACTIVATETASK { TASK = TaskSlideBlue; };
	};
	
	TASK TaskLCDTouch {
		PRIORITY = 0x01;   /* Low priority */
		AUTOSTART = FALSE;
		STACK = PRIVATE {
			SYS_SIZE = 2048;
		};
		ACTIVATION = 1;    /* only one pending activation */
		SCHEDULE = FULL;
	};
	
	TASK TaskButton {
		PRIORITY = 0x02;   /* High priority */
		RESOURCE = "ButtonStateLock";
		RESOURCE = "RedSlideStateLock";
		RESOURCE = "GreenSlideStateLock";
		RESOURCE = "BlueSlideStateLock";
		RESOURCE = "ScreenLock";
		AUTOSTART = FALSE;
		STACK = SHARED;
		ACTIVATION = 1;    /* only one pending activation */
		SCHEDULE = FULL;
	};
	
	TASK TaskSwitch {
		PRIORITY = 0x02;   /* High priority */
		RESOURCE = "SwitchStateLock";
		RESOURCE = "ScreenLock";
		AUTOSTART = FALSE;
		STACK = SHARED;
		ACTIVATION = 1;    /* only one pending activation */
		SCHEDULE = FULL;
	};
	
	TASK TaskSlideRed {
		PRIORITY = 0x02;   /* High priority */
		RESOURCE = "RedSlideStateLock";
		RESOURCE = "ScreenLock";
		AUTOSTART = FALSE;
		STACK = SHARED;
		ACTIVATION = 1;    /* only one pending activation */
		SCHEDULE = FULL;
	};
	
	TASK TaskSlideGreen {
		PRIORITY = 0x02;   /* High priority */
		AUTOSTART = FALSE;
		STACK = SHARED;
		ACTIVATION = 1;    /* only one pending activation */
		SCHEDULE = FULL;
	};
	
	TASK TaskSlideBlue {
		PRIORITY = 0x02;   /* High priority */
		AUTOSTART = FALSE;
		STACK = SHARED;
		ACTIVATION = 1;    /* only one pending activation */
		SCHEDULE = FULL;
	};

	RESOURCE ScreenLock { RESOURCEPROPERTY = STANDARD; };
	RESOURCE ButtonStateLock { RESOURCEPROPERTY = STANDARD; };
	RESOURCE SwitchStateLock { RESOURCEPROPERTY = STANDARD; };
	RESOURCE RedSlideStateLock { RESOURCEPROPERTY = STANDARD; };
	RESOURCE GreenSlideStateLock { RESOURCEPROPERTY = STANDARD; };
	RESOURCE BlueSlideStateLock { RESOURCEPROPERTY = STANDARD; };
	
	ISR systick_handler {
		CATEGORY = 2;
		ENTRY = "SYSTICK";
		PRIORITY = 1;
	};
	
	

};

paolo.gai
Administrator
Posts: 875
Joined: Thu Dec 07, 2006 12:11 pm

Re: Problem with multistack and STM32F4 Discovery LCD

Post by paolo.gai » Fri May 16, 2014 9:43 am

- if you can inspect the memory with your debugger, check if the stack is all used or not
- 64 bytes for ISR could be not enough. give it 1024 to be sure. after that reduce it to what you really need
- if the blocking task is the lowest priority task I'm not sure that a separate stack will help (you need it in an case if you are using WaitEvent)

I hope this helps...

PJ

Daniel_C
Newbie
Posts: 4
Joined: Sun Mar 16, 2014 7:53 pm

Re: Problem with multistack and STM32F4 Discovery LCD

Post by Daniel_C » Sat May 17, 2014 8:21 pm

yes it helps!
The reason of the program's crash was the interrupt stack size: increasing the size, as suggested, now it works.
Thank you very much!
Daniel

Post Reply