uint16_t PWMC_SetPhaseVoltage( PWMC_Handle_t * pHandle, alphabeta_t Valfa_beta )
int32_t wUAlpha = Valfa_beta.alpha * ( int32_t )pHandle->hT_Sqrt3; int32_t wUBeta = -( Valfa_beta.beta * ( int32_t )( pHandle->PWMperiod ) ) * 2; #define SQRT3FACTOR (uint16_t) 0xDDB4 /* = (16384 * 1.732051 * 2)*/
int32_t wX = wUBeta; int32_t wY = ( wUBeta + wUAlpha ) / 2; int32_t wZ = ( wUBeta - wUAlpha ) / 2;
if ( wY < 0 ) { if ( wZ < 0 ) { pHandle->Sector = SECTOR_5; } }
wTimePhA = ( int32_t )( pHandle->PWMperiod ) / 4 + ( ( wY - wX ) / ( >int32_t )262144 ); wTimePhC = wTimePhA - wY / 131072; wTimePhB = wTimePhC + wX / 131072;