and com4 use interrupt 3.Chapter 3 registers1 register groupThe register group of COM port is shown in the following table. There are 12 registers and 8 addresses are used. Some registers share one address, which is distinguished by dlab = 0/1. Dlab is the 7th-bit line control register.Base AddressRead/writeRegister abbreviationDescription0Write-Sending holding register (
Frequency lock register (urdlm and urdll)
Urrbr, urthr, and urdll share the same address.When the dlab bit of the urlcr register is 1All accesses to the shared address are urdll; when the dlab bit of the urlcr register is 0, the read operation on the shared address will access urrbr (receiver er buffer register), and the write operation on the shared address will access urthr (transmitter holding registe
program of BF533:
Void uartinit (unsigned short Div)
{
* Puart_gctl = 0x0009; ---- (1)
* Puart_lcr = 0x0080; ---- (2)
* Puart_dll = div; ---- (3)
* Puart_dlh = div> 8; ---- (4)
* Puart_lcr = 0x0003; ---- (5)
* Puart_ier = 0x0001; ---- (6)
}
Through the previous study of various registers on the serial port, we can easily understand the role of each statement. The role of sentence 1st is to enable serial clock, and when the serial port is idle, the serial line is pulled up; the sentence 2nd mean
FIFO is not triggered and exceeds the delay time, half of the delay time is 4-5 times of the sending time, a timeout interruption occurs, in this case, the incomplete data in the FIFO can be read. Note: If the FIFO trigger point is set to 8 characters and the current FIFO contains 4 characters, sending is suspended, and timeout interruption occurs, this will occur and one character will be read after each interruption, wait for the remaining characters in the FIFO, interrupt again, and so on.
3
If Keil arm is used, vpbdiv = 0x00000000 is automatically generated in startup. S, which leads to fpclk dividing by 4. The baud rate is reduced by four times. The default value of startup. s in Keil is as follows .; // ; // ; // ; // ; // ; // ; // ; // ; // ; // ; // Vpbdiv_setup equ 0vpbdiv_val equ 0x00000000 we will change it:
Vpbdiv_setup equ 1
Vpbdiv_val equ 0x00000001
Solve the problem.
# Include
# Include "config. H"
# Define uart_baud (baud) (unsigned INT) (fosc * pll_m)/(baud
Contact Us
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.