From eecb9852a0405717a7d1be77e70e5d10bbe9a29f Mon Sep 17 00:00:00 2001 From: richardbarry Date: Thu, 6 Jan 2011 10:06:09 +0000 Subject: [PATCH] Replace the function that returns the current run time counter value with a macro for easier inlining. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1229 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- .../Demo_Source/FreeRTOSConfig.h | 38 ++++++++++++++++--- .../Demo_Source/RunTimeStatsConfig.c | 16 -------- 2 files changed, 32 insertions(+), 22 deletions(-) diff --git a/Demo/MSP430X_MSP430F5438_CCS4/Demo_Source/FreeRTOSConfig.h b/Demo/MSP430X_MSP430F5438_CCS4/Demo_Source/FreeRTOSConfig.h index aaa0c5a9b..633984526 100644 --- a/Demo/MSP430X_MSP430F5438_CCS4/Demo_Source/FreeRTOSConfig.h +++ b/Demo/MSP430X_MSP430F5438_CCS4/Demo_Source/FreeRTOSConfig.h @@ -57,7 +57,7 @@ * executed from within CCS4! Once it has been executed, re-open or refresh * the CCS4 project and remove the #error line below. */ -#error Ensure CreateProjectDirectoryStructure.bat has been executed before building. See comment immediately above. +//#error Ensure CreateProjectDirectoryStructure.bat has been executed before building. See comment immediately above. #ifndef FREERTOS_CONFIG_H @@ -122,12 +122,38 @@ vApplicationSetupTimerInterrupt() generates the tick from timer A0, so in this case configTICK_VECTOR is set to TIMER0_A0_VECTOR. */ #define configTICK_VECTOR TIMER0_A0_VECTOR -extern void vConfigureTimerForRunTimeStats( void ); -extern unsigned long ulGetRunTimeStatsTime( void ); -extern volatile unsigned long ulStatsOverflowCount; + extern void vConfigureTimerForRunTimeStats( void ); + extern volatile unsigned long ulStatsOverflowCount; +/* Configure a 16 bit timer to generate the time base for the run time stats. +The timer is configured to interrupt each time it overflows so a count of +overflows can be kept - that way a 32 bit time value can be constructed from +the timers current count value and the number of overflows. */ #define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() vConfigureTimerForRunTimeStats() -#define portGET_RUN_TIME_COUNTER_VALUE() ulGetRunTimeStatsTime() - + +/* Construct a 32 bit time value for use as the run time stats time base. This +comes from the current value of a 16 bit timer combined with the number of times +the timer has overflowed. */ +#define portALT_GET_RUN_TIME_COUNTER_VALUE( ulCountValue ) \ + { \ + /* Stop the counter counting temporarily. */ \ + TA1CTL &= ~MC__CONTINOUS; \ + \ + /* Check to see if any counter overflow interrupts are pending. */ \ + if( ( TA1CTL & TAIFG ) != 0 ) \ + { \ + /* An overflow has occurred but not yet been processed. */ \ + ulStatsOverflowCount++; \ + \ + /* Clear the interrupt. */ \ + TA1CTL &= ~TAIFG; \ + } \ + \ + /* Generate a 32 bit counter value by combinging the current peripheral \ + counter value with the number of overflows. */ \ + ulCountValue = ( ulStatsOverflowCount << 16UL ); \ + ulCountValue |= ( unsigned long ) TA1R; \ + TA1CTL |= MC__CONTINOUS; \ + } #endif /* FREERTOS_CONFIG_H */ diff --git a/Demo/MSP430X_MSP430F5438_CCS4/Demo_Source/RunTimeStatsConfig.c b/Demo/MSP430X_MSP430F5438_CCS4/Demo_Source/RunTimeStatsConfig.c index e532d222d..17b0cacb0 100644 --- a/Demo/MSP430X_MSP430F5438_CCS4/Demo_Source/RunTimeStatsConfig.c +++ b/Demo/MSP430X_MSP430F5438_CCS4/Demo_Source/RunTimeStatsConfig.c @@ -102,19 +102,3 @@ interrupt void prvRunTimeStatsOverflowISR( void ) } /*-----------------------------------------------------------*/ -unsigned long ulGetRunTimeStatsTime( void ) -{ -unsigned long ulReturn; -unsigned short usCounterSnapshot; - - TA1CTL &= ~MC__CONTINOUS; - _nop(); - _nop(); - ulReturn = ( ulStatsOverflowCount << 16UL ); - usCounterSnapshot = TA1R; - ulReturn |= ( unsigned long ) usCounterSnapshot; - TA1CTL |= MC__CONTINOUS; - - return ulReturn; -} -/*-----------------------------------------------------------*/ -- 2.39.5