First working MCF52221 demo.

pull/4/head
Richard Barry 17 years ago
parent 094be62ef0
commit 58f3f932ee

@ -1,133 +0,0 @@
# Sample Linker Command File for CodeWarrior for ColdFire
KEEP_SECTION {.vectortable}
# Memory ranges
MEMORY {
vectorram (RWX) : ORIGIN = 0x20000000, LENGTH = 0x00000500
code (RX) : ORIGIN = 0x20000500, LENGTH = 0x00002B00
userram (RWX) : ORIGIN = 0x20003000, LENGTH = 0x00001000
}
SECTIONS {
# Heap and Stack sizes definition
___heap_size = 0x400;
___stack_size = 0x400;
# MCF52221 Derivative Memory map definitions from linker command files:
# __IPSBAR, __RAMBAR, __RAMBAR_SIZE, __FLASHBAR, __FLASHBAR_SIZE linker
# symbols must be defined in the linker command file.
# Memory Mapped Registers (IPSBAR= 0x40000000)
___IPSBAR = 0x40000000;
# 16 Kbytes Internal SRAM
___RAMBAR = 0x20000000;
___RAMBAR_SIZE = 0x00004000;
# 128 KByte Internal Flash Memory
___FLASHBAR = 0x00000000;
___FLASHBAR_SIZE = 0x00020000;
___SP_AFTER_RESET = ___RAMBAR + ___RAMBAR_SIZE - 4;
.userram : {} > userram
.code : {} > code
.vectorram : {} > vectorram
.vectors :
{
exceptions.c(.vectortable)
. = ALIGN (0x4);
} >> code
.text :
{
*(.text)
. = ALIGN (0x4);
*(.rodata)
. = ALIGN (0x4);
___ROM_AT = .;
___DATA_ROM = .;
} >> code
.data : AT(___ROM_AT)
{
___DATA_RAM = .;
. = ALIGN(0x4);
*(.exception)
. = ALIGN(0x4);
__exception_table_start__ = .;
EXCEPTION
__exception_table_end__ = .;
___sinit__ = .;
STATICINIT
__START_DATA = .;
*(.data)
. = ALIGN (0x4);
__END_DATA = .;
__START_SDATA = .;
*(.sdata)
. = ALIGN (0x4);
__END_SDATA = .;
___DATA_END = .;
__SDA_BASE = .;
. = ALIGN (0x4);
} >> userram
.bss :
{
___BSS_START = .;
__START_SBSS = .;
*(.sbss)
. = ALIGN (0x4);
*(SCOMMON)
__END_SBSS = .;
__START_BSS = .;
*(.bss)
. = ALIGN (0x4);
*(COMMON)
__END_BSS = .;
___BSS_END = .;
. = ALIGN(0x4);
} >> userram
.custom :
{
___HEAP_START = .;
___heap_addr = ___HEAP_START;
___HEAP_END = ___HEAP_START + ___heap_size;
___SP_END = ___HEAP_END;
___SP_INIT = ___SP_END + ___stack_size;
. = ALIGN (0x4);
} >> userram
___VECTOR_RAM = ADDR(.vectorram);
__SP_INIT = ___SP_INIT;
_romp_at = ___ROM_AT + SIZEOF(.data);
.romp : AT(_romp_at)
{
__S_romp = _romp_at;
WRITEW(___ROM_AT);
WRITEW(ADDR(.data));
WRITEW(SIZEOF(.data));
WRITEW(0);
WRITEW(0);
WRITEW(0);
}
}

