Erika3 and Avr8

Forum related to ERIKA Enterprise and RT-Druid version 3

Moderator: paolo.gai

dimolin

Re: Erika3 and Avr8

Post by dimolin »

Hello,

I think the OIL attribute USEGETSERVICEID in the current release doesn't work.

Code: Select all

OS myOs {
		EE_OPT = "__AVR8_GCC_C99__";
		CFLAGS = "-O0 -g";
		CFLAGS = "-DF_CPU=16000000L";

		STATUS             = EXTENDED;
		STARTUPHOOK        = TRUE;
		ERRORHOOK          = TRUE;
		SHUTDOWNHOOK       = FALSE;
		PRETASKHOOK        = FALSE;
		POSTTASKHOOK       = FALSE;
		USEGETSERVICEID    = FALSE;//-------> Doesn't work
		USEPARAMETERACCESS = TRUE;
		USERESSCHEDULER    = FALSE;
If I want to use the API OSErrorGetServiceId() I have to enable the attribute USEPARAMETERACCESS.

ee_oo_api_osek.h

Code: Select all

#if (defined(OSEE_USEPARAMETERACCESS))
FUNC(OSServiceIdType, OS_CODE)
  osEE_get_service_id
(
  void
);

FUNC(OsEE_api_param, OS_CODE)
  osEE_get_api_param1
(
  void
);

FUNC(OsEE_api_param, OS_CODE)
  osEE_get_api_param2
(
  void
);

FUNC(OsEE_api_param, OS_CODE)
  osEE_get_api_param3
(
  void
);

#define OSErrorGetServiceId() osEE_get_service_id()
e.guidieri

Re: Erika3 and Avr8

Post by e.guidieri »

Hi,

I just added support for USEGETSERVICEID in internal branch, just for completeness.

In any case USEPARAMETERACCES will still enable OSErrorGetServiceId macro too, since having access to service parameter without knowing which service is failed, is useless, and the specifications do not forbid explicitly this behaviour.
So what has been added is: if USEGETSERVICEID is TRUE and USEPARAMETERACCES is FALSE, you get only access to the OSErrorGetServiceId.

As the previous patch, this will be merged in master branch in the next GH window realease.

Regards,
Errico
dimolin

Re: Erika3 and Avr8

Post by dimolin »

Thank you!
dimolin

Re: Erika3 and Avr8

Post by dimolin »

Hello,

I'm trying to test an alarm assigned to a software counter. I have defined an extended task (IncrCounter_Task ) that runs every 10ms (using a cyclic alarm IncrCounter_Alarm that expire every 10ms). Inside this task I call the function IncrementCounter(ToggleLED_Counter);. I have also defined an alarm (ToggleLED_Alarm) assigned to the SW counter ToggleLED_Counter. When this alarm expires it raises an event for another task (ToggleLED_Task). Inside this task a LED connected to pin PB0 is toggled. So in my scenario the ToggleLED_Counter gets a tick every 10ms. The alarm ToggleLED_Alarm is configured as a relative to expire every 50 ticks (500ms). The end result is that the LED should blinking with frequency 1Hz.

If I define the alarms to run automatically (AUTOSTART = TRUE;), the example works as is expected. The problem is if I try to run them in the software with the API SetRelAlarm(). Then, I think the program loops inside IncrementCounter() by some reason.

Below you can find the full configuration of tasks, counters and alarms. In attachments I have attached complete examples - working and non-working.

Code: Select all

CPU mySystem {

   /******************************************************************************************
	* 
	* 						Core OS settings
	* 
	******************************************************************************************/	
	OS myOs {
		EE_OPT = "__AVR8_GCC_C99__";
		CFLAGS = "-O0 -g";
		CFLAGS = "-DF_CPU=16000000L";

		STATUS             = EXTENDED;
		STARTUPHOOK        = TRUE;
		ERRORHOOK          = TRUE;
		SHUTDOWNHOOK       = FALSE;
		PRETASKHOOK        = FALSE;
		POSTTASKHOOK       = FALSE;
		USEGETSERVICEID    = FALSE;
		USEPARAMETERACCESS = TRUE;
		USERESSCHEDULER    = FALSE;
				
		CPU_DATA = AVR8 {
			COMPILER    = GCC;
			MULTI_STACK = TRUE;
		};/* End of CPU_DATA */
		
		MCU_DATA = MEGA {
			MODEL = MEGA_328p;
		};/* End of MCU_DATA */
		
    	/*KERNEL_TYPE = OSEK {
      		CLASS = ECC1;
    	};*//* End of KERNEL_TYPE */
	};/* End of OS */

   /******************************************************************************************
	* 
	* 						Source files
	* 
	******************************************************************************************/
  	APPDATA myApp {
    	APP_SRC  = "Source/main.c";
    	APP_SRC  = "Source/tasks.c";
      	APP_SRC  = "Source/LedControl.c";   	
       	APP_SRC  = "Source/ErrorHandler.c"; 	     	
  	};/* End of APPDATA */

   /******************************************************************************************
	* 
	* 						APPLICATION MODES
	* 
	******************************************************************************************/  	
	
 	
   /******************************************************************************************
	* 
	* 						TASKS
	* 
	******************************************************************************************/ 

	TASK ToggleLED_Task {
		PRIORITY = 10;
		ACTIVATION = 1;
		AUTOSTART = TRUE{
			APPMODE = OSDEFAULTAPPMODE;
		};
		STACK = PRIVATE{
			SIZE = 100;
		};
		SCHEDULE = FULL;
		EVENT = ToggleLED_Event;
	};/* End of TASK */

	TASK IncrCounter_Task {
		PRIORITY = 5;
		ACTIVATION = 1;
		AUTOSTART = TRUE{
			APPMODE = OSDEFAULTAPPMODE;
		};
		STACK = PRIVATE{
			SIZE = 100;
		};
		SCHEDULE = FULL;
		EVENT = IncrCounter_Event;
	};/* End of TASK */
	
   /******************************************************************************************
	* 
	* 						RESOURCES
	* 
	******************************************************************************************/

			    
   /******************************************************************************************
	* 
	* 						COUNTERS
	* 
	******************************************************************************************/
 	COUNTER SystemCounter {
   		MINCYCLE = 1;
  		MAXALLOWEDVALUE = 65535;
   		TICKSPERBASE = 1;
   		TYPE = HARDWARE {
    		DEVICE = "TIMER1_COMPA";
     		SYSTEM_TIMER = TRUE;
        };
        SECONDSPERTICK = 0.001;
     };

 	COUNTER ToggleLED_Counter {
   		MINCYCLE = 1;
  		MAXALLOWEDVALUE = 1000;
   		TICKSPERBASE = 1; 
   		TYPE = SOFTWARE; 
    }; 
     
	
   /******************************************************************************************
	* 
	* 						ALARMS
	* 
	* ****************************************************************************************/ 	
	ALARM ToggleLED_Alarm {
    	COUNTER = ToggleLED_Counter;
    	ACTION = SETEVENT {
    		TASK  = ToggleLED_Task; 
    		EVENT = ToggleLED_Event;
    	};
   		AUTOSTART = FALSE; /*TRUE {
   			APPMODE = OSDEFAULTAPPMODE;
   			ALARMTIME = 50; 
   			CYCLETIME = 50;
   		};*/
  	 };

 	 ALARM IncrCounter_Alarm {
    	COUNTER = SystemCounter;
    	ACTION = SETEVENT {
    		TASK  = IncrCounter_Task; 
    		EVENT = IncrCounter_Event;
    	};
   		AUTOSTART = FALSE; /*TRUE {
   			APPMODE = OSDEFAULTAPPMODE;
   			ALARMTIME = 10; 
   			CYCLETIME = 10;
   		};*/
  	 };
 
   /******************************************************************************************
	* 
	* 						EVENTS
	* 
	******************************************************************************************/  	 	
	EVENT ToggleLED_Event
	{
		MASK = AUTO;	
	};

	EVENT IncrCounter_Event
	{
		MASK = AUTO;	
	};
	
   /******************************************************************************************
	* 
	* 						MESSAGES
	* 
	******************************************************************************************/ 
   
   /******************************************************************************************
	* 
	* 						INTERRUPTS
	* 
	******************************************************************************************/       
                               	
};

Code: Select all

/* System headers */
#include <ee.h>
#include <avr/io.h>
#include <util/delay.h>

/* User headers */
#include "LedControl.h"


TASK(ToggleLED_Task)
{
	SetRelAlarm(ToggleLED_Alarm,50,50);

	for(;;)
	{
		WaitEvent(ToggleLED_Event);
		ClearEvent(ToggleLED_Event);

		LedCnt_ToggleLed();
	}
}


TASK(IncrCounter_Task)
{
	SetRelAlarm(IncrCounter_Alarm,10,10);

	for(;;)
	{
		WaitEvent(IncrCounter_Event);
		ClearEvent(IncrCounter_Event);

		IncrementCounter(ToggleLED_Counter);
	}
}
BR
Dimo
Attachments
Example4_OK.7z
(657.07 KiB) Downloaded 434 times
Example4_NOK.7z
(659.58 KiB) Downloaded 430 times
paolo.gai
Administrator
Posts: 877
Joined: Thu Dec 07, 2006 12:11 pm

Re: Erika3 and Avr8

Post by paolo.gai »

Hi Dimo!

Thanks for posting a use case.

I does not have a Ardiuno with me, but I tried it on a S32 (which is a Cortex M). the idea is that if the program worked with the autostart, it is likely not an IRQ problem but more an internal kernel issue.

At the first try, I got an ErrorHook, memory got corrupted... Then I checked the stack usage, and it was over 100%. By setting the stack space to something more (256 bytes in my case)... it worked fine.

I'm thinking then that the issue you are having is more a stack overflow than an issue in the kernel itself. Please try giving more stack (at least 256?) to the two tasks...

Ciao!

PJ
dimolin

Re: Erika3 and Avr8

Post by dimolin »

Hi Paolo,

You are right. The problem is in the size of the stacks. After I increased them, the example works as is expected.

Thank you!


BR
Dimo
Locked