LPCOpen Platform  v1.03
LPCOpen Platform for NXP LPC Microcontrollers
 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 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 
67 /*****************************************************************************
68  * Private types/enumerations/variables
69  ****************************************************************************/
70 
71 #define DRAM_BASE_ADDRESS (uint32_t *) 0x28000000
72 
73 #if defined(BOARD_HITEX_EVA_18504350)
74 /* 8MB of Hitex board */
75 #define DRAM_SIZE (8 * 1024 * 1024)
76 #elif defined(BOARD_KEIL_MCB_18574357)
77 #define DRAM_SIZE (8 * 1024 * 1024)
78 #endif
79 
80 /*****************************************************************************
81  * Public types/enumerations/variables
82  ****************************************************************************/
83 
84 /*****************************************************************************
85  * Private functions
86  ****************************************************************************/
87 
88 /*****************************************************************************
89  * Public functions
90  ****************************************************************************/
91 
96 int main(void)
97 {
98  MEM_TEST_SETUP_T memSetup;
99 
100  Board_Init();
101 
102  /* Walking 0 test */
103  memSetup.start_addr = DRAM_BASE_ADDRESS;
104  memSetup.bytes = DRAM_SIZE;
105  if (mem_test_walking0(&memSetup)) {
106  DEBUGSTR("Walking 0 memory test passed\r\n");
107  }
108  else {
109  DEBUGOUT("Walking 0 memory test failed at address %p\r\n", memSetup.fail_addr);
110  DEBUGOUT(" Expected %08x, actual %08x\r\n", memSetup.ex_val, memSetup.is_val);
111  }
112 
113  /* Walking 1 test */
114  memSetup.start_addr = DRAM_BASE_ADDRESS;
115  memSetup.bytes = DRAM_SIZE;
116  if (mem_test_walking1(&memSetup)) {
117  DEBUGSTR("Walking 1 memory test passed\r\n");
118  }
119  else {
120  DEBUGOUT("Walking 1 memory test failed at address %p\r\n", memSetup.fail_addr);
121  DEBUGOUT(" Expected %08x, actual %08x\r\n", memSetup.ex_val, memSetup.is_val);
122  }
123 
124  /* Address test */
125  memSetup.start_addr = DRAM_BASE_ADDRESS;
126  memSetup.bytes = DRAM_SIZE;
127  if (mem_test_address(&memSetup)) {
128  DEBUGSTR("Address test passed\r\n");
129  }
130  else {
131  DEBUGOUT("Address test failed at address %p\r\n", memSetup.fail_addr);
132  DEBUGOUT(" Expected %08x, actual %08x\r\n", memSetup.ex_val, memSetup.is_val);
133  }
134 
135  /* Inverse address test */
136  memSetup.start_addr = DRAM_BASE_ADDRESS;
137  memSetup.bytes = DRAM_SIZE;
138  if (mem_test_invaddress(&memSetup)) {
139  DEBUGSTR("Inverse address test passed\r\n");
140  }
141  else {
142  DEBUGOUT("Inverse address test failed at address %p\r\n", memSetup.fail_addr);
143  DEBUGOUT(" Expected %08x, actual %08x\r\n", memSetup.ex_val, memSetup.is_val);
144  }
145 
146  /* Pattern test */
147  memSetup.start_addr = DRAM_BASE_ADDRESS;
148  memSetup.bytes = DRAM_SIZE;
149  if (mem_test_pattern(&memSetup)) {
150  DEBUGSTR("Pattern (0x55/0xAA) test passed\r\n");
151  }
152  else {
153  DEBUGOUT("Pattern (0x55/0xAA) test failed at address %p\r\n", memSetup.fail_addr);
154  DEBUGOUT(" Expected %08x, actual %08x\r\n", memSetup.ex_val, memSetup.is_val);
155  }
156 
157  /* Seeded pattern test */
158  memSetup.start_addr = DRAM_BASE_ADDRESS;
159  memSetup.bytes = DRAM_SIZE;
160  if (mem_test_pattern_seed(&memSetup, 0x12345678, 0x50005)) {
161  DEBUGSTR("Seeded pattern test passed\r\n");
162  }
163  else {
164  DEBUGOUT("Seeded pattern test failed at address %p\r\n", memSetup.fail_addr);
165  DEBUGOUT(" Expected %08x, actual %08x\r\n", memSetup.ex_val, memSetup.is_val);
166  }
167 
168  /* Never returns, for warning only */
169  return 0;
170 }
171