Wednesday, March 28, 2007

    Quick example of MPLAB C30 3.00's managed-PSV feature

    One of the big new features of MPLAB C30 3.00 is the new managed-PSV feature. Previous versions of C30 were limited to just one page of compiler-managed PSV constants. This new release will automatically switch to the correct PSV page when accessing a managed variable.

    The screenshot below shows a very simple example of the managed-PSV feature in action just sitting there.



    The space attribute places the variable into the program memory space, and the new __prog__ qualifier tells the compiler to manage the PSVPAG for this variable.

    You can also see the generated assembly code. You'll notice that the compiler saves and restores the current value of PSVPAG. This is to ensure compatibility with modules built with the older const-in-code model.

    Older libraries that don't know how to manage the PSVPAG may assume that PSVPAG is currently set to the .const section. Code generated using the managed-PSV feature must respect this assumption and save/restore the PSVPAG.

    I hope this post helps you get up to speed with the new feature (even though all of this information is documented in the updated C30 User's Guide). Have fun flipping pages!

    No comments: