Bug in MKL25Z4.h for Initializing UART0 BDH?

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Bug in MKL25Z4.h for Initializing UART0 BDH?

ソリューションへジャンプ
914件の閲覧回数
alexdean
Contributor III

I'm looking at the MKL25Z4.H macros for UART0 Baud Rate Generation. The UART0_BDH_SBR(x) macro doesn't seem to take the upper five bits of x, but I believe it should. Is this a bug, am I misusing the macro, or is there a newer version of the file available?

#define UART0_BDH_SBR_MASK  0x1Fu
#define UART0_BDH_SBR_SHIFT 0
#define UART0_BDH_SBR_WIDTH 5
#define UART0_BDH_SBR(x)    (((uint8_t)(((uint8_t)(x))<<UART0_BDH_SBR_SHIFT))&UART0_BDH_SBR_MASK)‍‍‍‍

Here's the version information for the file:

/*
** ###################################################################
**     Processors:          MKL25Z128FM4
**                          MKL25Z128FT4
**                          MKL25Z128LH4
**                          MKL25Z128VLK4
**
**     Compilers:           Keil ARM C/C++ Compiler
**                          Freescale C/C++ for Embedded ARM
**                          GNU C Compiler
**                          GNU C Compiler - CodeSourcery Sourcery G++
**                          IAR ANSI C/C++ Compiler for ARM
**
**     Reference manual:    KL25P80M48SF0RM, Rev.3, Sep 2012
**     Version:             rev. 2.5, 2015-02-19
**     Build:               b150721
**
**     Abstract:
**         CMSIS Peripheral Access Layer for MKL25Z4
**
**     Copyright (c) 1997 - 2015 Freescale Semiconductor, Inc.
**     All rights reserved.
*/‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
ラベル(2)
タグ(2)
0 件の賞賛
1 解決策
665件の閲覧回数
mjbcswitzerland
Specialist V

Hi

UART0_BDH has only 5 bits in the divisor and the last three are used for different functions:

pastedImage_1.png

The macro is masking the upper 3 bits (not upper 5) and is therefore OK.

Regards

Mark

元の投稿で解決策を見る

0 件の賞賛
2 返答(返信)
664件の閲覧回数
alexdean
Contributor III

Thanks, now it makes sense. The SHIFT and mask values are from the perspective of each register, rather than the value SBR which spans two registers. So the source code has to extract the upper byte of the desired SBR value before calling the macro.

0 件の賞賛
666件の閲覧回数
mjbcswitzerland
Specialist V

Hi

UART0_BDH has only 5 bits in the divisor and the last three are used for different functions:

pastedImage_1.png

The macro is masking the upper 3 bits (not upper 5) and is therefore OK.

Regards

Mark

0 件の賞賛