Podcast
Questions and Answers
What is the purpose of the HPRE field in a microcontroller?
What is the purpose of the HPRE field in a microcontroller?
When must the AHB clock frequency be at least 25 MHz?
When must the AHB clock frequency be at least 25 MHz?
What happens to the clocks after writing to the HPRE register?
What happens to the clocks after writing to the HPRE register?
What needs to be done to access registers in a module after reset?
What needs to be done to access registers in a module after reset?
Signup and view all the answers
What is the purpose of the D17 bit in the RCC_APB1ENR register?
What is the purpose of the D17 bit in the RCC_APB1ENR register?
Signup and view all the answers
What value does the USART_BRR register typically hold?
What value does the USART_BRR register typically hold?
Signup and view all the answers
Which part of the BRR register is utilized for setting the baud rate?
Which part of the BRR register is utilized for setting the baud rate?
Signup and view all the answers
What happens to the TXE flag when a character is moved to the transmit shift register?
What happens to the TXE flag when a character is moved to the transmit shift register?
Signup and view all the answers
What is the significance of the TXE flag in USART communication?
What is the significance of the TXE flag in USART communication?
Signup and view all the answers
Which USART register is responsible for transmitting characters from the microcontroller?
Which USART register is responsible for transmitting characters from the microcontroller?
Signup and view all the answers
What action marks the DR register as ready to accept a new character?
What action marks the DR register as ready to accept a new character?
Signup and view all the answers
What is the role of the TXE flag in avoiding data loss?
What is the role of the TXE flag in avoiding data loss?
Signup and view all the answers
Which part of the USART control sequence involves shifting out characters?
Which part of the USART control sequence involves shifting out characters?
Signup and view all the answers
In USART communication, what triggers a new character transmission after the last character?
In USART communication, what triggers a new character transmission after the last character?
Signup and view all the answers
After a character is shifted out, what allows loading a new character into the DR register?
After a character is shifted out, what allows loading a new character into the DR register?
Signup and view all the answers
What prevents a new character from being written into the DR register when transmitting data?
What prevents a new character from being written into the DR register when transmitting data?
Signup and view all the answers
What event marks the DR register as empty and ready for new data?
What event marks the DR register as empty and ready for new data?
Signup and view all the answers
Why is it important for the TXE flag to be set when transmitting data via USART2?
Why is it important for the TXE flag to be set when transmitting data via USART2?
Signup and view all the answers
Study Notes
Clock Configuration
- Clocks are divided using a prescaler factor between 1 and 16 AHB cycles after writing to PPRE2.
- Coding scheme for AHB clock division:
- 0xx: No division
- 100: Division by 2
- 101: Division by 4
- 110: Division by 8
- 111: Division by 16
- PPRE1 controls the APB low-speed prescaler; software must ensure the APB1 clock does not exceed 45 MHz.
- AHB clock also divided by a prescaler factor (1 to 16 AHB cycles) after PPRE1 configuration.
AHB and APB Prescalers
- HPRE bits (Bits 7:4) set the AHB prescaler; must maintain a minimum AHB clock frequency of 25 MHz for Ethernet use.
- System clock division configuration:
- 0xxx: No division
- 1000: Division by 2
- 1001: Division by 4
- 1010: Division by 8
- 1011: Division by 16
- Further divisions available up to 512.
HSI Oscillator
- HSION bit controls internal high-speed clock (HSI) enabling/disabling.
- HSIRDY signals HSI oscillator readiness after 6 clock cycles upon HSION clearing.
- HSI oscillator is default for SYSCLK and activates on reset.
USART2 Configuration Steps
- Enable clock for GPIOA and USART2.
- Set PA3 (USART2_RxD) function using GPIO_MODER and GPIO_AFRL registers.
- Configure baud rate using USART2_BRR register.
- Set up CR1 for oversampling rate, character size (8-bit or 9-bit), and reception enabling.
- Configure CR2 for the number of stop bits.
- Set CR3 for flow control settings.
- Enable USART2 after configuration, and wait for RXNE (Receive Not Empty) flag to indicate readiness to receive data.
Data Transmission via USART2
- Monitor RXNE flag to confirm data readiness in RXD pin.
- For data transfer, configure USART similarly by selecting PA2 for output using GPIO_MODER and GPIO_AFRL.
- Wait for TXE (Transmit Empty) flag before writing to the data register for transmission.
Programming Example
- Example code initializes USART2 and reads data to blink an LED based on received characters.
- Specific register manipulations for GPIO and USART configurations shown in the code snippets.
- Emphasize the need to configure the GPIO pins correctly to connect to USART functionalities.
USART Pins Overview
- Each USART port can have dedicated TX/RX pins, necessitating proper GPIO settings:
- Example for USART2: PA2 for TXD, PA3 for RXD.
- Ensure USART peripheral functions activated in GPIO settings.
Considerations
- Caution must be exercised around configuring prescalers to avoid exceeding clock limits on different domains (i.e., 45 MHz for APB1, 90 MHz for APB2).
- Bits reserved in registers must be maintained at reset values for reliable operation.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Description
Test your knowledge on STM32 clock configuration settings such as prescaler factors and clock division for AHB and APB buses. Understand the impact of setting the correct values to avoid exceeding specific clock frequency limits.