TI MSP430 series microcontroller serial communication baud rate calculation method[Copy link]
TI MSP430 series microcontroller, the baud rate value of the usart module is determined by the following three registers: UxBR0, UxBR1, UxMCTL Baud rate = BRCLK/N, mainly to calculate N. BRCLK: clock source, which can be set by registers as the clock source; through the SSEL two bits of register UCAxCTL1, 01: ACLK, 02: SMCLK N: the frequency division factor generated by the baud rate. N=UxBR1+UxBR0+UxMCTL, where UxBR1+UxBR0 is the integer part, UxMCTL is the set fractional part, where UxBR1 is the high bit, UxBR0 is the low bit, and the two are combined into a 16-bit word. For example: baud rate = 115200, clock source = 8MHz, external crystal oscillator N=8000000/115200=69.44. Obviously: UxBR1+UxBR0=69, that is, UxBR1=0, UxBR0=0x45, first round the fractional part 0.44×8, that is, 3.52, to 3. The 3 means that there must be 3 1s in the 8 bits in UxMCTL, and UxMCTL is divided into First Stage Modulation and Second Stage Modulation, that is, the former is the upper 4 bits, with a value range of 0-F, and the latter is the lower 4 bits. Note that the last 4 bits are preferably even numbers. The decimal part obtained in the previous step is rounded to the upper and lower bits, such as 3, which can be written as 0x16.