Вывод блока памяти данных » History » Version 10
krufter_multiclet, 07/19/2013 04:12 PM
1 | 1 | krufter_multiclet | h1. Вывод блока памяти данных |
---|---|---|---|
2 | 1 | krufter_multiclet | |
3 | 10 | krufter_multiclet | 1) [[С выравниванием по байту]] |
4 | 10 | krufter_multiclet | |
5 | 10 | krufter_multiclet | 2) [[С выравниванием по 8 байт]] |
6 | 10 | krufter_multiclet | |
7 | 7 | krufter_multiclet | +Для платы HW1-MCp04:+ |
8 | 2 | krufter_multiclet | |
9 | 2 | krufter_multiclet | <pre> |
10 | 8 | krufter_multiclet | .include "HDL50001_pcf.inc" |
11 | 8 | krufter_multiclet | |
12 | 2 | krufter_multiclet | .alias DM_START 0x00000000 ;start address DM for output by uart0 |
13 | 2 | krufter_multiclet | .alias BLOCK_SIZE 0x00000100 ;end address DM for output by uart0 |
14 | 2 | krufter_multiclet | .alias iterator1 2 |
15 | 2 | krufter_multiclet | .alias iterator2 3 |
16 | 2 | krufter_multiclet | .alias iterator3 4 |
17 | 2 | krufter_multiclet | .alias byte_DM 5 |
18 | 2 | krufter_multiclet | |
19 | 2 | krufter_multiclet | .alias UART_DATA UART0_DATA |
20 | 2 | krufter_multiclet | .alias UART_BDR UART0_BDR |
21 | 2 | krufter_multiclet | .alias UART_ST UART0_ST |
22 | 2 | krufter_multiclet | .alias UART_CR UART0_CR |
23 | 2 | krufter_multiclet | |
24 | 2 | krufter_multiclet | .alias UART_PORT_PIN 0x300 |
25 | 2 | krufter_multiclet | .alias UART_PORT_BPS GPIOB_BPS |
26 | 2 | krufter_multiclet | |
27 | 2 | krufter_multiclet | .text |
28 | 2 | krufter_multiclet | |
29 | 3 | krufter_multiclet | ;config uart |
30 | 2 | krufter_multiclet | initUART: |
31 | 2 | krufter_multiclet | jmp read_DM |
32 | 2 | krufter_multiclet | getl 0x00000300 |
33 | 9 | krufter_multiclet | wrl @1, UART_PORT_BPS |
34 | 2 | krufter_multiclet | getl 0x00000104 |
35 | 2 | krufter_multiclet | wrl @1, UART_BDR |
36 | 2 | krufter_multiclet | getl 0x00000003 |
37 | 2 | krufter_multiclet | wrl @1, UART_CR |
38 | 2 | krufter_multiclet | setl #iterator1, 0x00000000 |
39 | 4 | krufter_multiclet | setl #iterator3, 4 ; send to uart fifo 32 bytes |
40 | 2 | krufter_multiclet | complete |
41 | 2 | krufter_multiclet | |
42 | 2 | krufter_multiclet | ; read DM for define address as double word (64 bits) |
43 | 2 | krufter_multiclet | read_DM: |
44 | 2 | krufter_multiclet | getl BLOCK_SIZE |
45 | 2 | krufter_multiclet | subl @1, #iterator1 |
46 | 2 | krufter_multiclet | je @1, stop2 |
47 | 2 | krufter_multiclet | jne @2, out_DM |
48 | 2 | krufter_multiclet | getl #iterator1 |
49 | 2 | krufter_multiclet | addl @1, DM_START |
50 | 2 | krufter_multiclet | rdq @1 |
51 | 2 | krufter_multiclet | setq #byte_DM, @1 |
52 | 2 | krufter_multiclet | addl @4, 0x00000008 |
53 | 2 | krufter_multiclet | setl #iterator1, @1 |
54 | 2 | krufter_multiclet | setl #iterator2, 0 |
55 | 2 | krufter_multiclet | getl #iterator3 |
56 | 2 | krufter_multiclet | subl @1, 1 |
57 | 2 | krufter_multiclet | setl #iterator3, @1 |
58 | 2 | krufter_multiclet | complete |
59 | 2 | krufter_multiclet | |
60 | 2 | krufter_multiclet | out_DM: |
61 | 2 | krufter_multiclet | getl #iterator2 |
62 | 2 | krufter_multiclet | getl 56 ; write to tx fifo 8 bytes |
63 | 2 | krufter_multiclet | subl @1, @2 |
64 | 2 | krufter_multiclet | je @1, full_FIFO |
65 | 2 | krufter_multiclet | jne @2, out_DM |
66 | 2 | krufter_multiclet | getq #byte_DM |
67 | 2 | krufter_multiclet | slrq @1, #iterator2 |
68 | 2 | krufter_multiclet | wrq @1, UART_DATA ; write to tx fifo only one byte |
69 | 2 | krufter_multiclet | getl 8 |
70 | 2 | krufter_multiclet | addl @1, #iterator2 |
71 | 2 | krufter_multiclet | setl #iterator2, @1 |
72 | 2 | krufter_multiclet | complete |
73 | 2 | krufter_multiclet | |
74 | 2 | krufter_multiclet | ; analyze iterator3 for sending all 4*8 bytes |
75 | 2 | krufter_multiclet | full_FIFO: |
76 | 2 | krufter_multiclet | getl #iterator3 |
77 | 2 | krufter_multiclet | getl 0xFFFFFFFF |
78 | 2 | krufter_multiclet | and @1, @2 |
79 | 2 | krufter_multiclet | je @1, buf_TXD |
80 | 2 | krufter_multiclet | jne @2, read_DM |
81 | 2 | krufter_multiclet | complete |
82 | 2 | krufter_multiclet | |
83 | 2 | krufter_multiclet | ; wait for fifo transmitter is empty |
84 | 2 | krufter_multiclet | buf_TXD: |
85 | 2 | krufter_multiclet | rdl UART_ST |
86 | 2 | krufter_multiclet | getl 0x00000004 |
87 | 2 | krufter_multiclet | and @1, @2 |
88 | 2 | krufter_multiclet | je @1, buf_TXD |
89 | 2 | krufter_multiclet | jne @2, read_DM |
90 | 2 | krufter_multiclet | setl #iterator3, 4 |
91 | 2 | krufter_multiclet | complete |
92 | 2 | krufter_multiclet | |
93 | 2 | krufter_multiclet | ; enable led 2,3 |
94 | 2 | krufter_multiclet | stop2: |
95 | 2 | krufter_multiclet | getl 0x1000 |
96 | 2 | krufter_multiclet | complete |
97 | 2 | krufter_multiclet | </pre> |
98 | 5 | krufter_multiclet | |
99 | 1 | krufter_multiclet | +Замечание:+ размер блока BLOCK_SIZE должен быть выравнен на 8. Скоро появится пример вывода по UART с точностью до байта. |
100 | 7 | krufter_multiclet | |
101 | 7 | krufter_multiclet | |
102 | 7 | krufter_multiclet | +Для платы LDM-MCp04:+ |
103 | 7 | krufter_multiclet | |
104 | 7 | krufter_multiclet | <pre> |
105 | 8 | krufter_multiclet | .include "HDL50001_pcf.inc" |
106 | 8 | krufter_multiclet | |
107 | 7 | krufter_multiclet | .alias DM_START 0x00000000 ;start address DM for output by uart0 |
108 | 7 | krufter_multiclet | .alias BLOCK_SIZE 0x00000100 ;end address DM for output by uart0 |
109 | 7 | krufter_multiclet | .alias iterator1 2 |
110 | 7 | krufter_multiclet | .alias iterator2 3 |
111 | 7 | krufter_multiclet | .alias iterator3 4 |
112 | 7 | krufter_multiclet | .alias byte_DM 5 |
113 | 7 | krufter_multiclet | |
114 | 7 | krufter_multiclet | .alias UART_DATA UART3_DATA |
115 | 7 | krufter_multiclet | .alias UART_BDR UART3_BDR |
116 | 7 | krufter_multiclet | .alias UART_ST UART3_ST |
117 | 7 | krufter_multiclet | .alias UART_CR UART3_CR |
118 | 7 | krufter_multiclet | |
119 | 7 | krufter_multiclet | .alias UART_PORT_PIN 0x300 |
120 | 7 | krufter_multiclet | .alias UART_PORT_BPS GPIOD_BPS |
121 | 7 | krufter_multiclet | |
122 | 7 | krufter_multiclet | .text |
123 | 7 | krufter_multiclet | |
124 | 7 | krufter_multiclet | ;config uart |
125 | 7 | krufter_multiclet | initUART: |
126 | 7 | krufter_multiclet | jmp read_DM |
127 | 7 | krufter_multiclet | getl 0x00000300 |
128 | 9 | krufter_multiclet | wrl @1, UART_PORT_BPS |
129 | 7 | krufter_multiclet | getl 0x00000104 |
130 | 7 | krufter_multiclet | wrl @1, UART_BDR |
131 | 7 | krufter_multiclet | getl 0x00000003 |
132 | 7 | krufter_multiclet | wrl @1, UART_CR |
133 | 7 | krufter_multiclet | setl #iterator1, 0x00000000 |
134 | 7 | krufter_multiclet | setl #iterator3, 4 ; send to uart fifo 32 bytes |
135 | 7 | krufter_multiclet | complete |
136 | 7 | krufter_multiclet | |
137 | 7 | krufter_multiclet | ; read DM for define address as double word (64 bits) |
138 | 7 | krufter_multiclet | read_DM: |
139 | 7 | krufter_multiclet | getl BLOCK_SIZE |
140 | 7 | krufter_multiclet | subl @1, #iterator1 |
141 | 7 | krufter_multiclet | je @1, stop2 |
142 | 7 | krufter_multiclet | jne @2, out_DM |
143 | 7 | krufter_multiclet | getl #iterator1 |
144 | 7 | krufter_multiclet | addl @1, DM_START |
145 | 7 | krufter_multiclet | rdq @1 |
146 | 7 | krufter_multiclet | setq #byte_DM, @1 |
147 | 7 | krufter_multiclet | addl @4, 0x00000008 |
148 | 7 | krufter_multiclet | setl #iterator1, @1 |
149 | 7 | krufter_multiclet | setl #iterator2, 0 |
150 | 7 | krufter_multiclet | getl #iterator3 |
151 | 7 | krufter_multiclet | subl @1, 1 |
152 | 7 | krufter_multiclet | setl #iterator3, @1 |
153 | 7 | krufter_multiclet | complete |
154 | 7 | krufter_multiclet | |
155 | 7 | krufter_multiclet | out_DM: |
156 | 7 | krufter_multiclet | getl #iterator2 |
157 | 7 | krufter_multiclet | getl 56 ; write to tx fifo 8 bytes |
158 | 7 | krufter_multiclet | subl @1, @2 |
159 | 7 | krufter_multiclet | je @1, full_FIFO |
160 | 7 | krufter_multiclet | jne @2, out_DM |
161 | 7 | krufter_multiclet | getq #byte_DM |
162 | 7 | krufter_multiclet | slrq @1, #iterator2 |
163 | 7 | krufter_multiclet | wrq @1, UART_DATA ; write to tx fifo only one byte |
164 | 7 | krufter_multiclet | getl 8 |
165 | 7 | krufter_multiclet | addl @1, #iterator2 |
166 | 7 | krufter_multiclet | setl #iterator2, @1 |
167 | 7 | krufter_multiclet | complete |
168 | 7 | krufter_multiclet | |
169 | 7 | krufter_multiclet | ; analyze iterator3 for sending all 4*8 bytes |
170 | 7 | krufter_multiclet | full_FIFO: |
171 | 7 | krufter_multiclet | getl #iterator3 |
172 | 7 | krufter_multiclet | getl 0xFFFFFFFF |
173 | 7 | krufter_multiclet | and @1, @2 |
174 | 7 | krufter_multiclet | je @1, buf_TXD |
175 | 7 | krufter_multiclet | jne @2, read_DM |
176 | 7 | krufter_multiclet | complete |
177 | 7 | krufter_multiclet | |
178 | 7 | krufter_multiclet | ; wait for fifo transmitter is empty |
179 | 7 | krufter_multiclet | buf_TXD: |
180 | 7 | krufter_multiclet | rdl UART_ST |
181 | 7 | krufter_multiclet | getl 0x00000004 |
182 | 7 | krufter_multiclet | and @1, @2 |
183 | 7 | krufter_multiclet | je @1, buf_TXD |
184 | 7 | krufter_multiclet | jne @2, read_DM |
185 | 7 | krufter_multiclet | setl #iterator3, 4 |
186 | 7 | krufter_multiclet | complete |
187 | 7 | krufter_multiclet | |
188 | 7 | krufter_multiclet | ; enable led 2,3 |
189 | 7 | krufter_multiclet | stop2: |
190 | 7 | krufter_multiclet | getl 0x1000 |
191 | 7 | krufter_multiclet | complete |
192 | 7 | krufter_multiclet | </pre> |