FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [July 2006 Threads] ATmega2560 Porting Help !!Posted by Nobody/Anonymous on July 14, 2006 I've successfully ported you RTOS on my board equipped with ATMega1280 microcontroller and all seems to works great. In my next project I need to use ATMega2560 microcontroller but when I try to port the OS on this device IAR compiler gives me some warnings and demo software doesn't work. I suppose that It is due to the different size of 2560 program counter register, but I'm not sure. Is freeRTOS compatible with ATMega2560 ? Thank you
RE: ATmega2560 Porting Help !!Posted by Richard on July 15, 2006 I am not familiar with the 2560, but if the program counter is 3 bytes then this will definitely prevent the standard code from executing. I think this should be simple to fix.
Going into and out of interrupts the hardware will handle the three bytes. This area can therefore probably remain the same.
A change will definitely be required where the initial stack of the task is set up. Take a look in the function pxPortInitialiseStack() within Source/Portable/IAR/ATMega323. Here you will see the following code (I have taken out the casting to make it more readable):
///////////////////////////////////////////////////////////
The first part of the stack is the hardware stack. Place the start address of the task on the hardware stack. */ usAddress = pxCode; *pxTopOfStack = ( usAddress & 0x00ff ); pxTopOfStack--;
usAddress >>= 8; *pxTopOfStack = ( usAddress & 0x00ff ); pxTopOfStack--;
/* Leave enough space for the hardware stack before starting the software stack. The '- 2' is because we have already used two spaces for the address of the start of the task. */ pxTopOfStack -= ( configCALL_STACK_SIZE - 2 );
///////////////////////////////////////////////////////////
This only places two bytes at the stop of the stack for the return address (in this case the start of the task). You will need to modify this to something like:
///////////////////////////////////////////////////////////
The first part of the stack is the hardware stack. Place the start address of the task on the hardware stack. */ usAddress = pxCode; *pxTopOfStack = ( usAddress & 0x00ff ); pxTopOfStack--;
usAddress >>= 8; *pxTopOfStack = ( usAddress & 0x00ff ); pxTopOfStack--;
/* AND THE THIRD BYTE! */ usAddress >>= 8; *pxTopOfStack = ( usAddress & 0x00ff ); pxTopOfStack--;
/* Leave enough space for the hardware stack before starting the software stack. The '- 3' is because we have already used two spaces for the address of the start of the task. */ pxTopOfStack -= ( configCALL_STACK_SIZE - 3 );
///////////////////////////////////////////////////////////
The size required by the hardware stack is going to be larger as each time the program counter is saved you will require an extra byte. It is likely therefore that you will want to increase the value of configCALL_STACK_SIZE.
Regards.
RE: ATmega2560 Porting Help !!Posted by Nobody/Anonymous on July 18, 2006 Thank you Richard,
with your suggestion now your OS works also with ATMega 2560. I've done only an additional modification:
/* The number of bytes used on the hardware stack by the task start address. */ #define portBYTES_USED_BY_RETURN_ADDRESS( 3 )
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|