2019-08-27 03:01 AM
Hi Community,
I'm studying about the android program and stm32f407vet based controller.
The question I asked before is almost clear by using DMA USART.
I'm Transmit and Receive like under code.
code(IN STM32)
uint8_t rxBuffer;
int SIZE_OF_RX_TX = 1;
if (huart->Instance == USART3)
{
HAL_UART_Transmit_DMA(&huart1, rxBuffer, SIZE_OF_RX_TX);
HAL_UART_Transmit_DMA(&huart3, rxBuffer, SIZE_OF_RX_TX);
HAL_UART_Receive_DMA(&huart1, rxBuffer, SIZE_OF_RX_TX);
HAL_UART_Receive_DMA(&huart3, rxBuffer, SIZE_OF_RX_TX);
}
it means that receive USART3(BLUETOOTH) and TRANSMIT USART1 and USART3
and make a interuupt USART1 and USART3.
but in Android bluetooth only send byte array
code(in ANDROID)
void sendData(String text)
{
outputStream.write(text.getBytes("UTF-8"));
}
when I debug android program, and when I send text "1",
byte result is '49'
but when I send it to bluetooth usart3, the value sometimes broken.
and wrong value is occured.
Q.
is there a way to convert byte data USART?
How can I? I really don't know... help...
Solved! Go to Solution.
2019-08-27 04:30 PM
Oh Thanks,, I found why data is wrong....
Sorry....
I set a baud rate between bluetooth and microcontroller incorrectly...
2019-08-27 06:21 AM
Do you mean that when you send "1", your microcontroller sometimes receives wrong value?(something else than 49) or does this happen with other values only, like byte values higher than 127 when you don't receive what you send?
Edit: you don't need to convert "byte" values, it's 8bit value which does fit into a char or uint8_t which ever you use, however Java does not know what is "unsigned" and behaves differently for values between 128-255 than C.
2019-08-27 04:30 PM
Oh Thanks,, I found why data is wrong....
Sorry....
I set a baud rate between bluetooth and microcontroller incorrectly...
2019-08-27 06:10 PM
Related continuation https://community.st.com/s/question/0D50X0000BFypGBSQZ/hal-usart-dma-buffer-reset-method