STM32F0 Baud rate calculation macro
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2017-05-20 12:25 PM
Posted on May 20, 2017 at 21:25
From STM32F0xx_hal_uart.h
/** @brief BRR division operation to set BRR register in 8-bit oversampling mode. * @param __PCLK__: UART clock. * @param __BAUD__: Baud rate set by the user. * @retval Division result */&sharpdefine UART_DIV_SAMPLING8(__PCLK__, __BAUD__) ((((__PCLK__)*2U) + ((__BAUD__)/2U)) / (__BAUD__))/** @brief BRR division operation to set BRR register in 16-bit oversampling mode.
* @param __PCLK__: UART clock. * @param __BAUD__: Baud rate set by the user. * @retval Division result */&sharpdefine UART_DIV_SAMPLING16(__PCLK__, __BAUD__) (((__PCLK__) + ((__BAUD__)/2U)) / (__BAUD__))So why is there a (__BAUD__)/2U) term in equations?
#baud-rate #stm32f0
Labels:
- Labels:
-
STM32F0 Series
This discussion is locked. Please start a new topic to ask your question.
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2017-05-20 6:31 PM
Posted on May 21, 2017 at 03:31
>>So why is there a (__BAUD__)/2U) term in equations?
Think of it as adding 0.5 after the division, ie rounding up
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Up vote any posts that you find helpful, it shows what's working..
