2022-02-02 08:02 AM
I need to calculate angle value with input of sin/cos from ADC1/ADC2 channel by DMA way. As using the cordic of atan2 function,I think that two parameters of Y and X need to be written to pInBuff as like the key code below, is it correct?
sCordicConfig.Function = CORDIC_FUNCTION_PHASE; /* atan2 function */
sCordicConfig.Precision = CORDIC_PRECISION_6CYCLES; /* max precision for q1.31 atan2 */
sCordicConfig.Scale = CORDIC_SCALE_0; /* no scale */
sCordicConfig.NbWrite = CORDIC_NBWRITE_2; /* Two input data: x and y */
sCordicConfig.NbRead = CORDIC_NBREAD_1; /* One output data: atan2 */
sCordicConfig.InSize = CORDIC_INSIZE_32BITS; /* q1.31 format for input data */
sCordicConfig.OutSize = CORDIC_OUTSIZE_32BITS; /* q1.31 format for output data */
if (HAL_CORDIC_Configure(&hcordic, &sCordicConfig) != HAL_OK)
{
/* Configuration Error */
Error_Handler();
}
HAL_ADC_Start_DMA(&hadc1, (uint32_t*) aSin, 1);
HAL_ADC_Start_DMA(&hadc2, (uint32_t*) aCos, 1);
aTan[0] = aSin[0];
aTan[1] = aCos[0];
HAL_CORDIC_Calculate_DMA(&hcordic, aTan, aArcTan2,1,CORDIC_DMA_DIR_IN_OUT)