ARM serial port basic operation function test (based on LPC2134)

Publisher:恬淡岁月Latest update time:2016-05-03 Source: eefocusKeywords:ARM Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

 

  1. /**************************************************************************** 
  2. # * File name: UART0.h 
  3. # * Function: declare related global functions about UART0 
  4. # * Version: 1.0 
  5. # * Author: jianqi2010 
  6. # ****************************************************************************/  
  7. void UART_Init(void);  
  8.   
  9. void UART_Send_Byte(char ch);  
  10.   
  11. void UART_Send_String(char* p);  
  12.   
  13.   
  14. /**************************************************************************** 
  15. # * File name: UART0.c 
  16. # * Function: define global functions related to UART0 
  17. # * Version: 1.0 
  18. # * Author: jianqi2010 
  19. # ****************************************************************************/  
  20. #include"UART0.h"  
  21. #include"config.h"  
  22. #define BAUD 9600 //Baud rate  
  23.   
  24. void UART_Init(void)  
  25. {  
  26. uint16 Fdiv;  
  27. U0LCR = 0x83; // related check bit, data length, etc., DLAB = 1, baud rate can be set  
  28. Fdiv=(Fpclk/16)/BAUD;  
  29. U0DLM=Fdiv/256;  
  30. U0DLL=Fdiv%256;  
  31. U0LCR=0X03;  
  32. }  
  33.   
  34. /**************************************************************************** 
  35. # * Name: UART_Send_Char 
  36. # * Function: UART0 sends byte function 
  37. # * Entry parameters: bytes waiting to be sent 
  38. # * Export parameters: None 
  39. # ****************************************************************************/  
  40. void UART_Send_Byte(char ch)  
  41. {  
  42. U0THR = ch;  
  43. while((U0LSR&0x40)==0); //Wait for data to be sent  
  44. }  
  45.   
  46. /**************************************************************************** 
  47. # * Name: UART_Send_String 
  48. # * Function: UART0 sends string function 
  49. # * Entry parameter: string to be sent 
  50. # * Export parameters: None 
  51. # ****************************************************************************/  
  52. void UART_Send_String(char* p)  
  53. {  
  54. while (*p!='/0')  
  55. {  
  56. UART_Send_Byte(*p++);  
  57. }  
  58. }  
  59.   
  60.   
  61. /**************************************************************************** 
  62. # * File name: main.c 
  63. # * Function: Test the sending program of UART0 
  64. # * Version: 1.0 
  65. # * Author: jianqi2010 
  66. # ****************************************************************************/  
  67. #include"config.h"  
  68. #include"UART0.h"  
  69.   
  70. //Test function  
  71. int main(void)  
  72. {  
  73. BRUSH0=0X05;  
  74. IO0DIR = 0x01;  
  75. UART_Init();  
  76. UART_Send_String("HellowWord");  
  77. return 0;  
  78. }  

 

 

Keywords:ARM Reference address:ARM serial port basic operation function test (based on LPC2134)

Previous article:Using ARM external interrupt to control the flashing speed of the water lamp (based on LPC2134)
Next article:Let 2440 output driver debugging information

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号