@ -8,14 +8,14 @@ MEMORY {
vectorrom (RX) : ORIGIN = 0x00000000, LENGTH = 0x00000400
cfmprotrom (RX) : ORIGIN = 0x00000400, LENGTH = 0x00000020
code (RX) : ORIGIN = 0x00000500, LENGTH = 0x0001FB00
userram (RWX) : ORIGIN = 0x20000400, LENGTH = 0x00003C00
userram (RWX) : ORIGIN = 0x20000000, LENGTH = 0x00003C00
}
SECTIONS {
# Heap and Stack sizes definition
___heap_size = 0x4;
___stack_size = 0x200;
___stack_size = 0x100;

@ -1,133 +0,0 @@
# Sample Linker Command File for CodeWarrior for ColdFire
KEEP_SECTION {.vectortable}
# Memory ranges
MEMORY {
vectorram (RWX) : ORIGIN = 0x20000000, LENGTH = 0x00000500
code (RX) : ORIGIN = 0x20000500, LENGTH = 0x00002B00
userram (RWX) : ORIGIN = 0x20003000, LENGTH = 0x00001000
}
SECTIONS {
# Heap and Stack sizes definition
___heap_size = 0x400;
___stack_size = 0x400;
# MCF52221 Derivative Memory map definitions from linker command files:
# __IPSBAR, __RAMBAR, __RAMBAR_SIZE, __FLASHBAR, __FLASHBAR_SIZE linker
# symbols must be defined in the linker command file.
# Memory Mapped Registers (IPSBAR= 0x40000000)
___IPSBAR = 0x40000000;
# 16 Kbytes Internal SRAM
___RAMBAR = 0x20000000;
___RAMBAR_SIZE = 0x00004000;
# 128 KByte Internal Flash Memory
___FLASHBAR = 0x00000000;
___FLASHBAR_SIZE = 0x00020000;
___SP_AFTER_RESET = ___RAMBAR + ___RAMBAR_SIZE - 4;
.userram : {} > userram
.code : {} > code
.vectorram : {} > vectorram
.vectors :
{
exceptions.c(.vectortable)
. = ALIGN (0x4);
} >> code
.text :
{
*(.text)
. = ALIGN (0x4);
*(.rodata)
. = ALIGN (0x4);
___ROM_AT = .;
___DATA_ROM = .;
} >> code
.data : AT(___ROM_AT)
{
___DATA_RAM = .;
. = ALIGN(0x4);
*(.exception)
. = ALIGN(0x4);
__exception_table_start__ = .;
EXCEPTION
__exception_table_end__ = .;
___sinit__ = .;
STATICINIT
__START_DATA = .;
*(.data)
. = ALIGN (0x4);
__END_DATA = .;
__START_SDATA = .;
*(.sdata)
. = ALIGN (0x4);
__END_SDATA = .;
___DATA_END = .;
__SDA_BASE = .;
. = ALIGN (0x4);
} >> userram
.bss :
{
___BSS_START = .;
__START_SBSS = .;
*(.sbss)
. = ALIGN (0x4);
*(SCOMMON)
__END_SBSS = .;
__START_BSS = .;
*(.bss)
. = ALIGN (0x4);
*(COMMON)
__END_BSS = .;
___BSS_END = .;
. = ALIGN(0x4);
} >> userram
.custom :
{
___HEAP_START = .;
___heap_addr = ___HEAP_START;
___HEAP_END = ___HEAP_START + ___heap_size;
___SP_END = ___HEAP_END;
___SP_INIT = ___SP_END + ___stack_size;
. = ALIGN (0x4);
} >> userram
___VECTOR_RAM = ADDR(.vectorram);
__SP_INIT = ___SP_INIT;
_romp_at = ___ROM_AT + SIZEOF(.data);
.romp : AT(_romp_at)
{
__S_romp = _romp_at;
WRITEW(___ROM_AT);
WRITEW(ADDR(.data));
WRITEW(SIZEOF(.data));
WRITEW(0);
WRITEW(0);
WRITEW(0);
}
}

@ -65,17 +65,17 @@
*----------------------------------------------------------*/
#define configUSE_PREEMPTION 1
#define configUSE_IDLE_HOOK 0
#define configUSE_IDLE_HOOK 1
#define configUSE_TICK_HOOK 0
#define configCPU_CLOCK_HZ ( ( unsigned portLONG ) 80000000 )
#define configTICK_RATE_HZ ( ( portTickType ) 100 )
#define configMINIMAL_STACK_SIZE ( ( unsigned portSHORT ) 160 )
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 10 * 1024 ) ) /* The heap size is worked out from the linker script, so this constant is not used. */
#define configMINIMAL_STACK_SIZE ( ( unsigned portSHORT ) 140 )
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 14 * 1024 ) )
#define configMAX_TASK_NAME_LEN ( 12 )
#define configUSE_TRACE_FACILITY 1
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 0
#define configUSE_CO_ROUTINES 0
#define configUSE_CO_ROUTINES 1
#define configUSE_MUTEXES 1
#define configCHECK_FOR_STACK_OVERFLOW 2
#define configUSE_RECURSIVE_MUTEXES 1

