Statistics implementation PIC32 Example 18

PIC24
MPLAB X 1.10 Mac
C30 Compiler Following example 18 for PIC32  and making minor changes for PIC24, I am getting compiler errors.  I have the addition to FreeRTOSConfig.h as:
/* The following should not be included in asm files. */
#ifdef __LANGUAGE_C__ /* portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() is defined to call the
function that sets up timer 2 (T2) as the time base for the run time
statistics.  T2 is a 16-bit timer and generates an interrupt when it
overflows. portALT_GET_RUN_TIME_COUNTER_VALUE() is defined to set its parameter to
the current run time stats counter/time value.  The returned timer value
is 32-bits long, and is formed by shifting the T2 overflow count into the
top two bytes of a 32-bit number, then bitwise ORing the result with the
current T2 count value. */
void vSetupTimerForRunTimeStats( void );
unsigned long ulGetRunTimeStatsCounterValue( void );
                extern unsigned long ulCountValue;
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() vSetupTimerForRunTimeStats() /* T2 is 16-bits and generate an interrupt when it overflows.  The
number of overflows is stored in ulTMR2OverflowCount.  This macro
combines the current 16-bit counter value with the number of overflows
to return a 32-bit timer value. */
#define portALT_GET_RUN_TIME_COUNTER_VALUE( ulCountValue )
{
extern volatile unsigned long ulTMR2OverflowCount;
                        unsigned long ulCountValue;                                            

/* Disconnect the clock from the counter so it does not change 
while its value is being used. */
T2CON_VALUE = T2_OFF;

/* The number of overflows is shifted into the most significant
two bytes of the returned 32-bit value. */
ulCountValue = ( ulTMR2OverflowCount << 16UL );

/* The current T2 counter value is used as the least
significant two bytes of the returned 32-bit value. */
ulCountValue |= ( unsigned long ) ReadTimer2();

/* Reconnect the clock to the counter. */
T2CON_VALUE = T2_ON;
} #endif /* __LANGUAGE_C__ */ Note: T2CON_VALUE is being set to match comments and turn timer off at start.  This define and value was all that was changed for PIC24 My error is reported in task.c as:
../../../Source/tasks.c: In function ‘vTaskGetRunTimeStats’:
../../../Source/tasks.c:1340: error: invalid lvalue in assignment
../../../Source/tasks.c:1340: error: invalid lvalue in assignment
../../../Source/tasks.c: In function ‘vTaskSwitchContext’:
../../../Source/tasks.c:1598: error: invalid lvalue in assignment
../../../Source/tasks.c:1598: error: invalid lvalue in assignment It appears that the defined function does not appear to return an unsigned long to the caller(??). 
ulCountValue was not previously defined so I have defined it globally for debugging purposes (prior to main()) Thoughts?

Statistics implementation PIC32 Example 18

ulCountValue is defined – it is in the code you have posted as the parameter to the macro in the code you have posted!  You have then created another copy of it inside the macro, so I’m not sure what the pre-processor and subsequently the compiler will do at all.  It sounds like you then have a third global variable of the same name defined before main(), which will never get used anyway as the block scope one in the macro will shadow it. I would suggest starting by removing the two unnecessary variables that have the same name as the macro parameter and see what that does.  If you get the same error then, it must be something inside the macro that is causing it as the macro is not supposed to return an unsigned long to the caller, but assign the unsigned long to the macro parameter. Regards.

Statistics implementation PIC32 Example 18

Richard, Correct, these additions were evidence of my desperation and their removal put me back at start.  If the result is to be the assignment of the value to the macro parameter (ulCountValue in FreeRTOSConfig.c), I assume that is passed to the variable ulTotalRunTime in task.c.  I am trying to understand why this is not working and looking at C30 vs C32 compiler differences. One other function definition I can not find code for via the new IDE is:
unsigned long ulGetRunTimeStatsCounterValue( void );
This is before the macro definition and I do not see a corresponding function Another thought I had was that the Macro in question uses PIC24 peripheral macros and I have included a header in FreeRTOSConfig.h in hopes that that would be available to task.c if needed.  Where is the macro evaluated?  Should I just toggle bits and not use the externally defined macros like T2CON_VALUE? Thanks,
Duncan

Statistics implementation PIC32 Example 18

I am trying to understand why this is not working and looking at C30 vs C32 compiler differences.
This is just standard C code, I would be very surprised if your problem was anything to do with a compiler difference.
One other function definition I can not find code for via the new IDE is:
unsigned long ulGetRunTimeStatsCounterValue( void );
That just looks like a mistake to me and that the macro portGET_RUN_TIME_COUNTER_VALUE() was originally used – which could have used the ulGetRunTimeStatsCounterValue() function, but portALT_GET_RUN_TIME_COUNTER_VALUE() does not – the prototype would be wrong for a start (the “ALT” in the macro name just means “ALTernative”). To find which line in the macro is causing the problem I would suggest temporarily converting the macro to a function.  The compiler will then tell you the line the error is occurring on. Regards.