- AREA uart0_test, CODE, READONLY
- ENTRY
- PINSEL0 EQU 0xE002C000
- VICIntSelect EQU 0xFFFFF00C
- VICIntEnable EQU 0xFFFFF010
- VICVectAddr EQU 0xFFFFF030
- VICVectAddr0 EQU 0xFFFFF100
- VICVectCntl0 EQU 0xFFFFF200
- U0RBR EQU 0xE000C000
- U0THR EQU 0xE000C000
- U0DLL EQU 0xE000C000
- U0DLM EQU 0xE000C004
- U0IER EQU 0xE000C004
- U0IIR EQU 0xE000C008
- U0FCR EQU 0xE000C008
- U0LCR EQU 0xE000C00C
- U0LSR EQU 0xE000C014
- Vectors LDR PC, Reset_Addr
- LDR PC, Undef_Addr
- LDR PC, SWI_Addr
- LDR PC, PAbt_Addr
- LDR PC, DAbt_Addr
- NOP ; Reserved Vector
- LDR PC, IRQ_Addr
- ; LDR PC, [PC, #-0x0FF0] ; Vector from VicVectAddr
- LDR PC, FIQ_Addr
- Reset_Addr DCD Reset_Handler
- Undef_Addr DCD Undef_Handler
- SWI_Addr DCD SWI_Handler
- PAbt_Addr DCD PAbt_Handler
- DAbt_Addr DCD DAbt_Handler
- DCD 0 ; Reserved Address
- IRQ_Addr DCD IRQ_Handler
- FIQ_Addr DCD FIQ_Handler
- Reset_Handler B start
- Undef_Handler B Undef_Handler
- SWI_Handler B SWI_Handler
- PAbt_Handler B PAbt_Handler
- DAbt_Handler B DAbt_Handler
- IRQ_Handler B IRQ_Handler
- FIQ_Handler B FIQ_Handler
- start
- LDR R0,=PINSEL0 ;设置P0.0和P0.1为UART0
- LDR R1,[R0]
- BIC R1,#0x0F
- ORR R1,R1,#0x05
- STR R1,[R0]
- LDR R0,=U0LCR ;设置UART0工作模式,并使能访问除数锁存器
- MOV R1,#0x83
- STR R1,[R0]
- LDR R0,=U0DLL ;设置UART0波特率
- MOV R1,#0x01
- STR R1,[R0]
- LDR R0,=U0LCR ;禁止访问除数锁存器
- MOV R1,#0x03
- STR R1,[R0]
- LDR R0,=U0IER ;允许UART0接收中断
- MOV R1,#0x01
- STR R1,[R0]
- LDR R0,=U0FCR ;使能FIFO功能,并设置RX触发为8字节
- MOV R1,#0x81
- STR R1,[R0]
- MRS R0,CPSR ;使能IRQ中断
- BIC R0,#0x80
- MSR CPSR_c,R0
- LDR R0,=VICIntSelect
- MOV R1,#0x00
- STR R1,[R0]
- LDR R0,=VICVectCntl0
- MOV R1,#0x26
- STR R1,[R0]
- LDR R0,=VICVectAddr0
- LDR R1,=IRQ_Handler
- STR R1,[R0]
- LDR R0,=VICIntEnable
- MOV R1,#0x40
- STR R1,[R0]
- loop B loop
- END