|
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.
This Atmel SAM7 ARM7 port was developed on an AT91SAM7S-EK development/prototyping board from the AT91SAM7S64-IAR evaluation kit (instructions are provided should you wish to use an alternative development board). Two FreeRTOS embedded WEB server demos also exist for the SAM7 series of microcontrollers.
The AT91SAM7S64 is a peripheral rich (including a USB 2.0 device), low pin count ARM7TDMI based flash 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 through which the development hardware can be powered. Everything required to start development.
The development tools include a compiler, assembler and linker tool chain along with an IDE and a limited functionality simulator.
A nice feature of this system is the library support provided by Atmel for the majority of the on board peripherals. This greatly speeds development and has so far proved reliable.
This demo includes a USB HID class example driver (as described below). The SAM7X lwIP embedded WEB server demo includes a USB CDC class example driver.
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 IAR ARM7 port. The workspace rtosdemo.eww can be found in the Demo/ARM7_AtmelSAM7S64_IAR directory and should be opened from within the Embedded Workbench IDE.
The Demo/ARM7_AtmelSAM7S64_IAR/SrcIAR and the Demo/ARM7_AtmelSAM7S64_IAR/resource directories contain support files for the Atmel libraries and build environment.
The Demo/ARM7_AtmelSAM7S64_IAR/serial and Demo/ARM7_AtmelSAM7S64_IAR/USB directories contain sample interrupt driven serial port and USB drivers respectively.
The demo application uses the LEDs built into the prototyping board so no other hardware setup is required.
Simply open the rtosdemo workspace file from within the IAR Embedded Workbench IDE, ensure flash debug is the selected
configuration (see picture below), then select 'Built Target' from the IDE 'Project' menu.
When executing correctly the demo application will behave as follows:
LED PA.3 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 LED PA.3. If LED PA.3 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.

If you are powering the prototyping board from the USB port the enumeration process will start immediately the demo application starts to execute.
If you are executing the FreeRTOS.org demo application from the debugger then remove the USB cable prior to resetting your PC. Now the microcontroller flash has been programmed you can remove the JTAG debugger interface also - the program will then start to execute as soon as you reconnect the USB cable.




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 AIC. */
AT91C_BASE_AIC->AIC_EOICR = 0;
}
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 AIC. */
AT91C_BASE_AIC->AIC_EOICR = 0;
}
See the function vSerialISR() defined in Demo/ARM7_AtemlSAM7S64_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_AtemlSAM7S64_IAR/serial/serialIAR.S79 for a complete example.
The SAM7 family uses a standard ARM7 core so the main real time kernel components are portable across all ARM7 devices - but the peripheral setup and memory requirements will require consideration. Items to consider:
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.
Demo/ARM7_AtemlSAM7S64_IAR/SrcIAR/CStartup.s79 does not configure stacks for all operation modes.
SWI instructions are used by the real time kernel and can therefore not be used by the application code.
'System Interrupts' can be generated from more than one source. Currently all system interrupts are assumed to originate from the PIT (periodic interval timer). The use of any other system interrupts will necessitate some wrapper code to ascertain the interrupts origin.
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.
Any and all data, files, source code, html content and documentation included in the FreeRTOS.org distribution or available on this site are the exclusive property of Real Time Engineers Ltd..
See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd..