-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuart_print.s
85 lines (65 loc) · 1.64 KB
/
uart_print.s
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include "uart_regs.h"
.data
string:
.ascii "00"
.ascii ":"
.ascii "00"
.ascii ":"
.ascii "00"
.byte 0x0D
.byte 0x00
.text
.macro uart_print
bl uart_trans
.endm
uart_trans:
ldr r0, =UART1_BASE
ldr r1, =string
ldrb r2, [r1], #1 // hour 10'
ldrb r3, [r1], #1 // hour 1'
ldrb r4, [r1], #1 // ":"
ldrb r5, [r1], #1 // minute 10'
ldrb r6, [r1], #1 // minute 1'
ldrb r7, [r1], #1 // ":"
ldrb r8, [r1], #1 // second 10'
ldrb r9,[r1], #1 // second 1'
add r9, #1 // add 1 second
// second
cmp r9, #58
moveq r9, #48
addeq r8, #1
cmp r8, #54
moveq r8, #48
addeq r6, #1
// minute
cmp r6, #58
moveq r6, #48
addeq r5, #1
cmp r5, #54
moveq r5, #48
addeq r3, #1
cmp r3, #58
moveq r3, #48
addeq r2, #1 // increment hour number by 1
ldr r1, =string
strb r2, [r1], #1 // hour 10'
strb r3, [r1], #1 // hour 1'
strb r4, [r1], #1 // :
strb r5, [r1], #1 // minute 10'
strb r6, [r1], #1 // minute 1'
strb r7, [r1], #1 // :
strb r8, [r1], #1 // second 10'
strb r9, [r1], #1 // second 1'
ldr r1, =string
TRANSMIT_loop:
// --------- Check to see if the Tx FIFO is empty ------------------------------
ldr r2, [r0, #0x2C] // get Channel Status Register
and r2, r2, #0x8 // get Transmit Buffer Empty bit(bit[3:3])
cmp r2, #0x8 // check if TxFIFO is empty and ready to receive new data
bne TRANSMIT_loop // if TxFIFO is NOT empty, keep checking until it is empty
//------------------------------------------------------------------------------
ldrb r3, [r1], #1
streqb r3, [r0, #0x30] // fill the TxFIFO with 0x48
cmp r3, #0x00
bne TRANSMIT_loop
mov pc, lr // return to the caller