2024-09-02 02:34 AM
I'm writing a code for getting angle from a AS5047u magentic encoder to get the angle but the value from the angle not seems to be updating in the live expressions
Solved! Go to Solution.
2024-09-05 08:27 PM
uint16_t spi_RX=0;
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, GPIO_PIN_RESET);
HAL_SPI_Transmit(&hspi1, (uint8_t*) &COMMAND, 1, 100);
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, GPIO_PIN_SET);
HAL_Delay(1);
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, GPIO_PIN_RESET);
HAL_SPI_Receive(&hspi1, (uint8_t*) &spi_RX, 1, 100);
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, GPIO_PIN_SET);
uint16_t ANGLEUNC = spi_RX & 0x3FFF;
enc.m_angle = (float)ANGLEUNC * (360.0f / 16383.0f);
enc.spi_RX = AS5047U_ANGLECOM;
this is the code that worked for me if you're using AS5047 you should receive the data in the second call
2024-09-02 02:48 AM
Both data[] and angle are not updating or just angle?
2024-09-02 03:35 AM
Both data[] and angle are not updating
2024-09-05 06:59 PM
I also use the ADC DMA function, but the ADC data value does not change in real time for Live Expression, and it stops at the voltage value first measured. I want to know a solution, too.
2024-09-05 08:27 PM
uint16_t spi_RX=0;
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, GPIO_PIN_RESET);
HAL_SPI_Transmit(&hspi1, (uint8_t*) &COMMAND, 1, 100);
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, GPIO_PIN_SET);
HAL_Delay(1);
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, GPIO_PIN_RESET);
HAL_SPI_Receive(&hspi1, (uint8_t*) &spi_RX, 1, 100);
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, GPIO_PIN_SET);
uint16_t ANGLEUNC = spi_RX & 0x3FFF;
enc.m_angle = (float)ANGLEUNC * (360.0f / 16383.0f);
enc.spi_RX = AS5047U_ANGLECOM;
this is the code that worked for me if you're using AS5047 you should receive the data in the second call