EmbeddedRelated.com
Forums

porting FreeRtos to atmega2560

Started by Unknown July 23, 2008
Hello All.
I try to port FreRtos to atmega2560 WinAVR
I modified this piece in port.c

usAddress = ( unsigned portSHORT ) pxCode;
*pxTopOfStack = ( portSTACK_TYPE ) ( usAddress & ( unsigned
portSHORT ) 0x00ff );
pxTopOfStack--;

usAddress >>= 8;
*pxTopOfStack = ( portSTACK_TYPE ) ( usAddress & ( unsigned
portSHORT ) 0x00ff );
pxTopOfStack--;

/* AND THE THIRD BYTE */
usAddress >>= 8;
*pxTopOfStack = ( portSTACK_TYPE ) ( usAddress & ( unsigned
portSHORT ) 0x00ff );
pxTopOfStack--;
/* end of AND THE THIRD BYTE */

and changed timer interrupt settings to make interrupt work.
But still it resets even if I have only Idle Hook Task with only one
vTaskDelay function inside.
Could somebody point what I had overlooked?
Thanks
Alex.
Hello,
I've had the same problem and after reading your post and ATMega2560's
datasheet
I changed pxPortInitializeStack() in port.c as follow:

            usAddress = ( unsigned portLONG ) pxCode;
	*pxTopOfStack = ( portSTACK_TYPE ) ( usAddress & ( unsigned
portLONG ) 0x000000ff );
	pxTopOfStack--;

	usAddress >>= 8;
	*pxTopOfStack = ( portSTACK_TYPE ) ( usAddress & ( unsigned
portLONG ) 0x000000ff );
	pxTopOfStack--;

	usAddress >>= 8;
	*pxTopOfStack = ( portSTACK_TYPE ) ( usAddress & ( unsigned
portLONG ) 0x000000ff );
	pxTopOfStack--;

and I redifined type of usAddress variable as well:
            unsigned portLONG usAddress;
because portSHORT in AVR is only 16-bit wide and ATMega2560 have 22-
bit Program Counter register.
After these changes I port FreeRTOS demo to ATMega2560 and it works
correctly.

Good Luck,
walert