The demo application includes an interrupt driven UART test where one task transmits characters that are then received by another task. For correct operation of this functionality a loopback connector must be fitted to the lower 9 way plug on CN 63 (pins 2 and 3 must be connected together on the 9Way connector). Also the low CN63 plug must be linked to microcontroller using jumpers as described in the Application Board User Manual (NEC document number EASE-UM-0019-2.1). Demo application hardware setup - Target Boards (all other ports)The demo application makes use of the two LEDs that are mounted directly onto the target board, so no additional hardware setup is required.
FunctionalityThis section describes the functionality of the full demo that runs on the V850ES/Fx3 Application Board. The target boards do not have the IO interface or memory required for the full demo so only execute of subset of the described tasks.The full demo project creates 32 tasks before starting the RTOS scheduler. Most of these tasks consist of the 'standard demo' tasks - the purpose of these tasks is to both demonstrate the RTOS API and test the RTOS port. They do not in themselves perform any other useful function. In addition to the standard demo tasks the demo creates two 'register test' tasks. These fill the microcontroller registers with known values, then continuously check that each register still contains its expected value - each task using different values. As the tasks run with very low priority they will get pre-empted regularly. A register test task finding an unexpected value in one of its registers is indicative of an error in the pre-emption context switching mechanism. Finally, a 'check' task is used to give visible feedback of the system status. It only executes every three seconds but has a high priority so is guaranteed to get processing time. Each time it executes it inspects the status of all the other tasks in the system to see if any of them are reporting an error. The check task will toggle an LED every 3 seconds provided all the other tasks are running as expected. The toggle rate will change to 500ms if an error is discovered in any task. When executing correctly the demo will behave as follows:
Building the demo application
Programming the microcontroller and debugging
Configuration and Usage DetailsRTOS port specific configurationConfiguration items specific to this demo are contained in FreeRTOS\Demo\NEC_V850ES_IAR\FreeRTOSConfig.h. The constants defined in this file can be edited to suit your application.The configDATA_MODE configuration constant is specific to the V850ES port. If the compiler options are set to use either the small or large memory model then configDATA_MODE must be set to 0. If the compiler options are set to use the tiny data model then configDATA_MODE must be set to 1. Each port #defines 'BaseType_t' to equal the most efficient data type for that processor. This port defines BaseType_t to be of type long. Note that vPortEndScheduler() has not been implemented. Writing interrupt service routinesInterrupt service routines that cannot cause a context switch have no special requirements and can be written as described by the IAR compiler documentation.Often you will require an interrupt service routine to cause a context switch. For example a serial port character being received may unblock a high priority task that was blocked waiting for the character to arrive. If the unblocked task has a higher priority than the current task then the ISR should return directly to the unblocked task. Limitations in the IAR inline assembler necessitate such interrupt service routines use an assembly file wrapper. The UART driver is included in this demo to demonstrate the mechanism. The receive handler is replicated below. First the assembly file wrapper. ; ISR_Support.h defines the portSAVE_CONTEXT and portRESTORE_CONTEXT ; macros. #include "ISR_Support.h" PUBLIC vUARTRxISRWrapper EXTERN vUARTRxISRHandler RSEG CODE:CODE ; The wrapper is the interrupt entry point. vUARTRxISRWrapper: ; The ISR must start with a call to the portSAVE_CONTEXT() macro to save ; the context of the currently running task. portSAVE_CONTEXT ; Once the context is saved the C portion of the handler can be called. ; This is where the interrupting peripheral is actually serviced. jarl vUARTRxISRHandler, lp ; Finally the ISR must end with a call to portRESTORE_CONTEXT() to restore ; the context of which ever task is selected to run - which may be ; different to the task that was running before the interrupt started. portRESTORE_CONTEXT An example assembly file wrapper for an interrupt handler.
The C portion of the interrupt handler is just a standard C function. /* This standard C function is called from the assembly wrapper above. */ void vUARTRxISRHandler( void ) { char cChar; long lHigherPriorityTaskWoken = pdFALSE; /* Send the received character to the Rx queue. */ cChar = UD0RX; xQueueSendFromISR( xRxedChars, &cChar, &lHigherPriorityTaskWoken ); /* If sending a character to the Rx queue caused a task to unblock, and the unblocked task has a priority higher than the currently running task, then lHigherPriorityTaskWoken will have been set to true and a context switch should occur now. */ portYIELD_FROM_ISR( lHigherPriorityTaskWoken ); } The C portion of the example interrupt handler.
Resources used by the RTOS kernelThe RTOS kernel uses TM0 to generate the RTOS tick. The function prvSetupTimerInterrupts() in FreeRTOS\Source\portable\IAR\V850ES\port.c can be altered to use any convenient timer source.The RTOS kernel also requires exclusive use of the TRAP 0 instruction. Compiler optionsAs with all the ports, it is essential that the correct compiler options are used. The best way to ensure this is to base your application on the provided demo application files.Memory allocationSource\Portable\MemMang\heap_2.c is included in the demo application project to provide the memory allocation required by the RTOS kernel. Please refer to the Memory Management section of the API documentation for full information.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|
Latest News
NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS. Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019 Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed. View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS. Careers
FreeRTOS and other embedded software careers at AWS. FreeRTOS Partners
|