I am trying position control of DC motor with AS5600 encoder with position as input from user through UART but I am unable to do so. If I give a 4 digit input say 1222, only the '1' in ASCII value is stored in Buffer array.
I tried creating an array of array to store each digits of the input through a for loop which are stored as ASCII value in the array and then convert them back to decimal.
for (int j = 0; j < NUM_DIGITS; j++)
{
HAL_UART_Receive(&huart2, rxBuffer[i][j], 1, 1000);
intValue = (intValue * 10) + (rxBuffer[i][j] - '0');
}
If
rxBuffer[i][j]is a 2D array then it means that you do not read the warnings. If it is the case you need to pass address of this element (ie(uint8_t *)&rxBuffer[i][j])You also do not check the result of the HAL function.
Example of simple line reading function (: