From: richardbarry Date: Tue, 22 Nov 2011 13:21:37 +0000 (+0000) Subject: All for the TriCore demo: X-Git-Tag: V7.1.0~24 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=8461335f0249e05cb3b53916c7e467e93934239d;p=freertos All for the TriCore demo: + Comment serial.c + Improve the interaction between InterruptNetTest.c and main.c so both too short and too long periods are trapped. + Remove debug code from FreeRTOSConfig.h. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1636 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- diff --git a/Demo/TriCore_TC1782_TriBoard_GCC/RTOSDemo/FreeRTOSConfig.h b/Demo/TriCore_TC1782_TriBoard_GCC/RTOSDemo/FreeRTOSConfig.h index 898774a75..5b513540b 100644 --- a/Demo/TriCore_TC1782_TriBoard_GCC/RTOSDemo/FreeRTOSConfig.h +++ b/Demo/TriCore_TC1782_TriBoard_GCC/RTOSDemo/FreeRTOSConfig.h @@ -122,15 +122,6 @@ peripheral clock. */ /* Default definition of configASSERT(). */ #define configASSERT( x ) if( ( x ) == 0 ) { portDISABLE_INTERRUPTS(); for( ;; ); } -extern volatile unsigned long ulNest, ulMaxNest; -#define COUNT_NEST() \ -{ \ - ulNest++; \ - if( ulNest > ulMaxNest ) \ - { \ - ulMaxNest = ulNest; \ - } \ -} #endif /* FREERTOS_CONFIG_H */ diff --git a/Demo/TriCore_TC1782_TriBoard_GCC/RTOSDemo/InterruptNestTest.c b/Demo/TriCore_TC1782_TriBoard_GCC/RTOSDemo/InterruptNestTest.c index 5b8c75e52..64e5ac76c 100644 --- a/Demo/TriCore_TC1782_TriBoard_GCC/RTOSDemo/InterruptNestTest.c +++ b/Demo/TriCore_TC1782_TriBoard_GCC/RTOSDemo/InterruptNestTest.c @@ -51,6 +51,28 @@ licensing and training services. */ +/* + * It is intended that the tasks and timers in this file cause interrupts to + * nest at least one level deeper than they would otherwise. + * + * A timer is configured to create an interrupt at moderately high frequency, + * as defined by the tmrtestHIGH_FREQUENCY_TIMER_TEST_HZ constant. The + * interrupt priority is by configHIGH_FREQUENCY_TIMER_PRIORITY, which is set + * to ( configMAX_SYSCALL_INTERRUPT_PRIORITY - 1UL ), the second highest + * priority from which interrupt safe FreeRTOS API calls can be made. + * + * The timer interrupt handler counts the number of times it is called. When + * it has determined that the number of calls means that 10ms has passed, it + * 'gives' a semaphore, and resets it call count. + * + * A high priority task is used to receive the data posted to the queue by the + * interrupt service routine. The task should, then, leave the blocked state + * and 'take' the available semaphore every 10ms. The frequency at which it + * actually leaves the blocked state is verified by the demo's check task (see + * the the documentation for the entire demo on the FreeRTOS.org web site), + * which then flags an error if the frequency lower than expected. + */ + /* Standard includes. */ #include #include @@ -69,21 +91,33 @@ #include #include -#warning DOCUMENT THIS /* This constant is specific to this test application. It allows the high frequency (interrupt nesting test) timer to know how often to trigger, and the check task to know how many iterations to expect at any given time. */ #define tmrtestHIGH_FREQUENCY_TIMER_TEST_HZ ( 8931UL ) +/* + * The handler for the high priority timer interrupt. + */ static void prvPortHighFrequencyTimerHandler( int iArg ) __attribute__((longcall)); + +/* + * The task that receives messages posted to a queue by the higher priority + * timer interrupt. + */ static void prvHighFrequencyTimerTask( void *pvParameters ); +/* Constants used to configure the timer and determine how often the task +should receive data. */ static const unsigned long ulCompareMatchValue = configPERIPHERAL_CLOCK_HZ / tmrtestHIGH_FREQUENCY_TIMER_TEST_HZ; static const unsigned long ulInterruptsPer10ms = tmrtestHIGH_FREQUENCY_TIMER_TEST_HZ / 100UL; static const unsigned long ulSemaphoreGiveRate_ms = 10UL; +/* The semaphore used to synchronise the interrupt with the task. */ static xSemaphoreHandle xHighFrequencyTimerSemaphore = NULL; -static unsigned long ulHighFrequencyCounterIterations = 0UL; + +/* Holds the count of the number of times the task is unblocked by the timer. */ +static volatile unsigned long ulHighFrequencyTaskIterations = 0UL; /*-----------------------------------------------------------*/ @@ -141,8 +175,16 @@ unsigned long ulCompareMatchBits; unsigned long ulInterruptNestingTestGetIterationCount( unsigned long *pulExpectedIncFrequency_ms ) { +unsigned long ulReturn; + *pulExpectedIncFrequency_ms = ulSemaphoreGiveRate_ms; - return ulHighFrequencyCounterIterations; + portENTER_CRITICAL(); + { + ulReturn = ulHighFrequencyTaskIterations; + ulHighFrequencyTaskIterations = 0UL; + } + + return ulReturn; } /*-----------------------------------------------------------*/ @@ -158,7 +200,7 @@ static void prvHighFrequencyTimerTask( void *pvParameters ) /* Just count how many times the task has been unblocked before returning to wait for the semaphore again. */ - ulHighFrequencyCounterIterations++; + ulHighFrequencyTaskIterations++; } } /*-----------------------------------------------------------*/ @@ -190,5 +232,6 @@ unsigned long ulHigherPriorityTaskWoken = pdFALSE; ulExecutionCounter = 0UL; } + /* Context switch on exit if necessary. */ portYIELD_FROM_ISR( ulHigherPriorityTaskWoken ); } diff --git a/Demo/TriCore_TC1782_TriBoard_GCC/RTOSDemo/main.c b/Demo/TriCore_TC1782_TriBoard_GCC/RTOSDemo/main.c index 8cb80f366..1b0d7dd79 100644 --- a/Demo/TriCore_TC1782_TriBoard_GCC/RTOSDemo/main.c +++ b/Demo/TriCore_TC1782_TriBoard_GCC/RTOSDemo/main.c @@ -365,7 +365,10 @@ unsigned long ulHighFrequencyTimerTaskIterations, ulExpectedIncFrequency_ms; (interrupt nesting) timer test has increment since the check task last executed, and the frequency at which it is expected to execute in ms. */ ulHighFrequencyTimerTaskIterations = ulInterruptNestingTestGetIterationCount( &ulExpectedIncFrequency_ms ); - if( ulHighFrequencyTimerTaskIterations < ( ( mainNO_ERROR_FLASH_PERIOD_MS / ulExpectedIncFrequency_ms ) - 1 ) ) + if( ( ulHighFrequencyTimerTaskIterations < ( ( mainNO_ERROR_FLASH_PERIOD_MS / ulExpectedIncFrequency_ms ) - 1 ) ) + || + ( ulHighFrequencyTimerTaskIterations > ( ( mainNO_ERROR_FLASH_PERIOD_MS / ulExpectedIncFrequency_ms ) +5 ) ) + ) { /* Would have expected the high frequency timer task to have incremented its execution count more times that reported. */ diff --git a/Demo/TriCore_TC1782_TriBoard_GCC/RTOSDemo/serial.c b/Demo/TriCore_TC1782_TriBoard_GCC/RTOSDemo/serial.c index f381ef274..36051a45f 100644 --- a/Demo/TriCore_TC1782_TriBoard_GCC/RTOSDemo/serial.c +++ b/Demo/TriCore_TC1782_TriBoard_GCC/RTOSDemo/serial.c @@ -65,6 +65,21 @@ /* Demo Includes. */ #include "serial.h" +/***************************************************************************** + * Please note! + * + * This file is here to provide a means of generating interrupts to test the + * FreeRTOS tricore port. First - it configures the UART into loopback mode, + * and has only been used in loopback mode. Therefore, the baud rate + * calculation used has never been verified for correctness. Second - + * characters are passed into and out of the interrupt service routines using + * character queues. This provides a good test of the interrupt interaction, + * context switching mechanism, and kernel loading, it is however highly + * inefficient if the UART is being used to handle even moderate amounts of + * data throughput. + */ + + /*---------------------------------------------------------------------------*/ /* @@ -212,7 +227,7 @@ unsigned char ucTx; xTransmitStatus = 0UL; } - /* Finally end ISR and switch Task. */ + /* Finally end ISR and switch Task if necessary. */ portYIELD_FROM_ISR( xHigherPriorityTaskWoken ); } /*---------------------------------------------------------------------------*/ @@ -237,7 +252,7 @@ unsigned char ucRx; /* Error handling code can go here. */ } - /* Finally end ISR and switch Task. */ + /* Finally end ISR and switch Task if necessary. */ portYIELD_FROM_ISR( xHigherPriorityTaskWoken ); } /*---------------------------------------------------------------------------*/ @@ -246,7 +261,7 @@ void prvCheckTransmit( void ) { /* Check to see if the interrupt handler is working its way through the buffer. */ - if ( 0 == xTransmitStatus ) + if( 0 == xTransmitStatus ) { /* Not currently operational so kick off the first byte. */ ASC0_TBSRC.reg |= 0x8000UL;