UART function test of s3c2440

Publisher:温柔花香Latest update time:2024-06-06 Source: elecfansKeywords:s3c2440  UART Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

/* File name: UART.c
/* Function: The most basic UART sending and receiving
/* Author: Wujianqi
/* Version: 1.0
#include "2440addr.h" //Includes the settings of 2440 related registers
#include "def.h"
//The four LEDs correspond to GPB5.6.7.8.
#define LED1 5
#define LED2 6
#define LED3 7
#define LED4 8
#define BAUD 115200 //Baud rate
#define Bit(x) (1《x) //Set a bit
#define Output(x) (1《2*x) //Set the corresponding IO as output
#define LED_On(x) rGPBDAT=~Bit(x) //Turn on the corresponding LED
* Name: Clk_Set
* Function: About initialization of system clock
* Input parameter: None
* Output parameter: None
void Clk_Set(void)
{
int count;
rUPLLCON=(56《12)|(2《4)|2; //UCLK is 48MHZ
rMPLLCON=(92《12)|(1《4)|1; //FCLK is 400MHZ
rCLKDIVN=(0《3)|(2《1)|1;//HCLK is 100MHZ, PCLK is 50MHZ
rCAMDIVN=(0《9); //PCLK=HCLK/4
}
* Name: IO_init
* Function: Port initialization for LED
* Input parameters: None
* Output parameters: None
void IO_init(void)
{
rGPBCON=Output(LED1)|Output(LED2)|Output(LED3)|Output(LED4); //Set the IO port of LED to output
rGPBDAT=0xffff; //Turn off all LEDs
}
* Name: UART0_init
* Function: Initialization work related to UART0
* Input parameters: None
* Output parameters: None
void UART0_init(void)
{
rGPHCON=0xa0; //IO port enables UART0 function
rGPHUP=0xff; //Pull-up disabled
rULCON0=0x03; // 8-bit data, no parity, 1 stop bit
rUCON0=0x05; //pclk clock, interrupt request mode is Tx-level, Rx-pulse
rUBRDIV0=26; //Set baud rate
rUFCON0=0x00; //Do not use FIFO
rUMCON0=0x00; //Do not use flow control
}
* Name: Send_Byte
* Function: Send a character
* Input parameter: Waiting for the character to be sent
* Output parameter: None
void Send_Byte(char data)
{
while(!(rUTRSTAT0&0x2)); //Wait for the send buffer to be empty
rUTXH0=data;
}
* Name: Send_String
* Function: Send string
* Input parameter: Waiting for the string to be sent
* Output parameter: None
void Send_String(char* pt)
{
while(*pt)
{
Send_Byte(*pt++);
}
}
* Name: Uart_Getch
* Function: Receive a character
* Input parameter: None
* Output parameter: Received character
char Uart_Getch(void)
{
while(!(rUTRSTAT0&0x1)); //Wait for the receive buffer to have data
return (rURXH0); //Read out data
}
* Name: Main
* Function: Test UART sending and receiving functions
* Input parameter: None
* Output parameter: None
void Main(void)
{
char temp;
IO_init();
UART0_init();
Clk_Set();
Send_String("HelloWorld"); //Send string
while(1)
{
temp=Uart_Getch(); //Receive character
if(temp==0x01)
{
LED_On(LED1);
}
}
}

Keywords:s3c2440  UART Reference address:UART function test of s3c2440

Previous article:Analysis of RTC clock driver development example on S3C2440
Next article:S3C2440 clock settings

Recommended ReadingLatest update time:2024-11-16 09:35

S3C2440 chip clock (1)
The clock and power management module consists of three parts: clock control, USB control and power control. The clock control logic in S3C2440A can generate the necessary clock signals, including FCLK of CPU, HCLK of AHB bus peripherals and PCLK of APB bus peripherals. S3C2440A contains two phase-locked loops (PLL)
[Microcontroller]
S3C2440 chip clock (1)
S3C2440 bare metal -------SDRAM
1. Configure the memory controller registers When our S3C2440 accesses SDRAM, it first sends out an address, and then the memory controller first sends out a chip select signal nGCS6 according to the address range. Then, based on the type of the chip select signal, it is known that it is SDRAM, and then the address is
[Microcontroller]
S3C2440 bare metal -------SDRAM
s3c2440 code relocation and introduction of segments - apply what you have learned and practice comprehensive Makefile
For 2440, nand is started, and the first 4k content of nand is copied to sram by hardware. Nor flash can be read like memory, but cannot be written like memory. Special operations are required to perform write operations. The program contains global or static variables that need to be written. They are in the bin
[Microcontroller]
s3c2440 code relocation and introduction of segments - apply what you have learned and practice comprehensive Makefile
Learn 51 MCU-UART port sends a character
       The UART port, also known as the Universal Asynchronous Receiver/Transmitter, is part of the common functions of the microcontroller and is also a necessary hardware interface for early desktop computers.     When I debugged the UART port, I used the HyperTerminal. Now we use the Serial Port Assistant, which i
[Microcontroller]
Learn 51 MCU-UART port sends a character
The difference between S3C2440, S3C2450 and S3C6410
As the main solution processor provider for handheld devices such as GPS, PDA, and digital TV, South Korea's Sumsung Company has recently launched new ARM processor S3C2450 and S3C6410 chips. What are the differences and advantages between these platforms and the S3C2440 processor? S3C2440: Main frequency 400MHz; S
[Microcontroller]
06-S3C2440 Learning: Transplanting 2012u-boot to S3C2440 (Transplantation Process 3) Support NorFlash
In the previous section, we implemented support for nand flash boot (click to view), which does not mean that uboot can read and write nand at this time, but it can burn uboot to nand and relocate the code after powering on, thus implementing nand boot. In this section, we add support for nor, so that uboot can recogn
[Microcontroller]
06-S3C2440 Learning: Transplanting 2012u-boot to S3C2440 (Transplantation Process 3) Support NorFlash
s3c2440 bare metal-code relocation (2. Programming to implement code relocation)
1.Introduce link script We talked about why code should be relocated in the previous section, so how to relocate code? In the previous section, we found that the bin file compiled using "arm-linux-ld -Ttext 0 -Tdata 0x30000000" is more than 800 MB in size. This is definitely not possible. So how do we relocate the .
[Microcontroller]
s3c2440 bare metal-code relocation (2. Programming to implement code relocation)
S3C2440 ARM chip clock
1. Introduction to internal clock From the internal block diagram of S3C2440A, we can see that S3C2440A is mainly divided into three parts: ARM920T, AHB, and APB. Among them, FCLK is the working clock related to CPU, HCLK provides clock for high-speed bus devices, and PCLK provides clock for some low-spee
[Microcontroller]
S3C2440 ARM chip clock
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号