2020-02-27 09:17 AM
2020-02-27 10:44 AM
We do not know what type of a sensor are you using.
If it have analog voltage output use ADC to read its data.
UART is a communication method.
UART can be used to output data from an MCU to other device.
Its usefull if MCU board doent have any display and you want to use PC instead.
2020-02-27 10:30 PM
yeah ! that's fine here i use
HAL_GPIO_WritePin(GPIOA,GPIO_PIN_10,GPIO_PIN_SET);
HAL_ADC_Start(&hadc1);
HAL_ADC_PollForConversion(&hadc1,HAL_Delay);
row = HAL_ADC_GetValue(&hadc1);
HAL_GPIO_WritePin(GPIOA,GPIO_PIN_10,GPIO_PIN_RESET);
sprintf(msg,"%hu\r\n", row);
HAL_UART_Transmit(&huart2, (uint8_t*)msg, strlen(msg), HAL_Delay);
HAL_Delay(1);
then why i couldnt read a sensor value?
2020-02-28 12:03 AM
You want to read an analog voltage level using ADC, and output it to UART?
And there's no UART communication? Then debug UART - in debugger, read out the UART and GPIO registers values and check them against the RM, if they are of the expected value.
Or is there UART communication but the value is not expected? Then debug ADC - in debugger, read out the ADC registers values and check them.
JW
2020-02-28 06:31 PM
Sorry Mr.Jan I can't understand this . Will you please explain clea
2020-02-29 05:17 AM
Was the brain turned on, when you were reading Jan's text? What specifically you didn't understand? Basically he said - implement one thing at a time. Start with USART sending "Hello, world!", learn debugging, implement ADC reading and only then bring it all together.
2020-02-29 06:13 AM
Thank to both of you