![]() KickStart board with LEDs and loopback connector
|
From FreeRTOS.org V4.7.1 all IAR projects for ARM devices are saved using the IAR Embedded Workbench V5.x format and will not open from V4.x versions. FreeRTOS.org V4.7.0 and earlier are still available from SourceForge and can be used with Embedded Workbench V4.x.
The ST ARM7 port was developed on the prototyping board included in the STR712-SK/IAR KickStart development kit (instructions are provided should you wish to use an alternative development board).
The STR712F is a peripheral rich (including CANBus), low pin count ARM7TDMI based flash embedded microcontroller. The evaluation kit came with a non time limited evaluation version of the IAR Embedded Workbench development tools for ARM (32KB limited), a J-Link USB JTAG debugger interface and a USB cable. The development board can be powered either through the USB JTAG connector or using an external power supply.
The development tools include a compiler, assembler and linker tool chain along with an IDE and a limited functionality simulator.
The processor peripheral library provided by ST was used to facilitate development.
As downloaded this demo application does not demonstrate the use of co-routines. See the co-routine documentation page for information on how co-routine functionality can be quickly added to this demonstration.
See also the FAQ My application does not run, what could be wrong?
A THUMB mode sample project is included for the STR71x IAR ARM7 port. The workspace rtosdemo.eww can be found in the Demo/ARM7_STR71x_IAR directory and should be opened from within the Embedded Workbench IDE.
The Demo/ARM7_STR71x_IAR/library directory contains the components of the ST peripheral library that are used by the demo application.
The Demo/ARM7_STR71x_IAR/serial directory contains a sample interrupt driven RS232 serial port driver.
The demo application utilises the LED built onto the prototyping board. This single LED is enough to check that the demo is functioning correctly (see the description of the 'Check' task below), but for best effect an extra four LEDs are required. These should be connected to the header pins marked T1_OCMPA, T1_OCMPB, T1_ICAPB and T1_ICAPA. These pins are set as GPIO outputs when the application is executed.

The IDE workspace contains 4 folders:
Simply open the rtosdemo workspace file from within the IAR Embedded Workbench IDE, ensure debug or release is selected as desired (as marked in red in the picture above), then select 'Rebuild All' from the IDE 'Project' menu.
When executing correctly the demo application will behave as follows:
The red LED built onto the KickStart development board is under control of the 'Check' task. Every three seconds the 'Check' task examines all the tasks in the system to ensure they are executing without error. It then toggles the red LED. If the red LED is toggling every three seconds then no errors have ever been detected. The toggle rate increasing to 500ms indicates that the 'Check' task has discovered at least one error. This mechanism can be checked by removing the loopback connector from the serial port (described above), and in doing so deliberately generating an error.
Each port #defines 'portBASE_TYPE' to equal the most efficient data type for that processor. This port defines portBASE_TYPE to be of type long.
Note that vPortEndScheduler() has not been implemented.
static __arm __irq void vAnISR( void )
{
/* ISR C code goes here. */
/* End the interrupt in the EIC. */
portCLEAR_EIC();
}
Often you will require an interrupt service routine to cause a context switch. For example a serial port character being received may wake a high priority task that was blocked waiting for the character. If the ISR interrupted a lower priority task then it should return immediately to the woken task. Limitations in the IAR inline assembler necessitate such interrupt service routines include an assembly file wrapper.
/* For simplicity the C function should operate in ARM mode.
Note that the __irq modifier is NOT used. */
__arm void vASwitchingISR( void )
{
portCHAR cContextSwitchRequired;
/* Write the ISR body here as per normal.
A boolean is used to say whether a context switch is required.
In this example assume we posted onto a queue and this caused a
task to be woken. */
cContextSwitchRequired = pdTRUE;
/* Immediately before the end of the ISR call the
portEND_SWITCHING_ISR() macro. */
portEND_SWITCHING_ISR( ( cContextSwitchRequired ) );
/* End the interrupt in the EIC. */
portCLEAR_EIC();
}
See the function vSerialISR() defined in Demo/ARM7_STR71x_IAR/serial/serial.c for a complete example.
The entry point for the ISR has to be written in an assembly file. This just places a call to the C function between
calls to the portSAVE_CONTEXT() and portRESTORE_CONTEXT() macros respectively as per the following template:
EXTERN vASwitchingISR
PUBLIC vASwitchingISREntry
/* This header defines the save/restore macros. */
#include "ISR_Support.h"
vASwitchingISREntry:
portSAVE_CONTEXT ; Call portSAVE_CONTEXT macro first
bl vASwitchingISR ; Then call the function written in the C file.
portRESTORE_CONTEXT ; Call portRESTORE_CONTEXT last.
END
See the file Demo/ARM7_STR71x_IAR/serial/serialIAR.S79 for a complete example.
NOTE! : The processor MUST be in supervisor mode when the scheduler is started (vTaskStartScheduler is called). The demo applications included in the FreeRTOS.org download switch to supervisor mode prior to main being called. If you are not using one of these demo application projects then ensure Supervisor mode is entered before calling vTaskStartScheduler().
Interrupt service routines always run in ARM mode. All other code executes in THUMB mode.
Note: The stack size of each necessary operating mode is configured using constants defined within the file Demo/ARM7_STR71x_IAR/CStartup.s79. The IAR linker configuration utility is not used, and stacks are not setup for all operating modes.
SWI instructions are used by the real time kernel and can therefore not be used by the application code.
Unfortunately these warning cannot be fixed by modifying the source code as they predominantly relate to benign code that was added in order to fix warnings generated by other compilers (mainly relating to type casting). Some warnings have therefore been disabled in the project file.