fyi, I did get it to compile cleanly in mplab xc16 in post
1643, with some scant notes. No way of knowing if it works right though. I would gladly try the latest code and post a binary for a test if there is a current repository (before you download hundreds of megs).
Also it is often considered to use the motor as a boost charger. I was looking for a software implementation of PFC and found this, which happened to be for the DSPIC30 (i.e. PFC.c). PFC is good as you can get more charging power for a given breaker/circuit size, forcing the input current to an in-phase sine wave. I grabbed html versions of the source, will clean it up and see if xc16 can compile it, unless someone beats me to it.
some ancient pool pump with active microcontroller based pfc project
using the MC instead of a dedicated pfc chip makes some sense here, as it is already connected to all the gate drivers and a fair bit of etc.
Edit: since the motor inductance is fixed, might be useful to be able to tweak the boost charger pwm frequency for best efficiency.
Edit found a copy of the original project here, much better than the spam site
http://www.eevblog.com/forum/beginne...led-ac-motors/ MT2268.zip though some of the register names might be different from initial glance.
edit2: compared to ACIM FOC, you probably won't find PFC terribly challenging