USCI serial port of msp430, a trick to fix it

Publisher:清新家园Latest update time:2016-06-20 Source: eefocusKeywords:msp430 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
The initialization settings of 430's USCI serial port (UART mode) are very complicated. UCA0BR0, UCA0BR1, UCA0MCTL, etc. need to be calculated according to the baud rate, and there are decimal part adjustments. Here is a header file shared. When operating the serial port, just one init_uart(9600); is enough. Note: 9600 can also be changed to other baud rates such as 4800, 115200, etc., which is very convenient.

#define clock 8000000
#define UCBRS(x) UCBRS_##x

void uart_init(long baud)
{
float x = clock / baud ;
long y = clock / baud ;
char n;
P1SEL = BIT1 + BIT2 ; // P1.1 = RXD, P1.2=TXD
P1SEL2 = BIT1 + BIT2 ; 
UCA0CTL1|=UCSSEL_2 ;

UCA0BR0 = y % 256; 
UCA0BR1 = y / 256;

n=(char)((x-y)*8);
UCA0MCTL=2*n; //UCBRS_n n为*2 
UCA0CTL1 &= ~UCSWRST; 
IE2 |= UCA0RXIE ; 
}

UCA0MCTL=2*n; This is a shift operation, please see register for details.

Of course, if the clock is modified, remember to modify the clock as well.

If it is useful, please support it. Below I will share the header file, which supports printf, getchar, etc.

Keywords:msp430 Reference address:USCI serial port of msp430, a trick to fix it

Previous article:TV backlight 3D infrared signal transmission solution based on MSP430G2303
Next article:What is the difference between ISP and IAP programming methods?

Recommended ReadingLatest update time:2024-11-16 14:59

Design of electronic blood pressure meter based on silicon pressure sensor and MSP430F149 microcontroller
1 Introduction The traditional instrument for measuring blood pressure is the mechanical mercury sphygmomanometer. Electronic sphygmomanometers have only appeared on the market in recent years. Compared with traditional sphygmomanometers, electronic sphygmomanometers are simple to operate and easy to use, but their
[Industrial Control]
Design of electronic blood pressure meter based on silicon pressure sensor and MSP430F149 microcontroller
MSP430 series chip crystal oscillator selection instructions
This report divides the MSP430 series chips into two parts, one is the high-speed crystal oscillator interface, and the other is the low-speed crystal oscillator interface. In general, the low-speed crystal oscillator interface can connect to the crystal oscillator that can be connected to the high-speed crystal oscill
[Microcontroller]
Capacitive touch MSP430 circuit and LED drive circuit design explanation
  The MSP430 series of microcontrollers are famous for their low power consumption and rich peripheral modules. For capacitive touch applications, the PIN RO capacitive touch detection method of MSP430 supports direct connection of the IO port to the detection electrode without any peripheral devices, which greatly si
[Power Management]
Capacitive touch MSP430 circuit and LED drive circuit design explanation
Getting Started with MSP430: Hardware Basics
A few points worth noting: 1. The reset signal is the starting point of the MCU. There are two reset signals for 430: the power-on reset signal POR and the power-on clear signal PUC. The POR signal is only used when the power is on and the RST/NMI reset pin is set to the reset function, and the system is reset when it
[Microcontroller]
Design of transmission control timing detection system based on MSP430F149 single chip microcomputer
Since the rocket launcher launches simple controlled rockets, the electrical signal interface between its directional tube and the rocket has an ignition signal interface like ordinary uncontrolled rockets, as well as a 32-core parameter setting signal interface. In the launch procedure, if the flight control para
[Microcontroller]
Design of transmission control timing detection system based on MSP430F149 single chip microcomputer
MSP430 C language keyword expansion
1.interrupt is used for interrupt function. The definition is as follows: Syntax: interrupt void function name() or interrupt void function name() Parameters: The interrupt function has no parameters. The interrupt function needs to specify the interrupt vector. Return: The interrupt function is generally
[Microcontroller]
Design of Intelligent Digital Voltage Meter Based on MSP430 Single Chip Microcomputer
  Voltage measurement is very common in current electronic technology, and the accuracy and functional requirements for instruments are becoming increasingly higher. Especially when the strength of the measured signal differs greatly, it is necessary to ensure the measurement accuracy of the weak signal while taking i
[Microcontroller]
Design of Intelligent Digital Voltage Meter Based on MSP430 Single Chip Microcomputer
An AC frequency detection system based on MSP430 single chip microcomputer
1 Introduction Since frequency signals have the advantages of strong anti-interference, easy transmission, and high measurement accuracy, many non-frequency sensor signals are converted into frequency quantities for measurement and processing. Therefore, frequency measurement methods are attractin
[Microcontroller]
An AC frequency detection system based on MSP430 single chip microcomputer
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号