I'm still working with something based on AN3206. I'm trying to figure out what's wrong with my commutation, and I started reading back the theta from the eTPU. It doesn't make any sense to me.
I have a 4000 count encoder and a motor with two pole pairs. According to the function description theta = (2 * encoder)/4000, so theta should advance twice for each cycle. However, it isn't even synchronized with the zero position of the encoder. See the attached plot.
In etpu_pmsmvc.c scale is set to scale = motor_pole_pairs * 0x1000000 / qd_pc_per_rev; .
Since there was not a "get theta" function I added one like this:
fract24_t fs_etpu_pmsmvc_get_theta(uint8_t channel)
pba = fs_etpu_data_ram(channel) + (0x4000 >> 2);
return (fract24_t)(*(pba + ((FS_ETPU_PMSMVC_THETA_OFFSET) >> 2)));