s3c2440 serial port debugging function

Publisher:琴弦悠扬Latest update time:2016-05-03 Source: eefocusKeywords:s3c2440 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

 

  1. #include "2440addr.h"  
  2. #include   
  3. #include   
  4. #include   
  5. #include   
  6. #include   
  7. #define TXD0READY   (1<<2)  
  8. #define RXD0READY   (1)  
  9.  
  10. #define UART_CLK 50000000 // Set the clock source of UART0 to PCLK  
  11. #define UART_BAUD_RATE 115200 // baud rate  
  12. #define UART_BRD        ((UART_CLK  / (UART_BAUD_RATE * 16)) - 1)  
  13. /* 
  14.  * Initialize UART0 
  15.  * 115200,8N1,no flow control 
  16.  */  
  17. void Uart0_Init(void)  
  18. {  
  19.     rGPHCON |= 0xa0; // GPH2, GPH3 are used as TXD0, RXD0  
  20.     rGPHUP = 0x0c; // GPH2, GPH3 internal pull-up  
  21.     rULCON0 = 0x03; // 8N1 (8 data bits, no parity, 1 stop bit)  
  22.     rUCON0 = 0x05; // Query mode, UART clock source is PCLK  
  23.     rUFCON0 = 0x00; // Do not use FIFO  
  24.     rUMCON0 = 0x00; // Do not use flow control  
  25.     rUBRDIV0 = UART_BRD; // baud rate is 115200  
  26. }  
  27. /* 
  28.  * Send a character 
  29.  */  
  30. void Send_Byte(unsigned char c)  
  31. {  
  32.     /* Wait until all data in the send buffer has been sent out */  
  33.     while (!(rUTRSTAT0 & TXD0READY));  
  34.       
  35.     /* Write data to the UTXH0 register and the UART will automatically send it out */  
  36.     rUTXH0 = c;  
  37. }  
  38. /* 
  39.  * Receive characters 
  40.  */  
  41. unsigned char Get_Byte(void)  
  42. {  
  43.     /* Wait until there is data in the receive buffer */  
  44.     while (!(rUTRSTAT0 & RXD0READY));  
  45.       
  46.     /* Directly read the URXH0 register to obtain the received data */  
  47.     return rURXH0;  
  48. }  
  49. /* 
  50.  * Determine whether a character is a number 
  51.  */  
  52. int isDigit(unsigned char c)  
  53. {  
  54.     if (c >= '0' && c <= '9')  
  55.         return 1;  
  56.     else  
  57.         return 0;         
  58. }  
  59. /* 
  60.  * Determine whether a character is an English letter 
  61.  */  
  62. int isLetter(unsigned char c)  
  63. {  
  64.     if (c >= 'a' && c <= 'z')  
  65.         return 1;  
  66.     else if (c >= 'A' && c <= 'Z')  
  67.         return 1;         
  68.     else  
  69.         return 0;  
  70. }  
  71. void Uart0_SendString(char *pt)  
  72. {  
  73.     while(*pt)  
  74.     {  
  75.         Send_Byte(*pt++);  
  76.     }  
  77. }  
  78.   
  79. void Uart_Printf(char *fmt,...)  
  80. {  
  81.     va_list ap;  
  82.     char string[256];  
  83.     va_start(ap,fmt);  
  84.     vsprintf(string,fmt,ap);  
  85.     Uart0_SendString(string);  
  86.     va_end(ap);  
  87. }   

Keywords:s3c2440 Reference address:s3c2440 serial port debugging function

Previous article:Remap of STM32
Next article:NANDFlashd reading and writing (based on s3c2440)

Recommended ReadingLatest update time:2024-11-16 23:34

Design of embedded image information acquisition and transmission system
1. Introduction Home security has been a problem that has troubled people for a long time. The rise of "smart home" can be said to not only solve this problem, but also improve people's quality of life. However, its high cost is unaffordable for most people. This paper proposes a simple, low-cost dedicated home secu
[Microcontroller]
Design of embedded image information acquisition and transmission system
U-boot porting on mini2440-S3C2440 (3) - Phase 1: Exploring the boot code
1. This article takes the mini2440 development board as an example: u-boot is a two-stage Bootloader. The first stage files are CPU/arm920t/start.S and board/mini2440/lowlevel_init.S. The former is platform-related and the latter is development board-related. U-boot first stage code: 1. Hardware device initialization
[Microcontroller]
S3C2440 clock frequency
System clock Before the clock of MINI2440 development board is turned on, the whole development board relies on a 12MHz crystal oscillator to provide frequency to run, that is to say, CPU, memory, UART and other hardware that need clock frequency all work at 12MHz, while S3C2440A can work normally at 400MHz. Th
[Microcontroller]
S3C2440 clock frequency
S3C2440 timer configuration
The relevant registers for timer configuration are as follows (listed in the order of the s3c2440 manual) 1. TCFG0: Timer Configuration Register 0 Function: Define the dead zone length of the device and set the pre-calibrator value Description: Bits set the pre-calibrator value for timers 0 and 1, an
[Microcontroller]
Linux 2.6.32 porting to arm9 (s3c2440) platform 2 -- Kconfig and Makefile
I followed countless posts and documents on Ubuntu and spent a lot of time to set up the Qt environment and Eclipse, only to find in the end that these were irrelevant things. The first thing to do was to port Linux to the ARM core board. I fiddled with the porting for a long time and was confused by the complex tre
[Microcontroller]
Description of the address change of s3c2440_write_addr_lp function in S3C2440NAND operation
Source Program static void s3c2440_write_addr_lp(unsigned int addr) { int i; volatile unsigned char *p = (volatile unsigned char *)&s3c2440nand- NFADDR; int col, page;   col = addr & NAND_BLOCK_MASK_LP; page = addr / NAND_SECTOR_SIZE_LP; *p = col & 0xff; /* Column Address A0~A7 */ for(i=0; i 10; i++); *p
[Microcontroller]
Description of the address change of s3c2440_write_addr_lp function in S3C2440NAND operation
The startup process of the arm chip using s3c2440 as an example
The startup process of arm embedded chips is actually very complicated for embedded novices. Many people have only a little understanding of it and there are many misunderstandings. In the author's opinion, if you want to truly understand this startup process, you must first understand the differences and connections
[Microcontroller]
The startup process of the arm chip using s3c2440 as an example
Design and implementation of terminal LCD driver circuit based on S3C2440A
introduction Most of the portable handheld terminal products now, such as mobile phones, navigation systems, etc., have a small LCD display, which makes the design of LCD drive circuit an important part of handheld terminal design. This article takes handheld terminals used in special industries as an exam
[Microcontroller]
Design and implementation of terminal LCD driver circuit based on S3C2440A
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号