S3C2440 UART operation (FIFO interrupt mode)

Publisher:Joyful444LifeLatest update time:2016-04-20 Source: eefocusKeywords:S3C2440 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
Knowledge about serial port
 
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  the threshold of the Rx FIFO, the Rx interrupt is generated.
 
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   = 0x7ff;   //No pull-up resistor
//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;
 }
 //Initialize interrupt
void int_init(void)
{
rINTMOD=0x0; //Interrupt mode register
   pISR_UART0 = (int)Uart0; //Set interrupt service function address
   rINTSUBMSK = ~(0x3);    //Open UART0 send and receive interrupt mask
rINTMSK = ~(0x1<<28);   //Open UART0 interrupt mask
//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)   //Receive interrupt
{
rINTSUBMSK |= BIT_SUB_RXD0;  
while((rUFSTAT0&0x1f)>0)) 

           *ps++ = rURXH0;  
       }  
       data_is_ready = 1;        
       rSUBSRCPND = BIT_SUB_RXD0;  
}
//Send interrupt
else if(rSUBSRCPND & BIT_SUB_TXD0) 
{
rINTSUBMSK |= BIT_SUB_TXD0;    
          
       while(( !(rUFSTAT0&(1<<14))) && (*ps != '\r'))  
       {  
           rUTXH0 = *ps++;          
           for(i=0; i<100;i++);  
       }     
          
  
       data_is_ready = 0;  
  
       rSUBSRCPND = BIT_SUB_TXD0;  
   
   rSRCPND = BIT_UART0;  
   rINTPND = BIT_UART0;  
   if(data_is_ready)  
       rINTSUBMSK &= ~(BIT_SUB_TXD0);     
   else  
       rINTSUBMSK &= ~(BIT_SUB_RXD0); 
       //rINTSUBMSK &= ~(BIT_SUB_TXD0);
}
 
After testing, the function can be completed.

 


Keywords:S3C2440 Reference address:S3C2440 UART operation (FIFO interrupt mode)

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

In-depth analysis of the big-endian and small-endian issues in the S3C2440 startup code
1. The settings of big and small end in ADS1.2 and their impact on compiled code The following is a piece of code compiled in line segment mode, and the contents of the generated binary file Compile in big-endian mode to generate binary file contents From the above content, we can see that their byte or
[Microcontroller]
In-depth analysis of the big-endian and small-endian issues in the S3C2440 startup code
s3c2440 bare metal-memory controller (3-1, NorFlash principle of norflash programming)
1.Flash types and characteristics: Flash is generally divided into nand flash and nor flash. Their respective characteristics are as follows: - Nor NAND XIP (execution on chip) yes no Performance (erase) Very slow (5s, blocks too big) Fast(3ms) Performance (write) slow quick Performance (read) quick quick reli
[Microcontroller]
s3c2440 bare metal-memory controller (3-1, NorFlash principle of norflash programming)
S3C2440 cpu initialization (reset content)
reset content (start.S file): 1. Set svc mode Set the processor mode to svc mode. According to the ARM architecture reference manual, the processor has seven working modes: In the program status register, the mode is set to 10011: The assembly code is as follows: set_svc: mrs r0, cpsr bic r0, r0, #0x1f orr r0, r0
[Microcontroller]
S3C2440 cpu initialization (reset content)
S3C2440 external interrupt response register setting method
If the following settings are not followed, the interrupt will not be executed or the next interrupt will not be entered. /*Interrupt suspension setting, this process is added to the main function and loaded at startup*/ void Eint_wait() {    rSRCPND=rSRCPND; //Interrupt pending register clear    rINTPND=rINTPND; //In
[Microcontroller]
s3c2440_LCD controller settings and code details
1. Hardware requirements for LCD operation:    To make an LCD display text or image normally, it needs not only LCD driver but also corresponding LCD controller. Usually, the manufacturer will make LCD driver together with LCD glass substrate in the form of COF/COG, while LCD controller is realized by external circuit
[Microcontroller]
s3c2440_LCD controller settings and code details
Design of GPC controller based on Linux and s3C2440
In recent years, Internet-based network control systems have become a hot topic in the field of measurement and control at home and abroad, and have broad application prospects in the fields of oil exploration and development, steel and chemical industry, etc. The design and development of the controller is the key and
[Industrial Control]
Design of GPC controller based on Linux and s3C2440
Design of digital voltage-stabilized power supply for test system based on S3C2440
  0 Preface   DC regulated power supply is a relatively common electronic device, which has been widely used in many fields such as electronic circuits, experimental teaching, scientific research, etc. In recent years, embedded technology has developed extremely rapidly, and highly integrated processors with single-ch
[Microcontroller]
Design of digital voltage-stabilized power supply for test system based on S3C2440
04-S3C2440u-boot learning u-boot analysis (3) source code stage 1 and 2
Refer to "Wei Dongshan 1st Video" Lesson 09 Section 3 u-boot analysis source code stage 1.WMV 1. Phase 1 (1) Open u-boot-1.1.6_JZ2440cpuarm920tstart.S _start: b reset (jump to reset): 1. Set SVC32 mode; reset: /* * set the cpu to SVC32 mode */ mrs r0,cpsr bic r0,r0,#0x1f orr r0,r0,#0xd3 msr c
[Microcontroller]
04-S3C2440u-boot learning u-boot analysis (3) source code stage 1 and 2
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号