3 independent serial ports, each of which can be
operated using DMA and interrupt modes. Each contains 2 64-byte FIFOs, one for receiving and one for transmitting.
Non-FIFO mode is equivalent to a register buffer mode of FIFO mode.
Each UART has 7 states, overrun error, check error, frame error, breakpoint, receive buffer ready, transmit buffer empty, transmit shift register empty.
When the data in the receive shift register is transferred to the FIFO, and the received data triggers
When the data in the transmitter FIFO that has not yet been sent reaches the Tx FIFO threshold, the Tx interrupt is generated. (I think it should be understood as: the interrupt is generated when the FIFO in the transmitter is empty after the transmission is completed.)
Function: Enter 16 bytes on the serial port, including carriage return, and then the input characters will be echoed on the serial terminal.
Program code:
//Function declaration
void Uart_init(void);
void int_init(void);
void __irq Uart0(void);
void Main(void);
//Cache
static unsigned char mywords[100] = {0,0};
static int data_is_ready = 0;
//Initialize uart
void Uart_init(void)
{
//Initialize pin
rGPHCON = 0x00faaa; //Set the pin to TXD0 and RXD0 mode
rGPHUP
//Initialize UART
rULCON0 = 0x03; //Send 8 bits of data each time, one stop bit, no check, normal mode
rUCON0 = (0x05) | (1<<9); //Set reception and transmission to interrupt mode
rUFCON0 = (0x3<<6) | (0x2<<4) | (0x01<<0); //Enable FIFO, send 48 bytes, receive 16 bytes
rUMCON0 = 0;
//Set clock frequency
rUBRDIV0 = 26;
void int_init(void)
{
rINTMOD=0x0; //Interrupt mode register
rINTMSK = ~(0x1<<28);
//rSUBSRCPND=(BIT_SUB_TXD0);
}
void Main(void)
{
MMU_Init();
int_init();
Uart_init();
while(1);
}
//Interrupt handling function
void __irq Uart0(void)
{
unsigned char *ps = mywords;
int i;
if(rSUBSRCPND & BIT_SUB_RXD0)
{
rINTSUBMSK |= BIT_SUB_RXD0;
while((rUFSTAT0&0x1f)>0))
{
}
//Send interrupt
else if(rSUBSRCPND & BIT_SUB_TXD0)
{
rINTSUBMSK |= BIT_SUB_TXD0;
}
After testing, the function can be completed.
Previous article:Why do arm instructions perform better than thumb instructions?
Next article:Conversion between ARM ADS assembly and Gnu assembly
Recommended ReadingLatest update time:2024-11-16 14:35
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- From ERM to X-axis LRA, TI provides you with a comprehensive Haptics Solution
- 【TI mmWave Radar Evaluation】+Configuration File Test (Part 2)
- TI Live: Overview and application introduction of 60G millimeter wave sensors, "packaged antenna" makes building and factory detection solutions simpler
- First day of the journey in Shenzhen
- Ethernet Problems
- MicroPython precompiled firmware for TB-01 (W600)
- Is it necessary to attend Altium's offline training?
- How to prevent audio equipment from aging and make the sound better
- Discussion on BQ35100 Li-ion Battery Capacity Monitoring
- Evaluation: STM32F769I-DISCO connected to Gizwits Cloud to realize IoT development remote control and other functions