Hi,
I'm making a project on a STM32F103 where I have to put a connectBlue BT module in SPP mode, I configure the BT module through USART2.
But it seems that I've configured the USART2 wrong, or maybe it's me sending functions which are causing me problems?
The USART should run:
- uart
- 115200 baudrate
- 8 bit
- 1 stop bit
- no parity
- no HW flow control
When I debug, I see that the USART2 registers are as followed:
SR = 0xC0
BBR = 0x138
CR1 = 0x202C
CR2 = 0x0
CR3 = 0x0
GRPT = 0x1
Here's my function to send a byte:
void usartSendByte(u8 Data)
{
USART_SendData(USART2, Data);
while((USART2->SR & USART_FLAG_TXE ) == 0);
}
void USART_SendData(USART_TypeDef* USARTx, uint16_t Data)
{
/* Check the parameters */
assert_param(IS_USART_ALL_PERIPH(USARTx));
assert_param(IS_USART_DATA(Data));
/* Transmit Data */
USARTx->DR = (Data & (uint16_t)0x01FF);
}
I'm a bit confused about how to receive data?? I would like to receive it in a circular buffer, since when I'm sending a configuration packet to the BT module I'll receive a comfirm packet including: start byte, packet type (1 byte), length (1 byte), data parameters (n bytes) and followed by a checksum (1 byte).
I know I have to write something in the USART2_IRQHandler(), some help/hints here would be appreciated thanks!
Best regards
Malke