gannis wrote on Sunday, February 25, 2007:
Sure.
I havn’t examined what could to be done, if something, to break the notorious +128k limit. With the latest WinAVR I suppose it would be worth the effort.
- - -
E:\projects\freertos\Source\portable\GCC>type port.patch
— ATMega323\port.c Sun Nov 26 16:31:10 2006
+++ ATMega2560\port.c Sun Feb 25 12:02:48 2007
@@ -1,5 +1,5 @@
/*
- FreeRTOS.org V4.1.3 - Copyright (C) 2003-2006 Richard Barry.
+ FreeRTOS.org V4.1.2.1 - Copyright (C) 2003-2006 Richard Barry.
This file is part of the FreeRTOS.org distribution.
@@ -32,11 +32,11 @@
/*
-Changes from V2.6.0
+Changes from V4.1.2 (ATmega323)
+
+ Port made for ATmega2560: Register names and initialisations changed.
+ Three byte program counter handled.
- + AVR port - Replaced the inb() and outb() functions with direct memory
- access. This allows the port to be built with the 20050414 build of
- WinAVR.
*/
#include <stdlib.h>
@@ -56,7 +56,7 @@
#define portCLEAR_COUNTER_ON_MATCH ( ( unsigned portCHAR ) 0x08 )
#define portPRESCALE_64 ( ( unsigned portCHAR ) 0x03 )
#define portCLOCK_PRESCALER ( ( unsigned portLONG ) 64 )
-#define portCOMPARE_MATCH_A_INTERRUPT_ENABLE ( ( unsigned portCHAR ) 0x10 )
+#define portCOMPARE_MATCH_A_INTERRUPT_ENABLE ( ( unsigned portCHAR ) 0x02 )
/*-----------------------------------------------------------*/
@@ -216,6 +216,13 @@
*pxTopOfStack = ( portSTACK_TYPE ) ( usAddress & ( unsigned portSHORT ) 0x00ff );
pxTopOfStack–;
+ /* Three byte program counter in ATmega2560.
+ Set the top byte to 0 since we don’t yet have access to the upper
+ (128k+) program bank. */
+ usAddress >>= 8;
+ *pxTopOfStack = ( portSTACK_TYPE ) ( usAddress & ( unsigned portSHORT ) 0x00ff );
+ pxTopOfStack–;
+
/* Next simulate the stack as if after a call to portSAVE_CONTEXT().
portSAVE_CONTEXT places the flags on the stack immediately after r0
to ensure the interrupts get disabled as soon as possible, and so ensuring
@@ -395,9 +402,9 @@
/* Enable the interrupt - this is okay as interrupt are currently globally
disabled. */
- ucLowByte = TIMSK;
+ ucLowByte = TIMSK1;
ucLowByte |= portCOMPARE_MATCH_A_INTERRUPT_ENABLE;
- TIMSK = ucLowByte;
+ TIMSK1 = ucLowByte;
}
/*-----------------------------------------------------------*/
Changes in the Demo is trivial and left as an exercise; Change UCSRB to UCSR0B etc.