R
R
RomanoO2012-04-19 17:01:36
Android
RomanoO, 2012-04-19 17:01:36

HC-05 + Android Bluetooth Module - Array Transfer

Good evening, Habr!

I got this module. I hooked it up to stm32vldiscovery via uart (I used the 1st uart).
The response part is written for Android according to this manual .
There was a problem while trying to pass the elementary sequence "okay". I tried to send it like this: So: In any case, only “y” comes, that is, the last byte. Maybe someone faced such a problem? Something I don’t really want to transfer arrays byte by byte, while synchronizing with delays.
void USART_PutSequence(uint8_t *sequence)
{
while(*sequence != 0) {
USART_SendData(USART1, (uint8_t)*sequence);
sequence++;
}
}

void USART_PutSequence(uint8_t *sequence)
{
USART_SendData(USART1, (uint8_t)sequence[0]);
USART_SendData(USART1, (uint8_t)sequence[1]);
USART_SendData(USART1, (uint8_t)sequence[2]);
USART_SendData(USART1, (uint8_t)sequence[3]);
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
RomanoO, 2012-04-21
@RomanoO

The solution was found in polling the Transmit Completed bit after sending the next byte:
void USART_PutSequence(uint8_t *sequence)
{
int i = 0;
while(sequence[i] != 0) {
USART_SendData(USART1, (uint8_t)sequence[i++]);
while (!(USART1->SR & USART_FLAG_TC));
}
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question