This repository has been archived on 2023-11-05. You can view files and clone it, but cannot push or open issues or pull requests.
FreeRTOS-Kernel/Demo/HCS12_GCC_banked
Richard Barry ab964f3c9d Updated to V4.0.5
+ Introduced API function xTaskResumeFromISR().  Same functionality as
	  xTaskResume(), but can be called from within an interrupt service routine.
	+ Optimised vListInsert() in the case when the wake time is the maximum 
	  tick count value.
	+ Bug fix:  The 'value' of the event list item is updated when the priority
	  of a task is changed.  Previously only the priority of the TCB itself was
	  changed.
	+ vTaskPrioritySet() and vTaskResume() no longer use the event list item.
	  This has not been necessary since V4.0.1 when the xMissedYield handling
	  was added.
	+ Lowered the PCLK setting on the ARM9 STR9 demo from 96MHz to 48MHz.
	+ When ending the scheduler - do not try to attempt a context switch when
	  deleting the current task.
	+ SAM7X EMAC drivers:  Corrected the Rx frame length mask when obtaining 
	  the length from the rx descriptor.
2006-08-11 10:42:06 +00:00
..
asm-m68hcs12 New demo files for HCS12 GCC port. 2006-05-27 13:53:15 +00:00
sys New demo files for HCS12 GCC port. 2006-05-27 13:53:15 +00:00
cpu.h New demo files for HCS12 GCC port. 2006-05-27 13:53:15 +00:00
FreeRTOSConfig.h Updated to V4.0.5 2006-08-11 10:42:06 +00:00
gelfunc.c New demo files for HCS12 GCC port. 2006-05-27 13:53:15 +00:00
ldscript-rtos.x New demo files for HCS12 GCC port. 2006-05-27 13:53:15 +00:00
main.c Updated to V4.0.5 2006-08-11 10:42:06 +00:00
Makefile New demo files for HCS12 GCC port. 2006-05-27 13:53:15 +00:00
memory.x New demo files for HCS12 GCC port. 2006-05-27 13:53:15 +00:00
ParTest.c Updated to V4.0.5 2006-08-11 10:42:06 +00:00
PE_Error.h New demo files for HCS12 GCC port. 2006-05-27 13:53:15 +00:00
README.txt New demo files for HCS12 GCC port. 2006-05-27 13:53:15 +00:00
sci.c New demo files for HCS12 GCC port. 2006-05-27 13:53:15 +00:00
sci.h New demo files for HCS12 GCC port. 2006-05-27 13:53:15 +00:00
serial.c New demo files for HCS12 GCC port. 2006-05-27 13:53:15 +00:00
startup.c Updated to V4.0.5 2006-08-11 10:42:06 +00:00
vectors.c New demo files for HCS12 GCC port. 2006-05-27 13:53:15 +00:00

##-------------------------------------------------------------------
## Readme.txt
##
## FreeRTOS Port Example for GCC/HCS12, called "Demo/HCS12_GCC_banked"
## Author Jefferson L Smith
##
##-------------------------------------------------------------------
This project stationery is designed to get you up and running quickly with GCC for MC9S12.

This port is tested with the development board Dragon12 (http://www.evbplus.com/ ).

This GCC release has been tested:
  gnu-m68hc1x 3.1 from http://m68hc11.serveftp.org/

The following folders are derived from GEL 1.6 (http://gel.sourceforge.net/ ):
- sys: starting point for GEL system includes
- asm-m68hcs12: specific 9S12 support, mostly referenced by sys

The demo was partially derived from Demo HCS12_CodeWarrior_banked.


##------------------------------------------------------------------------
##  Getting Started
##------------------------------------------------------------------------

---
The COM (SCI) port to use can be changed in the Makefile. Change this parameter in
CPPFLAGS: -DM6812_DEF_SCI=1
0 uses SCI0
1 uses SCI1

---
The LED port address can be changed in the Makefile. Change this parameter in
CPPFLAGS: -DPORT_LED=M6811_PORTB

The known ports are: M6811_PORTA, M6811_PORTB, M6811_PTT, M6811_PTP, M6811_PTM, and M6811_PTH. Any other port address could be used.

If a known port (above) is used, "startup.c" will initialize the correct port. If any other port is used (by typing the port address), it will need to be manually configured as outputs.


##------------------------------------------------------------------------
##  Memory Banks (PPAGE)
##------------------------------------------------------------------------

---
HCS12_GCC_banked uses two methods of placing certain code/data into PPAGE banks. The simple way is to edit each function's prototype or definition with an attribute macro ATTR_BANKn as defined in "cpu.h". Replace the 'n' with the number of the bank [0..13].

Also see "memory.x" sections .bank2 and .bank3 for examples of linking .text and .rodata of a specific ".o" object file into a specific bank.


##------------------------------------------------------------------------
##  Technical Issues
##------------------------------------------------------------------------

---
Passing a function pointer to vCreateTasks() does not include the PPAGE value. The result is that it's stack is initialized with PPAGE 0x30. That is not a problem because GCC generates a "trampoline" routine in unbanked memory which will bounce to the far address of the target function. The 16-bit function pointer passed is actually pointing to that trampoline. The trampoline would only be called once--when starting the task.

---
Here are three aspects to consider when defining ISR:

1. The ISR might be simple enough to not generate header code such as saving _.frame and has no local variables. This type can be defined as a normal routine (no interrupt attribute) or "naked" if it were implemented in this GCC. IMPORTANT: Use these special port macros defined in "portmacro.h". They go at the beginning and end of the function:

portISR_HEAD()  First line of the ISR
portISR_TAIL()  Last line of the ISR

This ensures all the needed softregs (pseudo CPU registers) are saved on the stack in case of a task swap within the ISR. Because this sets up the stack for a task swap, portTASK_SWITCH_FROM_ISR() could also be used in the ISR to save time and stack space.

2. The ISR may have one or more local variables. Define it using the interrupt attribute. The special portTASK_SWITCH_FROM_ISR() won't work. If a task is awakened within this ISR, use taskYIELD() which completely saves the appropriate softregs again and uses more stack.

3. Writing an ISR in assembly avoids the challenges with compiler-generated code. The steps would have to execute the way they execute in the C ISR.

---
If editing "startup.c", note that the function __premain() executes before global variables are initialized, and before the BSS section is cleared. So using any global variables may have unexpected results.

---
If you need to use other softregs, edit "portmacro.h" and "port.c" to save/restore them For example _.d1, _.d2, enabled by "-msoft-reg-count=2" on gcc commandline.

This port expects "-msoft-reg-count=0". This might be the gcc default, but is specified to be certain.


##------------------------------------------------------------------------
##  TODO
##------------------------------------------------------------------------

---