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