NM500 TEST PGM

Dependencies:   NM500Lib_Socket NM500_Test_Socket SDFileSystem_Socket mbed

Committer:
Nasungil
Date:
Mon Dec 17 09:32:13 2018 +0000
Revision:
17:c6ea9c132419
Parent:
16:2a9a0976146c
Child:
18:ef02c87871b8
NM500 Socket Board PGM
;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Nasungil 8:c41405662e53 1 #include "mbed.h"
Nasungil 8:c41405662e53 2 #include "NM500.h"
Nasungil 13:e756b6e50853 3 #include "Test.h"
Nasungil 8:c41405662e53 4
Nasungil 13:e756b6e50853 5
Nasungil 12:c8fbe49527e7 6 void data_classify(void);
Nasungil 12:c8fbe49527e7 7 void NSR_Test(void);
Nasungil 13:e756b6e50853 8 void Connection_test(void);
Nasungil 13:e756b6e50853 9 void Memory_Test(void);
Nasungil 13:e756b6e50853 10
Nasungil 13:e756b6e50853 11 //connection
Nasungil 13:e756b6e50853 12 int NSR_Conn_fail = 0;
Nasungil 13:e756b6e50853 13 int GCR_Conn_fail = 0;
Nasungil 13:e756b6e50853 14 int MINIF_Conn_fail = 0;
Nasungil 13:e756b6e50853 15 int MAXIF_Conn_fail = 0;
Nasungil 13:e756b6e50853 16 int NCR_Conn_fail = 0;
Nasungil 13:e756b6e50853 17 int INDEX_Conn_fail = 0;
Nasungil 13:e756b6e50853 18 int DIST_Conn_fail = 0;
Nasungil 13:e756b6e50853 19 int CAT_Conn_fail = 0;
Nasungil 13:e756b6e50853 20 int AIF_Conn_fail = 0;
Nasungil 13:e756b6e50853 21 int NID_Conn_fail = 0;
Nasungil 13:e756b6e50853 22 int Connection = 0;
Nasungil 13:e756b6e50853 23
Nasungil 13:e756b6e50853 24 //reset Test
Nasungil 13:e756b6e50853 25 int Reset_fail = 0;
Nasungil 13:e756b6e50853 26
Nasungil 13:e756b6e50853 27 //memory test
Nasungil 13:e756b6e50853 28 int Memory_fail = 0;
Nasungil 12:c8fbe49527e7 29
Nasungil 12:c8fbe49527e7 30 int id_fail = 0;
Nasungil 12:c8fbe49527e7 31 int nsr_fail = 0;
Nasungil 12:c8fbe49527e7 32
Nasungil 12:c8fbe49527e7 33 int CMN_Maxif = 0;
Nasungil 12:c8fbe49527e7 34 int CMN_Nsr = 0;
Nasungil 12:c8fbe49527e7 35 int CMN_Ncount = 0;
Nasungil 12:c8fbe49527e7 36 int CMN_RC = 0;
Nasungil 12:c8fbe49527e7 37 int CMN = 0;
Nasungil 12:c8fbe49527e7 38
Nasungil 12:c8fbe49527e7 39 int Gcr1 = 0;
Nasungil 12:c8fbe49527e7 40 int Gcr2 = 0;
Nasungil 12:c8fbe49527e7 41 int Minif1 = 0;
Nasungil 12:c8fbe49527e7 42 int Minif2 = 0;
Nasungil 12:c8fbe49527e7 43 int Maxif1 = 0;
Nasungil 12:c8fbe49527e7 44 int Maxif2 = 0;
Nasungil 12:c8fbe49527e7 45 int Aif1 = 0;
Nasungil 12:c8fbe49527e7 46 int Aif2 = 0;
Nasungil 12:c8fbe49527e7 47 int Cat1 = 0;
Nasungil 12:c8fbe49527e7 48 int Cat2 = 0;
Nasungil 12:c8fbe49527e7 49
Nasungil 12:c8fbe49527e7 50 int Nid1 = 0;
Nasungil 12:c8fbe49527e7 51 int Nid2 = 0;
Nasungil 12:c8fbe49527e7 52 int Dist1 = 0;
Nasungil 12:c8fbe49527e7 53 int Dist2 = 0;
Nasungil 12:c8fbe49527e7 54
Nasungil 12:c8fbe49527e7 55 int Learn1 = 0;
Nasungil 12:c8fbe49527e7 56 int Learn2 = 0;
Nasungil 12:c8fbe49527e7 57
Nasungil 12:c8fbe49527e7 58 int Memory1 = 0;
Nasungil 12:c8fbe49527e7 59 int Memory2 = 0;
Nasungil 12:c8fbe49527e7 60
Nasungil 12:c8fbe49527e7 61 int NM1 = 0;
Nasungil 12:c8fbe49527e7 62 int NM2 = 0;
Nasungil 12:c8fbe49527e7 63
Nasungil 13:e756b6e50853 64 unsigned char array1[NEURONSIZE];
Nasungil 13:e756b6e50853 65 unsigned char array2[NEURONSIZE];
Nasungil 10:74e762848659 66
Nasungil 16:2a9a0976146c 67
Nasungil 13:e756b6e50853 68 Serial pc(SERIAL_TX, SERIAL_RX);
Nasungil 13:e756b6e50853 69
Nasungil 8:c41405662e53 70
Nasungil 11:6a81bde51be5 71 int main() {
Nasungil 15:4acc28dbd9fe 72 //pc.baud(115200);
Nasungil 12:c8fbe49527e7 73
Nasungil 13:e756b6e50853 74 pc.printf("\nPress any key to start\n");
Nasungil 13:e756b6e50853 75 int data = pc.getc();
Nasungil 13:e756b6e50853 76
Nasungil 16:2a9a0976146c 77 pc.printf("\nNM500 Test Board V1.0 \n");
Nasungil 13:e756b6e50853 78 //SPI Setting
Nasungil 14:0264a9975d3d 79 //time measure start
Nasungil 16:2a9a0976146c 80
Nasungil 13:e756b6e50853 81 SPI_Init();
Nasungil 13:e756b6e50853 82 SD_Init();
Nasungil 13:e756b6e50853 83 //reset Test
Nasungil 16:2a9a0976146c 84
Nasungil 13:e756b6e50853 85 RESET_Test();
Nasungil 16:2a9a0976146c 86
Nasungil 16:2a9a0976146c 87
Nasungil 13:e756b6e50853 88 //NM500 Init
Nasungil 12:c8fbe49527e7 89 if(begin() == 0){
Nasungil 17:c6ea9c132419 90 pc.printf("\nNM500 Init\n");
Nasungil 12:c8fbe49527e7 91 }
Nasungil 12:c8fbe49527e7 92 else{
Nasungil 14:0264a9975d3d 93 error("IC Fail\n");
Nasungil 14:0264a9975d3d 94
Nasungil 12:c8fbe49527e7 95 }
Nasungil 13:e756b6e50853 96 //connection Test
Nasungil 16:2a9a0976146c 97
Nasungil 13:e756b6e50853 98 Connection_test();
Nasungil 16:2a9a0976146c 99
Nasungil 16:2a9a0976146c 100
Nasungil 16:2a9a0976146c 101
Nasungil 16:2a9a0976146c 102 Cell_Test();
Nasungil 11:6a81bde51be5 103
Nasungil 13:e756b6e50853 104 //Memory Test
Nasungil 16:2a9a0976146c 105
Nasungil 13:e756b6e50853 106 Memory_Test();
Nasungil 16:2a9a0976146c 107
Nasungil 16:2a9a0976146c 108
Nasungil 13:e756b6e50853 109 forget();
Nasungil 13:e756b6e50853 110
Nasungil 12:c8fbe49527e7 111 //memory array init
Nasungil 12:c8fbe49527e7 112 for(int i=0;i<NEURONSIZE;i=i+1){
Nasungil 12:c8fbe49527e7 113 array1[i]=0x0a;
Nasungil 12:c8fbe49527e7 114 array2[i]=0x05;
Nasungil 12:c8fbe49527e7 115 }
Nasungil 12:c8fbe49527e7 116 NSR_Test();
Nasungil 12:c8fbe49527e7 117
Nasungil 14:0264a9975d3d 118
Nasungil 12:c8fbe49527e7 119 //NCOUNT Test
Nasungil 12:c8fbe49527e7 120 int ncount_fail = read(NM_NCOUNT);
Nasungil 11:6a81bde51be5 121
Nasungil 12:c8fbe49527e7 122 if(ncount_fail != 0){
Nasungil 12:c8fbe49527e7 123 CMN_Ncount = 1;
Nasungil 12:c8fbe49527e7 124 error("NCOUNT Fail\n");
Nasungil 12:c8fbe49527e7 125 }
Nasungil 12:c8fbe49527e7 126
Nasungil 8:c41405662e53 127 //minif test
Nasungil 10:74e762848659 128 write(NM_MINIF,3);
Nasungil 12:c8fbe49527e7 129 // int minif = read(NM_MINIF);
Nasungil 12:c8fbe49527e7 130 // if(minif != 3)
Nasungil 12:c8fbe49527e7 131 // CMN_Minif = 1;
Nasungil 11:6a81bde51be5 132
Nasungil 8:c41405662e53 133 //maxif test
Nasungil 9:7970a5638913 134 write(NM_MAXIF,10000);
Nasungil 10:74e762848659 135 int maxif = read(NM_MAXIF);
Nasungil 12:c8fbe49527e7 136 if(maxif != 10000)
Nasungil 12:c8fbe49527e7 137 CMN_Maxif = 1;
Nasungil 8:c41405662e53 138
Nasungil 8:c41405662e53 139 //GCR test
Nasungil 9:7970a5638913 140 write(NM_GCR,5);
Nasungil 12:c8fbe49527e7 141 // int gcr = read(NM_GCR);
Nasungil 13:e756b6e50853 142 // //pc.printf("gcr : %d",gcr);
Nasungil 12:c8fbe49527e7 143 // if(gcr != 5)
Nasungil 12:c8fbe49527e7 144 // CMN_Gcr = 1;
Nasungil 10:74e762848659 145
Nasungil 16:2a9a0976146c 146
Nasungil 8:c41405662e53 147 //Neuron learn
Nasungil 13:e756b6e50853 148 pc.printf("\nLearn Start\n");
Nasungil 12:c8fbe49527e7 149
Nasungil 12:c8fbe49527e7 150
Nasungil 12:c8fbe49527e7 151 int daisy = data_learn();
Nasungil 12:c8fbe49527e7 152
Nasungil 16:2a9a0976146c 153
Nasungil 17:c6ea9c132419 154 pc.printf("\nLearn Complete\n");
Nasungil 16:2a9a0976146c 155
Nasungil 16:2a9a0976146c 156
Nasungil 8:c41405662e53 157
Nasungil 9:7970a5638913 158 //data save
Nasungil 16:2a9a0976146c 159
Nasungil 17:c6ea9c132419 160 pc.printf("\nSave Start\n");
Nasungil 12:c8fbe49527e7 161
Nasungil 9:7970a5638913 162 int save = NeuronToSD();
Nasungil 12:c8fbe49527e7 163 if(save == 0xFFFF || save == 0x7FFF) //change
Nasungil 12:c8fbe49527e7 164 save = MAXNEURONS;
Nasungil 16:2a9a0976146c 165
Nasungil 17:c6ea9c132419 166 pc.printf("\nSave Complete\n");
Nasungil 16:2a9a0976146c 167
Nasungil 16:2a9a0976146c 168
Nasungil 9:7970a5638913 169
Nasungil 10:74e762848659 170 //forget
Nasungil 9:7970a5638913 171 forget();
Nasungil 12:c8fbe49527e7 172
Nasungil 10:74e762848659 173
Nasungil 10:74e762848659 174 //restore
Nasungil 17:c6ea9c132419 175 pc.printf("\nRestore Start\n");
Nasungil 12:c8fbe49527e7 176
Nasungil 10:74e762848659 177 int restore = SDToNeurons();
Nasungil 12:c8fbe49527e7 178
Nasungil 12:c8fbe49527e7 179 if(restore == 0xFFFF || restore == 0x7FFF) //change
Nasungil 12:c8fbe49527e7 180 restore = MAXNEURONS;
Nasungil 16:2a9a0976146c 181
Nasungil 17:c6ea9c132419 182 pc.printf("\nRestore Complete\n");
Nasungil 16:2a9a0976146c 183
Nasungil 16:2a9a0976146c 184
Nasungil 10:74e762848659 185
Nasungil 10:74e762848659 186 setKNN();
Nasungil 10:74e762848659 187 //classify
Nasungil 16:2a9a0976146c 188
Nasungil 17:c6ea9c132419 189 pc.printf("\nClassify Start\n");
Nasungil 12:c8fbe49527e7 190
Nasungil 12:c8fbe49527e7 191 data_classify();
Nasungil 16:2a9a0976146c 192
Nasungil 17:c6ea9c132419 193 pc.printf("\nClassify Complete\n");
Nasungil 16:2a9a0976146c 194
Nasungil 10:74e762848659 195
Nasungil 9:7970a5638913 196
Nasungil 13:e756b6e50853 197 pc.printf("\n****************Test Result****************\n");
Nasungil 12:c8fbe49527e7 198 //nsr result
Nasungil 12:c8fbe49527e7 199 if(CMN_Nsr ==1){
Nasungil 13:e756b6e50853 200 pc.printf("NSR Register Fail\n");
Nasungil 12:c8fbe49527e7 201 CMN++;
Nasungil 12:c8fbe49527e7 202 }
Nasungil 10:74e762848659 203
Nasungil 12:c8fbe49527e7 204 //NCOUNT Result
Nasungil 12:c8fbe49527e7 205 if(CMN_Ncount ==1){
Nasungil 13:e756b6e50853 206 pc.printf("NCOUNT Register Fail\n");
Nasungil 12:c8fbe49527e7 207 CMN++;
Nasungil 10:74e762848659 208 }
Nasungil 10:74e762848659 209
Nasungil 12:c8fbe49527e7 210 //MAXIF Result
Nasungil 12:c8fbe49527e7 211 if(CMN_Maxif ==1){
Nasungil 13:e756b6e50853 212 pc.printf("MAXIF Register Fail\n");
Nasungil 12:c8fbe49527e7 213 CMN++;
Nasungil 12:c8fbe49527e7 214 }
Nasungil 12:c8fbe49527e7 215
Nasungil 12:c8fbe49527e7 216 //MINIF Result
Nasungil 12:c8fbe49527e7 217 if(Minif1 ==1){
Nasungil 13:e756b6e50853 218 pc.printf("#1 NM500 MINIF Register Fail\n");
Nasungil 12:c8fbe49527e7 219 NM1++;
Nasungil 10:74e762848659 220 }
Nasungil 12:c8fbe49527e7 221 if(Minif2 ==1){
Nasungil 13:e756b6e50853 222 pc.printf("#2 NM500 MINIF Register Fail\n");
Nasungil 12:c8fbe49527e7 223 NM2++;
Nasungil 12:c8fbe49527e7 224 }
Nasungil 12:c8fbe49527e7 225
Nasungil 12:c8fbe49527e7 226 //learn result
Nasungil 12:c8fbe49527e7 227 if(Learn1 == 1){
Nasungil 13:e756b6e50853 228 pc.printf("#1 NM500 Learn Function Fail\n");
Nasungil 12:c8fbe49527e7 229 NM1++;
Nasungil 12:c8fbe49527e7 230 }
Nasungil 12:c8fbe49527e7 231 if(Learn2 == 1){
Nasungil 13:e756b6e50853 232 pc.printf("#2 NM500 Learn Function Fail\n");
Nasungil 12:c8fbe49527e7 233 NM2++;
Nasungil 10:74e762848659 234 }
Nasungil 10:74e762848659 235
Nasungil 12:c8fbe49527e7 236 //Daisy Chain result
Nasungil 12:c8fbe49527e7 237 if(daisy == 1){
Nasungil 13:e756b6e50853 238 pc.printf("#1 NM500 Daisy Chain Fail\n");
Nasungil 12:c8fbe49527e7 239 NM1++;
Nasungil 12:c8fbe49527e7 240 }
Nasungil 12:c8fbe49527e7 241
Nasungil 12:c8fbe49527e7 242 //GCR result
Nasungil 12:c8fbe49527e7 243 if(Gcr1 == 1){
Nasungil 13:e756b6e50853 244 pc.printf("#1 NM500 GCR Register Fail\n");
Nasungil 12:c8fbe49527e7 245 NM1++;
Nasungil 12:c8fbe49527e7 246 }
Nasungil 12:c8fbe49527e7 247 if(Gcr2 == 1){
Nasungil 13:e756b6e50853 248 pc.printf("#2 NM500 GCR Register Fail\n");
Nasungil 12:c8fbe49527e7 249 NM2++;
Nasungil 12:c8fbe49527e7 250 }
Nasungil 12:c8fbe49527e7 251 //AIF result
Nasungil 12:c8fbe49527e7 252 if(Aif1 == 1){
Nasungil 13:e756b6e50853 253 pc.printf("#1 NM500 AIF Register Fail\n");
Nasungil 12:c8fbe49527e7 254 NM1++;
Nasungil 12:c8fbe49527e7 255 }
Nasungil 12:c8fbe49527e7 256 if(Aif2 == 1){
Nasungil 13:e756b6e50853 257 pc.printf("#2 NM500 AIF Register Fail\n");
Nasungil 12:c8fbe49527e7 258 NM2++;
Nasungil 10:74e762848659 259 }
Nasungil 12:c8fbe49527e7 260 //Cat result
Nasungil 12:c8fbe49527e7 261 if(Cat1 == 1){
Nasungil 13:e756b6e50853 262 pc.printf("#1 NM500 CAT Register Fail\n");
Nasungil 12:c8fbe49527e7 263 NM1++;
Nasungil 12:c8fbe49527e7 264 }
Nasungil 12:c8fbe49527e7 265 if(Cat2 == 1){
Nasungil 13:e756b6e50853 266 pc.printf("#2 NM500 CAT Register Fail\n");
Nasungil 12:c8fbe49527e7 267 NM2++;
Nasungil 12:c8fbe49527e7 268 }
Nasungil 12:c8fbe49527e7 269 if(save != MAXNEURONS){
Nasungil 13:e756b6e50853 270 pc.printf("NM500 Learn Function Fail\n");
Nasungil 12:c8fbe49527e7 271 CMN++;
Nasungil 10:74e762848659 272 }
Nasungil 12:c8fbe49527e7 273 if(restore != MAXNEURONS){
Nasungil 13:e756b6e50853 274 pc.printf("NM500 Restore Function Fail\n");
Nasungil 12:c8fbe49527e7 275 CMN++;
Nasungil 12:c8fbe49527e7 276 }
Nasungil 12:c8fbe49527e7 277 //NID result
Nasungil 12:c8fbe49527e7 278 if(Nid1 == 1){
Nasungil 13:e756b6e50853 279 pc.printf("#1 NM500 Nid Register Fail\n");
Nasungil 12:c8fbe49527e7 280 NM1++;
Nasungil 12:c8fbe49527e7 281 }
Nasungil 12:c8fbe49527e7 282 if(Nid2 == 1){
Nasungil 13:e756b6e50853 283 pc.printf("#2 NM500 Nid Register Fail\n");
Nasungil 12:c8fbe49527e7 284 NM2++;
Nasungil 10:74e762848659 285 }
Nasungil 10:74e762848659 286
Nasungil 12:c8fbe49527e7 287 //Dist result
Nasungil 12:c8fbe49527e7 288 if(Dist1 == 1){
Nasungil 13:e756b6e50853 289 pc.printf("#1 NM500 Dist Register Fail\n");
Nasungil 12:c8fbe49527e7 290 NM1++;
Nasungil 12:c8fbe49527e7 291 }
Nasungil 12:c8fbe49527e7 292 if(Dist2 == 1){
Nasungil 13:e756b6e50853 293 pc.printf("#2 NM500 Dist Register Fail\n");
Nasungil 12:c8fbe49527e7 294 NM2++;
Nasungil 12:c8fbe49527e7 295 }
Nasungil 12:c8fbe49527e7 296 if(Memory1 == 1){
Nasungil 13:e756b6e50853 297 pc.printf("#1 Memory Fail\n");
Nasungil 12:c8fbe49527e7 298 NM1++;
Nasungil 12:c8fbe49527e7 299 }
Nasungil 12:c8fbe49527e7 300 if(Memory2 == 1){
Nasungil 13:e756b6e50853 301 pc.printf("#2 NM500 Memory Fail\n");
Nasungil 12:c8fbe49527e7 302 NM2++;
Nasungil 12:c8fbe49527e7 303 }
Nasungil 12:c8fbe49527e7 304
Nasungil 12:c8fbe49527e7 305 //final result
Nasungil 13:e756b6e50853 306 if(Reset_fail == 1)
Nasungil 13:e756b6e50853 307 pc.printf("Resest Test Fail\n");
Nasungil 14:0264a9975d3d 308 else
Nasungil 14:0264a9975d3d 309 pc.printf("Resest Test Pass\n");
Nasungil 12:c8fbe49527e7 310
Nasungil 13:e756b6e50853 311 if(Connection == 1)
Nasungil 13:e756b6e50853 312 pc.printf("Connection Test Fail\n");
Nasungil 14:0264a9975d3d 313 else
Nasungil 14:0264a9975d3d 314 pc.printf("Connection Test Pass\n");
Nasungil 13:e756b6e50853 315
Nasungil 13:e756b6e50853 316 if(Memory_fail == 1)
Nasungil 13:e756b6e50853 317 pc.printf("Memory Test Fail \n");
Nasungil 14:0264a9975d3d 318 else
Nasungil 14:0264a9975d3d 319 pc.printf("Memory Test Pass\n");
Nasungil 13:e756b6e50853 320 if(NM1 !=0)
Nasungil 13:e756b6e50853 321 pc.printf("#1 NM500 Function Test Fail\n");
Nasungil 13:e756b6e50853 322 if(NM2 != 0)
Nasungil 13:e756b6e50853 323 pc.printf("#2 NM500 Function Test Fail\n");
Nasungil 13:e756b6e50853 324 if(NM1 == 0 && NM2 == 0)
Nasungil 14:0264a9975d3d 325 pc.printf("NM500 Function Test PASS\n");
Nasungil 12:c8fbe49527e7 326
Nasungil 13:e756b6e50853 327 // pc.printf("POWER SAVE ON\n");
Nasungil 12:c8fbe49527e7 328 // write(NM_POWER_SAVE,0);
Nasungil 16:2a9a0976146c 329
Nasungil 12:c8fbe49527e7 330
Nasungil 12:c8fbe49527e7 331 }
Nasungil 14:0264a9975d3d 332
Nasungil 14:0264a9975d3d 333
Nasungil 14:0264a9975d3d 334
Nasungil 16:2a9a0976146c 335