LPCOpen Platform
v1.03
LPCOpen Platform for NXP LPC Microcontrollers
Main Page
Modules
Data Structures
Files
Related Pages
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
memtest.c
Go to the documentation of this file.
1
/*
2
* @brief Memory ethernet example
3
* This example shows how to do a (more complex) memory test for
4
* verifying DRAM operation. The test performs walking 0 and 1,
5
* address and inverse address, and pattern tests on DRAM.
6
*
7
* @note
8
* Copyright(C) NXP Semiconductors, 2012
9
* All rights reserved.
10
*
11
* @par
12
* Software that is described herein is for illustrative purposes only
13
* which provides customers with programming information regarding the
14
* LPC products. This software is supplied "AS IS" without any warranties of
15
* any kind, and NXP Semiconductors and its licensor disclaim any and
16
* all warranties, express or implied, including all implied warranties of
17
* merchantability, fitness for a particular purpose and non-infringement of
18
* intellectual property rights. NXP Semiconductors assumes no responsibility
19
* or liability for the use of the software, conveys no license or rights under any
20
* patent, copyright, mask work right, or any other intellectual property rights in
21
* or to any products. NXP Semiconductors reserves the right to make changes
22
* in the software without notification. NXP Semiconductors also makes no
23
* representation or warranty that such application will be suitable for the
24
* specified use without further testing or modification.
25
*
26
* @par
27
* Permission to use, copy, modify, and distribute this software and its
28
* documentation is hereby granted, under NXP Semiconductors' and its
29
* licensor's relevant copyrights in the software, without fee, provided that it
30
* is used in conjunction with NXP Semiconductors microcontrollers. This
31
* copyright, permission, and disclaimer notice must appear in all copies of
32
* this code.
33
*/
34
35
#include "board.h"
36
#include "
mem_tests.h
"
37
#include <stdio.h>
38
65
/*****************************************************************************
66
* Private types/enumerations/variables
67
****************************************************************************/
68
69
#define DRAM_BASE_ADDRESS (uint32_t *) EMC_ADDRESS_DYCS0
70
#define DRAM_SIZE (8 * 1024 * 1024)
71
72
/*****************************************************************************
73
* Public types/enumerations/variables
74
****************************************************************************/
75
76
/*****************************************************************************
77
* Private functions
78
****************************************************************************/
79
80
/*****************************************************************************
81
* Public functions
82
****************************************************************************/
83
88
int
main
(
void
)
89
{
90
MEM_TEST_SETUP_T
memSetup;
91
92
Board_Init
();
93
94
/* Walking 0 test */
95
memSetup.
start_addr
=
DRAM_BASE_ADDRESS
;
96
memSetup.
bytes
=
DRAM_SIZE
;
97
if
(
mem_test_walking0
(&memSetup)) {
98
DEBUGSTR
(
"Walking 0 memory test passed\r\n"
);
99
}
100
else
{
101
DEBUGOUT
(
"Walking 0 memory test failed at address %p\r\n"
, memSetup.
fail_addr
);
102
DEBUGOUT
(
" Expected %08x, actual %08x\r\n"
, memSetup.
ex_val
, memSetup.
is_val
);
103
}
104
105
/* Walking 1 test */
106
memSetup.
start_addr
=
DRAM_BASE_ADDRESS
;
107
memSetup.
bytes
=
DRAM_SIZE
;
108
if
(
mem_test_walking1
(&memSetup)) {
109
DEBUGSTR
(
"Walking 1 memory test passed\r\n"
);
110
}
111
else
{
112
DEBUGOUT
(
"Walking 1 memory test failed at address %p\r\n"
, memSetup.
fail_addr
);
113
DEBUGOUT
(
" Expected %08x, actual %08x\r\n"
, memSetup.
ex_val
, memSetup.
is_val
);
114
}
115
116
/* Address test */
117
memSetup.
start_addr
=
DRAM_BASE_ADDRESS
;
118
memSetup.
bytes
=
DRAM_SIZE
;
119
if
(
mem_test_address
(&memSetup)) {
120
DEBUGSTR
(
"Address test passed\r\n"
);
121
}
122
else
{
123
DEBUGOUT
(
"Address test failed at address %p\r\n"
, memSetup.
fail_addr
);
124
DEBUGOUT
(
" Expected %08x, actual %08x\r\n"
, memSetup.
ex_val
, memSetup.
is_val
);
125
}
126
127
/* Inverse address test */
128
memSetup.
start_addr
=
DRAM_BASE_ADDRESS
;
129
memSetup.
bytes
=
DRAM_SIZE
;
130
if
(
mem_test_invaddress
(&memSetup)) {
131
DEBUGSTR
(
"Inverse address test passed\r\n"
);
132
}
133
else
{
134
DEBUGOUT
(
"Inverse address test failed at address %p\r\n"
, memSetup.
fail_addr
);
135
DEBUGOUT
(
" Expected %08x, actual %08x\r\n"
, memSetup.
ex_val
, memSetup.
is_val
);
136
}
137
138
/* Pattern test */
139
memSetup.
start_addr
=
DRAM_BASE_ADDRESS
;
140
memSetup.
bytes
=
DRAM_SIZE
;
141
if
(
mem_test_pattern
(&memSetup)) {
142
DEBUGSTR
(
"Pattern (0x55/0xAA) test passed\r\n"
);
143
}
144
else
{
145
DEBUGOUT
(
"Pattern (0x55/0xAA) test failed at address %p\r\n"
, memSetup.
fail_addr
);
146
DEBUGOUT
(
" Expected %08x, actual %08x\r\n"
, memSetup.
ex_val
, memSetup.
is_val
);
147
}
148
149
/* Seeded pattern test */
150
memSetup.
start_addr
=
DRAM_BASE_ADDRESS
;
151
memSetup.
bytes
=
DRAM_SIZE
;
152
if
(
mem_test_pattern_seed
(&memSetup, 0x12345678, 0x50005)) {
153
DEBUGSTR
(
"Seeded pattern test passed\r\n"
);
154
}
155
else
{
156
DEBUGOUT
(
"Seeded pattern test failed at address %p\r\n"
, memSetup.
fail_addr
);
157
DEBUGOUT
(
" Expected %08x, actual %08x\r\n"
, memSetup.
ex_val
, memSetup.
is_val
);
158
}
159
160
return
0;
161
}
162
applications
lpc17xx_40xx
examples
periph
periph_memtest
memtest.c
Generated on Fri May 10 2013 10:42:07 for LPCOpen Platform by
1.8.2