UART : STM32 ----> bluetooth

USART

i. GPIO Registers

1- GPIO port mode register

2- GPIO port output type register

3- GPIO port output speed register

ii. UART Registers

1- Transmitted data register

2- Recieved data register

3- Baud rate register

baud rate = Fck/16*UARTdiv
Fck is a clock that depends on the APB of the UART. I am going to use APB1 which has UART4 and UART5 with clock frequency of 36 MHZ. Baud rate will be fixed at 9600. Then it is easy to calculate the remaining variable

2- Interrupt and status register

We need only three bits in this register
1) TXE: it indicates data is shifted from buffer and you can write more data.
2) TC: it indicates data is transmitted.
3)TC: indicates that data is transmitted.

3- control register 1

This register is concerened with the enabling and features of the UART as well as the interupts flags bits. The UART will be set at 8-bit with no parity bit.It sets the oversampling by either 8 or 16.

4- control register 2

This register is mostly concerned with the USART so only one bit will be used, the stop bit.

Block Diagram:

to be updated

Concepts:

1-Shadow Register

2-Alternate Functions

1- Open Drain Type: If you make the output pin HIGH the pin will be connected to ground through the switch and if you make the Output pin LOW the pin will be left floating since the switch will be turned off.
2- Push-Pull Type: If you make the output HIGH the pin will be connected to Vdd through the PNP switch and if you make the Output pin LOW the pin will be connected to Ground thorough the NPN switch.

3- Oversampling

Oversampling is a technique, which is used by the receive engine of the USART peripheral. It is used for data recovery by discriminating between the valid incoming data and noise. The oversampling method can be selected by programming the OVER8 bit in the USART_CR1 register and can be either 16 or 8 times the baud rate clock. the choice between 16 or 8 is a trade-off between speed and clock tolerance. .

FT232

FT232 was used to convert TTL to USB to connect the STM board to the PC
Rx->Tx
Tx->Rx
Gnd->Gnd

Nested vectored interrupt controller (NVIC)

Echo program

A simple echo program was created using UART

I2C

Direct memory access controller (DMA)

DMA can be used to reduce CPU overload. Data can be quickly moved by DMA without any CPU actions. This keeps CPU resources free for other operations.