\r
 void vPortEndScheduler( void )\r
 {\r
-       /* It is unlikely that the AVR port will get stopped.  If required simply\r
-       disable the tick interrupt here. */\r
+       /* Not implemented - unlikely to ever be required as there is nothing to\r
+       return to. */\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
  */\r
 static void prvSetupTimerInterrupt( void )\r
 {\r
+/* The peripheral clock divided by 32 is used by the timer. */\r
+const unsigned portSHORT usReloadValue = ( unsigned portSHORT ) ( ( ( configPER_CLOCK_HZ / configTICK_RATE_HZ ) / 32UL ) - 1UL );\r
 \r
        TMCSR0_CNTE=0;          /* Count Disable */\r
     TMCSR0_CSL=0x2;            /* CLKP/32 */\r
     TMCSR0_RELD=1;             /* Reload */\r
     \r
     TMCSR0_UF=0;               /* Clear underflow flag */\r
-       //TMRLR0=0x1F3;         /* Tick = 1 ms*/ \r
-       TMRLR0=0x1387;          /* Tick = 10 ms*/ \r
+       TMRLR0=usReloadValue;\r
        TMCSR0_INTE=1;          /* Interrupt Enable */\r
        TMCSR0_CNTE=1;          /* Count Enable */\r
        TMCSR0_TRG=1;           /* Trigger */\r
 
 #define portLONG               long\r
 #define portSHORT              int\r
 #define portSTACK_TYPE unsigned portSHORT\r
-#define portBASE_TYPE  char\r
+#define portBASE_TYPE  long\r
 \r
 /* This is required since SOFTUNE doesn't support inline directive as is. */\r
 #define inline\r