michas (04.01.2018 16:49, просмотров: 172) ответил AlexG на у меня есть на Си и с одним нюансом - я тестировал внешнее ОЗУ, внутреннее не пробовал.
Поможите люди добрые, написал вот, работает. Но почему компилятор раскидывает переменные в какие попало регистры? #define STRT_ADDR_RAM (0x20000000)
#define SIZE_RAM (0x4000)
void RamTest(void)
{
register uint32_t addres_ram __asm("r8");
register uint32_t result_T1 __asm("r9");
register uint32_t result_T0 __asm("r10");
register uint32_t result_TRAA __asm("r11");
register uint32_t result_TR55 __asm("r12");
#pragma push
#pragma O0
#pragma Otime
for (addres_ram = STRT_ADDR_RAM; addres_ram < STRT_ADDR_RAM + SIZE_RAM; addres_ram++)
{
*(__IO uint8_t*)addres_ram = 0x00;
}
result_T0 = 1;
for (addres_ram = STRT_ADDR_RAM; addres_ram < STRT_ADDR_RAM + SIZE_RAM; addres_ram++)
{
*(__IO uint8_t*)addres_ram = 0xFF;
}
result_T1 = 1;
for (addres_ram = STRT_ADDR_RAM; addres_ram < STRT_ADDR_RAM + SIZE_RAM; addres_ram++)
{
*(__IO uint8_t*)addres_ram = 0x55;
}
result_TR55 = 1;
for (addres_ram = STRT_ADDR_RAM; addres_ram < STRT_ADDR_RAM + SIZE_RAM; addres_ram++)
{
*(__IO uint8_t*)addres_ram = 0xAA;
}
result_TRAA = 1;
#pragma pop
}
;;;166 void RamTest(void)
000000 b530 PUSH {r4,r5,lr}
;;;167 {
;;;168 register uint32_t addres_ram __asm("r8");
;;;169 register uint32_t result_T1 __asm("r9");
;;;170 register uint32_t result_T0 __asm("r10");
;;;171 register uint32_t result_TRAA __asm("r11");
;;;172 register uint32_t result_TR55 __asm("r12");
;;;173
;;;174 #pragma push
;;;175 #pragma O0
;;;176 #pragma Otime
;;;177
;;;178 for (addres_ram = STRT_ADDR_RAM; addres_ram < STRT_ADDR_RAM + SIZE_RAM; addres_ram++)
000002 f04f5000 MOV r0,#0x20000000
000006 e002 B |L1.14|
|L1.8|
;;;179 {
;;;180 *(__IO uint8_t*)addres_ram = 0x00;
000008 2500 MOVS r5,#0
00000a 7005 STRB r5,[r0,#0]
00000c 1c40 ADDS r0,r0,#1 ;178
|L1.14|
00000e 4d10 LDR r5,|L1.80|
000010 42a8 CMP r0,r5 ;178
000012 d3f9 BCC |L1.8|
;;;181 }
;;;182
;;;183 result_T0 = 1;
000014 2201 MOVS r2,#1
;;;184
;;;185 for (addres_ram = STRT_ADDR_RAM; addres_ram < STRT_ADDR_RAM + SIZE_RAM; addres_ram++)
000016 0750 LSLS r0,r2,#29
000018 e002 B |L1.32|
|L1.26|
;;;186 {
;;;187 *(__IO uint8_t*)addres_ram = 0xFF;
00001a 25ff MOVS r5,#0xff
00001c 7005 STRB r5,[r0,#0]
00001e 1c40 ADDS r0,r0,#1 ;185
|L1.32|
000020 4d0b LDR r5,|L1.80|
000022 42a8 CMP r0,r5 ;185
000024 d3f9 BCC |L1.26|
;;;188 }
;;;189
;;;190 result_T1 = 1;
000026 2101 MOVS r1,#1
;;;191
;;;192 for (addres_ram = STRT_ADDR_RAM; addres_ram < STRT_ADDR_RAM + SIZE_RAM; addres_ram++)
000028 0748 LSLS r0,r1,#29
00002a e002 B |L1.50|
|L1.44|
;;;193 {
;;;194 *(__IO uint8_t*)addres_ram = 0x55;
00002c 2555 MOVS r5,#0x55
00002e 7005 STRB r5,[r0,#0]
000030 1c40 ADDS r0,r0,#1 ;192
|L1.50|
000032 4d07 LDR r5,|L1.80|
000034 42a8 CMP r0,r5 ;192
000036 d3f9 BCC |L1.44|
;;;195 }
;;;196
;;;197 result_TR55 = 1;
000038 2401 MOVS r4,#1
;;;198
;;;199 for (addres_ram = STRT_ADDR_RAM; addres_ram < STRT_ADDR_RAM + SIZE_RAM; addres_ram++)
00003a 0760 LSLS r0,r4,#29
00003c e002 B |L1.68|
|L1.62|
;;;200 {
;;;201 *(__IO uint8_t*)addres_ram = 0xAA;
00003e 25aa MOVS r5,#0xaa
000040 7005 STRB r5,[r0,#0]
000042 1c40 ADDS r0,r0,#1 ;199
|L1.68|
000044 4d02 LDR r5,|L1.80|
000046 42a8 CMP r0,r5 ;199
000048 d3f9 BCC |L1.62|
;;;202 }
;;;203
;;;204 result_TRAA = 1;
00004a 2301 MOVS r3,#1
;;;205
;;;206 #pragma pop
;;;207 }
00004c bd30 POP {r4,r5,pc}
;;;208
ENDP
00004e 0000 DCW 0x0000
|L1.80|
DCD 0x20004000