PSVPAG error PIC24FJ256DA210

fruitmans wrote on Wednesday, November 10, 2010:

I am trying to use the FreeRTOS kernel on the PIC24FJ256DA210 microcontroller from Microchip. When i select this device within the demo project and select the correct headerfile in FreeRTOS.h i get the following error.

port.c: In function ‘pxPortInitialiseStack’:
port.c:223: error: ‘PSVPAG’ undeclared (first use in this function)
port.c:223: error: (Each undeclared identifier is reported only once
port.c:223: error: for each function it appears in.)

I am pretty new to FreeRTOS so all the help i can get would be very helpfull.

Thanks in advance,

Rik Vugteveen

woops_ wrote on Wednesday, November 10, 2010:

The Microchip\MPLAB C30\support\PIC24F\h folder holds a header for each device individually in which PSVPAG is referenced. Are you including the header? It is normally inc from FreeRTOSconfig header.

richard_damon wrote on Wednesday, November 10, 2010:

It looks like that chip has a new feature (Extended Data Space) that may require a small change in the port to handle. It looks like the PSVPAG register becomes the DSWPAG and DSRPAG for EDS parts.

anonymous wrote on Friday, August 05, 2011:

A late reply, but here goes.

I had the same problem with a EDS pic device, a PIC24FJ256GB210.
I found a post on the microchip forum that dealt with the same issue: http://www.microchip.com/forums/m568144-print.aspx.

The suggested solution is to change the kernel code in a few places. In port.c under the portRESTORE_CONTEXT() macro, replace the line “POP PSVPAG” with POP “DSWPAG” and “POP DSRPAG”. The order of the pops is important!

In port.c under in the pxPortInitialiseStack function definition, replace the lines

*pxTopOfStack = PSVPAG; pxTopOfStack++;

with

*pxTopOfStack = DSRPAG; pxTopOfStack++; *pxTopOfStack = DSWPAG; pxTopOfStack++

.

Finally in portasm_PIC24.S in the _vPortYield section, replace “PUSH PSVPAG” with “PUSH DSRPAG” and “PUSH DSWPAG”, and replace the line “POP PSVPAG” with “POP DSWPAG” and “POP DSRPAG”. Again, notice the order of push and pops.

These changes make FreeRTOS run on the fore mentioned micro, but I cannot guarantee that they will work under all circumstances.