@ -51,7 +51,6 @@
#include "task.h"
__declspec(interrupt:0) void vPIT0InterruptHandler( void );
extern unsigned portLONG __VECTOR_RAM[];
/* Constants used to configure the interrupts. */
#define portPRESCALE_VALUE 64
@ -62,7 +61,7 @@ extern unsigned portLONG __VECTOR_RAM[];
/*
* FreeRTOS.org requires two interrupts - a tick interrupt generated from a
* timer source, and a spare interrupt vector used for context switching.
* The configuration below uses PIT0 for the former, and vector 63 for the
* The configuration below uses PIT0 for the former, and vector 16 for the
* latter. **IF YOUR APPLICATION HAS BOTH OF THESE INTERRUPTS FREE THEN YOU DO
* NOT NEED TO CHANGE ANY OF THIS CODE** - otherwise instructions are provided
* here for using alternative interrupt sources.
@ -92,7 +91,7 @@ extern unsigned portLONG __VECTOR_RAM[];
*
* 3) Change the name of the function __cs3_isr_interrupt_127() within portasm.S
* to be correct for whichever vector number is being used. By default interrupt
* controller 0 number 63 is used, which corresponds to vector number 127.
* controller 0 number 16 is used, which corresponds to vector number 127.
*/
void vApplicationSetupInterrupts( void )
{

@ -81,7 +81,7 @@
/* Demo app includes. */
#include "BlockQ.h"
#include "death.h"
#include "flash.h"
#include "crflash.h"
#include "partest.h"
#include "semtest.h"
#include "PollQ.h"
@ -117,6 +117,9 @@ error have been detected. */
#define mainGEN_QUEUE_TASK_PRIORITY ( tskIDLE_PRIORITY )
#define mainWEB_TASK_PRIORITY ( tskIDLE_PRIORITY + 2 )
/* Co-routines are used to flash the LEDs. */
#define mainNUM_FLASH_CO_ROUTINES ( 3 )
/*
* Configure the hardware for the demo.
*/
@ -128,12 +131,6 @@ static void prvSetupHardware( void );
*/
static void prvCheckTask( void *pvParameters );
/*
* Implement the 'Reg test' functionality as described at the top of this file.
*/
static void vRegTest1Task( void *pvParameters );
static void vRegTest2Task( void *pvParameters );
/*-----------------------------------------------------------*/
/* Counters used to detect errors within the reg test tasks. */
@ -147,26 +144,17 @@ int main( void )
prvSetupHardware();
/* Start the standard demo tasks. */
vStartLEDFlashTasks( tskIDLE_PRIORITY );
vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
vStartGenericQueueTasks( mainGEN_QUEUE_TASK_PRIORITY );
vStartQueuePeekTasks();
vStartRecursiveMutexTasks();
vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
/* Start the reg test tasks - defined in this file. */
xTaskCreate( vRegTest1Task, ( signed portCHAR * ) "Reg1", configMINIMAL_STACK_SIZE, ( void * ) &ulRegTest1Counter, tskIDLE_PRIORITY, NULL );
xTaskCreate( vRegTest2Task, ( signed portCHAR * ) "Reg2", configMINIMAL_STACK_SIZE, ( void * ) &ulRegTest2Counter, tskIDLE_PRIORITY, NULL );
/* For demo purposes use some co-routines to flash the LEDs. */
vStartFlashCoRoutines( mainNUM_FLASH_CO_ROUTINES );
/* Create the check task. */
xTaskCreate( prvCheckTask, ( signed portCHAR * ) "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
/* The suicide tasks must be created last as they need to know how many
tasks were running prior to their creation in order to ascertain whether
or not the correct/expected number of tasks are running at any given time. */
vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY );
/* Start the scheduler. */
vTaskStartScheduler();
@ -215,36 +203,8 @@ portTickType xLastExecutionTime;
ulError |= 0x20UL;
}
if( xArePollingQueuesStillRunning() != pdTRUE )
{
ulError |= 0x40UL;
}
if( xIsCreateTaskStillRunning() != pdTRUE )
{
ulError |= 0x80UL;
}
if( xAreRecursiveMutexTasksStillRunning() != pdTRUE )
{
ulError |= 0x200UL;
}
if( ulLastRegTest1Count == ulRegTest1Counter )
{
ulError |= 0x1000UL;
}
if( ulLastRegTest2Count == ulRegTest2Counter )
{
ulError |= 0x1000UL;
}
ulLastRegTest1Count = ulRegTest1Counter;
ulLastRegTest2Count = ulRegTest2Counter;
/* If an error has been found then increase our cycle rate, and in so
going increase the rate at which the check task LED toggles. */
doing increase the rate at which the check task LED toggles. */
if( ulError != 0 )
{
ulTicksToWait = mainERROR_PERIOD;
@ -281,169 +241,19 @@ void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed portCHAR *pcTask
}
/*-----------------------------------------------------------*/
static void vRegTest1Task( void *pvParameters )
{
/* Sanity check - did we receive the parameter expected? */
if( pvParameters != &ulRegTest1Counter )
{
/* Change here so the check task can detect that an error occurred. */
for( ;; )
{
}
}
/* Set all the registers to known values, then check that each retains its
expected value - as described at the top of this file. If an error is
found then the loop counter will no longer be incremented allowing the check
task to recognise the error. */
asm volatile ( "reg_test_1_start: \n\t"
" moveq #1, d0 \n\t"
" moveq #2, d1 \n\t"
" moveq #3, d2 \n\t"
" moveq #4, d3 \n\t"
" moveq #5, d4 \n\t"
" moveq #6, d5 \n\t"
" moveq #7, d6 \n\t"
" moveq #8, d7 \n\t"
" move #9, a0 \n\t"
" move #10, a1 \n\t"
" move #11, a2 \n\t"
" move #12, a3 \n\t"
" move #13, a4 \n\t"
" move #14, a5 \n\t"
" move #15, a6 \n\t"
" \n\t"
" cmpi.l #1, d0 \n\t"
" bne reg_test_1_error \n\t"
" cmpi.l #2, d1 \n\t"
" bne reg_test_1_error \n\t"
" cmpi.l #3, d2 \n\t"
" bne reg_test_1_error \n\t"
" cmpi.l #4, d3 \n\t"
" bne reg_test_1_error \n\t"
" cmpi.l #5, d4 \n\t"
" bne reg_test_1_error \n\t"
" cmpi.l #6, d5 \n\t"
" bne reg_test_1_error \n\t"
" cmpi.l #7, d6 \n\t"
" bne reg_test_1_error \n\t"
" cmpi.l #8, d7 \n\t"
" bne reg_test_1_error \n\t"
" move a0, d0 \n\t"
" cmpi.l #9, d0 \n\t"
" bne reg_test_1_error \n\t"
" move a1, d0 \n\t"
" cmpi.l #10, d0 \n\t"
" bne reg_test_1_error \n\t"
" move a2, d0 \n\t"
" cmpi.l #11, d0 \n\t"
" bne reg_test_1_error \n\t"
" move a3, d0 \n\t"
" cmpi.l #12, d0 \n\t"
" bne reg_test_1_error \n\t"
" move a4, d0 \n\t"
" cmpi.l #13, d0 \n\t"
" bne reg_test_1_error \n\t"
" move a5, d0 \n\t"
" cmpi.l #14, d0 \n\t"
" bne reg_test_1_error \n\t"
" move a6, d0 \n\t"
" cmpi.l #15, d0 \n\t"
" bne reg_test_1_error \n\t"
" move ulRegTest1Counter, d0 \n\t"
" addq #1, d0 \n\t"
" move d0, ulRegTest1Counter \n\t"
" bra reg_test_1_start \n\t"
"reg_test_1_error: \n\t"
" bra reg_test_1_error \n\t"
);
}
/*-----------------------------------------------------------*/
static void vRegTest2Task( void *pvParameters )
void vApplicationIdleHook( void );
void vApplicationIdleHook( void )
{
/* Sanity check - did we receive the parameter expected? */
if( pvParameters != &ulRegTest2Counter )
{
/* Change here so the check task can detect that an error occurred. */
for( ;; )
{
}
}
/* Set all the registers to known values, then check that each retains its
expected value - as described at the top of this file. If an error is
found then the loop counter will no longer be incremented allowing the check
task to recognise the error. */
asm volatile ( "reg_test_2_start: \n\t"
" moveq #10, d0 \n\t"
" moveq #20, d1 \n\t"
" moveq #30, d2 \n\t"
" moveq #40, d3 \n\t"
" moveq #50, d4 \n\t"
" moveq #60, d5 \n\t"
" moveq #70, d6 \n\t"
" moveq #80, d7 \n\t"
" move #90, a0 \n\t"
" move #100, a1 \n\t"
" move #110, a2 \n\t"
" move #120, a3 \n\t"
" move #130, a4 \n\t"
" move #140, a5 \n\t"
" move #150, a6 \n\t"
" \n\t"
" cmpi.l #10, d0 \n\t"
" bne reg_test_2_error \n\t"
" cmpi.l #20, d1 \n\t"
" bne reg_test_2_error \n\t"
" cmpi.l #30, d2 \n\t"
" bne reg_test_2_error \n\t"
" cmpi.l #40, d3 \n\t"
" bne reg_test_2_error \n\t"
" cmpi.l #50, d4 \n\t"
" bne reg_test_2_error \n\t"
" cmpi.l #60, d5 \n\t"
" bne reg_test_2_error \n\t"
" cmpi.l #70, d6 \n\t"
" bne reg_test_2_error \n\t"
" cmpi.l #80, d7 \n\t"
" bne reg_test_2_error \n\t"
" move a0, d0 \n\t"
" cmpi.l #90, d0 \n\t"
" bne reg_test_2_error \n\t"
" move a1, d0 \n\t"
" cmpi.l #100, d0 \n\t"
" bne reg_test_2_error \n\t"
" move a2, d0 \n\t"
" cmpi.l #110, d0 \n\t"
" bne reg_test_2_error \n\t"
" move a3, d0 \n\t"
" cmpi.l #120, d0 \n\t"
" bne reg_test_2_error \n\t"
" move a4, d0 \n\t"
" cmpi.l #130, d0 \n\t"
" bne reg_test_2_error \n\t"
" move a5, d0 \n\t"
" cmpi.l #140, d0 \n\t"
" bne reg_test_2_error \n\t"
" move a6, d0 \n\t"
" cmpi.l #150, d0 \n\t"
" bne reg_test_2_error \n\t"
" move ulRegTest1Counter, d0 \n\t"
" addq #1, d0 \n\t"
" move d0, ulRegTest2Counter \n\t"
" bra reg_test_2_start \n\t"
"reg_test_2_error: \n\t"
" bra reg_test_2_error \n\t"
);
/* The co-routines run in the idle task. */
vCoRoutineSchedule();
}
/*-----------------------------------------------------------*/
/* To keep the linker happy. */
void exit( int n )
{
/* To keep the linker happy only as the libraries have been removed from
the build. */
( void ) n;
for( ;; ) {}
}

Loading…
Cancel
Save