To ensure that S3C6410 has been initialized, usually use UBOOT initialization
//Serial port register
//UART0
#defineULCON0 *((vu32*)0x7F005000) //UART channel 0 line control register
#defineUCON0 *((vu32*)0x7F005004) //UART channel 0 control register
#defineUFCON0 *((vu32*)0x7F005008) //UART channel 0 FIFO control register
#defineUMCON0 *((vu32*)0x7F00500C) //UART channel 0 modem control register
#defineUTRSTAT0 *((vu32*)0x7F005010) //UART channel 0 send/receive status register
#defineUERSTAT0 *((vu32*)0x7F005014) //UART channel 0 receive error status register
#defineUFSTAT0 *((vu32*)0x7F005018) //UART channel 0 FIFO status register
#defineUMSTAT0 *((vu32*)0x7F00501C) //UART channel 0 modem status register
#defineUTXH0 *((vu32*)0x7F005020) //UART channel 0 send buffer register
#defineURXH0 *((vu32*)0x7F005024) //UART channel 0 receive buffer register
#defineUBRDIV0 *((vu32*)0x7F005028) //Channel 0 baud rate divider register
#defineUDIVSLOT0 *((vu32*)0x7F00502C) //UART channel 0 frequency division slot register
#defineUINTP0 *((vu32*)0x7F005030) //Channel 0 interrupt processing register
#defineUINTSP0 *((vu32*)0x7F005034) //UART channel 0 interrupt source processing register
#defineUINTM0 *((vu32*)0x7F005038) //UART channel 0 interrupt mask register
//Author: Chen
//Creation time: 20120220
//Last modified time: 20120220
//Description: S3C6410 serial port related
#include "system.h"
#include "uart.h"
#include "s3c6410_map.h"
///////////////////////////////////////////////////// /////////////////
//Add the following code to support the printf function,
#if 1
#include "stdio.h"
//Support functions required by the standard library
struct __FILE
{
inthandle;
};
/* FILE is typedef'd in stdio.h. */
FILE __stdout;
// define _sys_exit() to avoid using semihost mode
_sys_exit(int x)
{
x= x;
}
//Redefine fputc function
int fputc(int ch,FILE *f)
{
Uart0_SendByte((u8)ch);
returnch;
}
#endif
static const u16UART_SPEED[13][2] ={{1717,0x4924},{858,0x4924},{428,0x4924},{285,0x4924},{213,0x4924},{142,0x4924},{106, 0x4924},{72,0x4924},{70,0x4924},{34,0x4924},{16,0x4924},{7,0x4924},{3,0x4924}};
/****************************************************** *************************************************** ************************
*Function: voidUart0_Init(void)
*Function: Serial port 0 initialization
*Parameters: None
*Return: None
*Depends on: underlying macro definitions
*Author : Chen
*Time: 20120220
* Last modified: 20120220
*Description: Initialize serial port 0
*************************************************** *************************************************** *********************/
void Uart0_Init(u8UART_Speed)
{
PCLK_GATE|= 1 << 1; //UART0 gates PCLK clock, 66mhz
GPIOA->CON&=~(0xff); //Clear previous settings, GPIOA0, GPIOA1
GPIOA->CON|= (HOST | (HOST <<4)); //Set GPIOA0, GPIOA1 to uart mode
ULCON0=0x3; //8 bits per frame //Clear settings//Normal mode, no parity, 1 stop bit
UCON0= (0x1 << 2) | 0x1 | (2 <<10); // Clear control register // Set (PCLK=66MHz) as baud rate clock
UFCON0=0; //Disable FIFO
UMCON0=0; //Disable AFC, nRTS high level is invalid
UBRDIV0 =UART_SPEED[UART_Speed][0]; //Set the integer part of the baud rate
UDIVSLOT0= UART_SPEED[UART_Speed][1]; //Set the decimal part of the baud rate
UINTP0= 0; //Disable UART0 interrupt
UINTSP0= 0; //Set interrupt source
UINTM0= 0; //Disable interrupt mask\
}
/****************************************************** *************************************************** ************************
*Function: voidUart0_SendByte(u8 data)
*Function: Serial port 0 sends a byte
*Parameter: data to be sent
*Return: None
*Depends on: underlying macro definitions
*Author : Chen
*Time: 20120220
* Last modified: 20120220
*Description: Use serial port 0 to send a byte
*************************************************** *************************************************** *********************/
voidUart0_SendByte(u8 data)
{
while(!(UTRSTAT0& (1 <<2))); //Wait for the send buffer to be empty
UTXH0= data; //Write data into the transmit buffer
Now
you can use printf directly to send data to the serial port.
Previous article:Temporarily solve the problem that S3C6410 cannot perform bare metal floating point operations
Next article:The difference between main() and __main() in ARM
Recommended ReadingLatest update time:2024-11-16 15:00
- Popular Resources
- Popular amplifiers
- MCU C language programming and Proteus simulation technology (Xu Aijun)
- Internet of Things Development Technology Based on C Language (Edited by Gao Song)
- ARM Embedded System Principles and Applications (Wang Xiaofeng)
- ARM Cortex-M4+Wi-Fi MCU Application Guide (Embedded Technology and Application Series) (Guo Shujun)
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
- Design an electronic meter that can measure 0-1.5A current and automatically switch ranges
- Analysis of embedded C language pointers
- What does 0402_SHORT mean in the schematic diagram and how to draw the PCB
- CB140 core board voltage value difference solution
- RJ45 selection for POE powered device PD
- How are the results of CST PCB simulation displayed?
- Arrow Live: Focus on "TI FPD-Link III Automotive Chipset", the ideal solution for automotive video transmission
- Application of “C2000+TMS570” dual-chip solution in automotive electric drive functional safety
- A complete list of filter circuits, save it for future use!
- Automatic License Plate Recognition System Based on ARM Cortex