If you use Keil ARM, the default value of VPBDIV=0X00000000 in the automatically generated Startup.s will result in Fpclk being divided by 4, which will cause the baud rate to drop by four times. The following are the default values set in Startup.s in Keil. ;//
;// Peripheral Bus Clock Rate
;//
;// <0=> VPB Clock = CPU Clock / 4
;// <1=> VPB Clock = CPU Clock
;// <2=> VPB Clock = CPU Clock / 2
;//
;// <0=> XCLK Pin
= CPU Clock / 4;// < 1=> XCLK
Pin = CPU Clock;// <2=>
VPBDIV_SETUP EQU 1
VPBDIV_Val EQU 0x00000001
problem solved.
#include
#include "Config.H"
#define UART_BAUD(baud) (unsigned int)((FOSC*PLL_M) / (baud * 16))
void Init_Uart0(unsigned int Baud)
{
/* initialize the serial interface */
PINSEL0 = 0x00000005; /* Enable RxD0 and TxD0 */
U0LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit */
U0DLM=(unsigned char)(Baud>>8);
U0DLL = (unsigned char)Baud;
U0LCR = 0x03; /* DLAB = 0 */
}
void delay (unsigned int i) { /* Delay function */
unsigned int n;
while(i>1)
{
for(n=65535;n>1;n--);
i--;
}
}
void Sent_Byte(unsigned char data)
{
U0THR = data; // Send data
while( (U0LSR&0x40)==0 ); // Wait for data to be sent
}
void Sent_Str(unsigned char const *str)
{ while(1)
{ if( *str == '/0' ) break;
Sent_Byte(*str++); // Send data
}
}
void main(void)
{
Init_Uart0(UART_BAUD(115200));
for(;;)
{
Sent_Str("www.dnp.cn /n");
delay(200);
}
}
Previous article:Introduction to LPC2131 UART usage
Next article:CRC check is used in STM32 and C#
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- Why is the GaN device [G-level is negative voltage powered]
- Signal Integrity and Power Integrity Analysis (3rd Edition)
- Share the FAQ about STM32/8
- MCU Model Challenge 1: Guess the manufacturer and model based on the MCU's power pins.
- 【i.MX6ULL】Driver Development 9——Linux IO Model Analysis
- What is the selection method and calculation process of ESD tube? Which forum friend can write out the calculation steps?
- Five Experiences in RF Circuit Design
- What is a combined hydraulic cylinder?
- [MYX-1028X] (V) Serial communication Demo
- Anxinke NB-IoT module review - some speculation about the failure of CH340