This is the third blog update after I started to build the infrared remote control code learner (here are links to the previous posts: 1, 2, 3 ) . I thought it would go faster, but it turned out to be a quite difficult task, which I am still working on. So far, as I showed in my previous blog, I built a circuit and algorithm that captures the infrared signal from a remote control, decodes it, measures the infrared carrier frequency (which can have various values typically between 30kHz and 60kHz), and encodes it in a format that can be further stored in the EEPROM memory block of the PsoC5LP chip. In this update I will show how I store the infrared remote control codes into the EEPROM array inside the Cypress PSoC5LP chip and how I read it back. Next step would be to reconstruct the infrared signal and send it to an IR LED. When done with this task I will implement the code learner into my brainwaves appliance controller project so users can “teach” the brainwaves appliance controller specific codes needed to control their TVs, cable or satellite receivers, and other electronic devices that use infrared remote control.
So let’s take a look on how I have approached the code writing into EEPROM memory block task. First, I need to fit 8 infrared remote control codes into the 2k EEPROM memory inside the PSoC5LP. Each remote control code is sampled and then encoded in a compressed format that fits in an array of 224 locations.
For each infrared remote control code I need to store an array of size 224 uint8 values and additionally the infrared carrier frequency and unit interval. In the table below I am showing how I mapped the 2k EEPROM block inside PSoC5LP to store these 8 infrared remote control codes. There are 128 rows and each row has 16 locations of 8 bits each.
EEPROM Memory Mapping
Row number | mem_bas_index | ||
0 | 0 | code_0_IR_remote | code0_IR_carrier_freg_and_unit_interval |
1 | 16 | code0_IR_carrier_on array [0-15] | |
2 | 32 | code0_IR_carrier_on array [16-31] | |
3 | 48 | code0_IR_carrier_on array [32-47] | |
4 | 64 | code0_IR_carrier_on array [48-63] | |
5 | 80 | code0_IR_carrier_on array [64-79] | |
6 | 96 | code0_IR_carrier_on array [80-95] | |
7 | 112 | code0_IR_carrier_on array [96-111] | |
8 | 128 | code0_IR_carrier_off array [0-15] | |
9 | 144 | code0_IR_carrier_off array [16-31] | |
10 | 160 | code0_IR_carrier_off array [32-47] | |
11 | 176 | code0_IR_carrier_off array [48-63] | |
12 | 192 | code0_IR_carrier_off array [64-79] | |
13 | 208 | code0_IR_carrier_off array [80-95] | |
14 | 224 | code0_IR_carrier_off array [96-111] | |
15 | 240 | ||
16 | 256 | code_1_IR_remote | code1_IR_carrier_freg_and_unit_interval |
17 | 272 | code1_IR_carrier_on array [0-15] | |
18 | 288 | code1_IR_carrier_on array [16-31] | |
19 | 304 | code1_IR_carrier_on array [32-47] | |
20 | 320 | code1_IR_carrier_on array [48-63] | |
21 | 336 | code1_IR_carrier_on array [64-79] | |
22 | 352 | code1_IR_carrier_on array [80-95] | |
23 | 368 | code1_IR_carrier_on array [96-111] | |
24 | 384 | code1_IR_carrier_off array [0-15] | |
25 | 400 | code1_IR_carrier_off array [16-31] | |
26 | 416 | code1_IR_carrier_off array [32-47] | |
27 | 432 | code1_IR_carrier_off array [48-63] | |
28 | 448 | code1_IR_carrier_off array [64-79] | |
29 | 464 | code1_IR_carrier_off array [80-95] | |
30 | 480 | code1_IR_carrier_off array [96-111] | |
31 | 496 | ||
32 | 512 | code_2_IR_remote | code2_IR_carrier_freg_and_unit_interval |
33 | 528 | code2_IR_carrier_on array [0-15] | |
34 | 544 | code2_IR_carrier_on array [16-31] | |
35 | 560 | code2_IR_carrier_on array [32-47] | |
36 | 576 | code2_IR_carrier_on array [48-63] | |
37 | 592 | code2_IR_carrier_on array [64-79] | |
38 | 608 | code2_IR_carrier_on array [80-95] | |
39 | 624 | code2_IR_carrier_on array [96-111] | |
40 | 640 | code2_IR_carrier_off array [0-15] | |
41 | 656 | code2_IR_carrier_off array [16-31] | |
42 | 672 | code2_IR_carrier_off array [32-47] | |
43 | 688 | code2_IR_carrier_off array [48-63] | |
44 | 704 | code2_IR_carrier_off array [64-79] | |
45 | 720 | code2_IR_carrier_off array [80-95] | |
46 | 736 | code2_IR_carrier_off array [96-111] | |
47 | 752 | ||
48 | 768 | code_3_IR_remote | code3_IR_carrier_freg_and_unit_interval |
49 | 784 | code3_IR_carrier_on array [0-15] | |
50 | 800 | code3_IR_carrier_on array [16-31] | |
51 | 816 | code3_IR_carrier_on array [32-47] | |
52 | 832 | code3_IR_carrier_on array [48-63] | |
53 | 848 | code3_IR_carrier_on array [64-79] | |
54 | 864 | code3_IR_carrier_on array [80-95] | |
55 | 880 | code3_IR_carrier_on array [96-111] | |
56 | 896 | code3_IR_carrier_off array [0-15] | |
57 | 912 | code3_IR_carrier_off array [16-31] | |
58 | 928 | code3_IR_carrier_off array [32-47] | |
59 | 944 | code3_IR_carrier_off array [48-63] | |
60 | 960 | code3_IR_carrier_off array [64-79] | |
61 | 976 | code3_IR_carrier_off array [80-95] | |
62 | 992 | code3_IR_carrier_off array [96-111] | |
63 | 1008 | ||
64 | 1024 | code_4_IR_remote | code4_IR_carrier_freg_and_unit_interval |
65 | 1040 | code4_IR_carrier_on array [0-15] | |
66 | 1056 | code4_IR_carrier_on array [16-31] | |
67 | 1072 | code4_IR_carrier_on array [32-47] | |
68 | 1088 | code4_IR_carrier_on array [48-63] | |
69 | 1104 | code4_IR_carrier_on array [64-79] | |
70 | 1120 | code4_IR_carrier_on array [80-95] | |
71 | 1136 | code4_IR_carrier_on array [96-111] | |
72 | 1152 | code4_IR_carrier_off array [0-15] | |
73 | 1168 | code4_IR_carrier_off array [16-31] | |
74 | 1184 | code4_IR_carrier_off array [32-47] | |
75 | 1200 | code4_IR_carrier_off array [48-63] | |
76 | 1216 | code4_IR_carrier_off array [64-79] | |
77 | 1232 | code4_IR_carrier_off array [80-95] | |
78 | 1248 | code4_IR_carrier_off array [96-111] | |
79 | 1264 | ||
80 | 1280 | code_5_IR_remote | code5_IR_carrier_freg_and_unit_interval |
81 | 1296 | code5_IR_carrier_on array [0-15] | |
82 | 1312 | code5_IR_carrier_on array [16-31] | |
83 | 1328 | code5_IR_carrier_on array [32-47] | |
84 | 1344 | code5_IR_carrier_on array [48-63] | |
85 | 1360 | code5_IR_carrier_on array [64-79] | |
86 | 1376 | code5_IR_carrier_on array [80-95] | |
87 | 1392 | code5_IR_carrier_on array [96-111] | |
88 | 1408 | code5_IR_carrier_off array [0-15] | |
89 | 1424 | code5_IR_carrier_off array [16-31] | |
90 | 1440 | code5_IR_carrier_off array [32-47] | |
91 | 1456 | code5_IR_carrier_off array [48-63] | |
92 | 1472 | code5_IR_carrier_off array [64-79] | |
93 | 1488 | code5_IR_carrier_off array [80-95] | |
94 | 1504 | code5_IR_carrier_off array [96-111] | |
95 | 1520 | ||
96 | 1536 | code_6_IR_remote | code6_IR_carrier_freg_and_unit_interval |
97 | 1552 | code6_IR_carrier_on array [0-15] | |
98 | 1568 | code6_IR_carrier_on array [16-31] | |
99 | 1584 | code6_IR_carrier_on array [32-47] | |
100 | 1600 | code6_IR_carrier_on array [48-63] | |
101 | 1616 | code6_IR_carrier_on array [64-79] | |
102 | 1632 | code6_IR_carrier_on array [80-95] | |
103 | 1648 | code6_IR_carrier_on array [96-111] | |
104 | 1664 | code6_IR_carrier_off array [0-15] | |
105 | 1680 | code6_IR_carrier_off array [16-31] | |
106 | 1696 | code6_IR_carrier_off array [32-47] | |
107 | 1712 | code6_IR_carrier_off array [48-63] | |
108 | 1728 | code6_IR_carrier_off array [64-79] | |
109 | 1744 | code6_IR_carrier_off array [80-95] | |
110 | 1760 | code6_IR_carrier_off array [96-111] | |
111 | 1776 | ||
112 | 1792 | code_7_IR_remote | code7_IR_carrier_freg_and_unit_interval |
113 | 1808 | code7_IR_carrier_on array [0-15] | |
114 | 1824 | code7_IR_carrier_on array [16-31] | |
115 | 1840 | code7_IR_carrier_on array [32-47] | |
116 | 1856 | code7_IR_carrier_on array [48-63] | |
117 | 1872 | code7_IR_carrier_on array [64-79] | |
118 | 1888 | code7_IR_carrier_on array [80-95] | |
119 | 1904 | code7_IR_carrier_on array [96-111] | |
120 | 1920 | code7_IR_carrier_off array [0-15] | |
121 | 1936 | code7_IR_carrier_off array [16-31] | |
122 | 1952 | code7_IR_carrier_off array [32-47] | |
123 | 1968 | code7_IR_carrier_off array [48-63] | |
124 | 1984 | code7_IR_carrier_off array [64-79] | |
125 | 2000 | code7_IR_carrier_off array [80-95] | |
126 | 2016 | code7_IR_carrier_off array [96-111] | |
127 | 2032 |
After defining this memory map I started to write a function that would take the measured and encoded data and store it in one of the 8 blocks that I defined in the memory map. Here is the function that writes data into the EEPROM. The writing is done row by row, so this function had to rearrange the input data in row format and then write each row in the corresponding memory block.
Function to write array into memory:
void storedata_in_eeprom (uint8 aval[224], uint8 freqcarrier, uint16 unit, uint16 unittrim, uint8 locationnumber)
{
/*EEPROM_Start();*/
/*cystatus eraseStatus;*/
cystatus writeStatus;
uint8 eepromlocation = locationnumber;
uint8 freqeeprom = freqcarrier;
uint8 unit_lower = (unit & 0xF);
uint8 unit_upper = (unit >> 8);
uint8 unittrim_lower = (unittrim & 0xF);
uint8 unittrim_upper = (unittrim >> 8);
uint8 row1_data[SIZEOF_EEPROM_ROW] = {freqeeprom, unit_lower, unit_upper, unittrim_lower, unittrim_upper, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u};
uint8 row2_data[SIZEOF_EEPROM_ROW] = {aval[0], aval[1], aval[2], aval[3], aval[4], aval[5], aval[6], aval[7], aval[8], aval[9], aval[10], aval[11], aval[12], aval[13], aval[14], aval[15]};
uint8 row3_data[SIZEOF_EEPROM_ROW] = {aval[16], aval[17], aval[18], aval[19], aval[20], aval[21], aval[22], aval[23], aval[24], aval[25], aval[26], aval[27], aval[28], aval[29], aval[30], aval[31]};
uint8 row4_data[SIZEOF_EEPROM_ROW] = {aval[32], aval[33], aval[34], aval[35], aval[36], aval[37], aval[38], aval[39], aval[40], aval[41], aval[42], aval[43], aval[44], aval[45], aval[46], aval[47]};
uint8 row5_data[SIZEOF_EEPROM_ROW] = {aval[48], aval[49], aval[50], aval[51], aval[52], aval[53], aval[54], aval[55], aval[56], aval[57], aval[58], aval[59], aval[60], aval[61], aval[62], aval[63]};
uint8 row6_data[SIZEOF_EEPROM_ROW] = {aval[64], aval[65], aval[66], aval[67], aval[68], aval[69], aval[70], aval[71], aval[72], aval[73], aval[74], aval[75], aval[76], aval[77], aval[78], aval[79]};
uint8 row7_data[SIZEOF_EEPROM_ROW] = {aval[80], aval[81], aval[82], aval[83], aval[84], aval[85], aval[86], aval[87], aval[88], aval[89], aval[90], aval[91], aval[92], aval[93], aval[94], aval[95]};
uint8 row8_data[SIZEOF_EEPROM_ROW] = {aval[96], aval[97], aval[98], aval[99], aval[100], aval[101], aval[102], aval[103], aval[104], aval[105], aval[106], aval[107], aval[108], aval[109], aval[110], aval[111]};
uint8 row9_data[SIZEOF_EEPROM_ROW] = {aval[112], aval[113], aval[114], aval[115], aval[116], aval[117], aval[118], aval[119], aval[120], aval[121], aval[122], aval[123], aval[124], aval[125], aval[126], aval[127]};
uint8 row10_data[SIZEOF_EEPROM_ROW] = {aval[128], aval[129], aval[130], aval[131], aval[132], aval[133], aval[134], aval[135], aval[136], aval[137], aval[138], aval[139], aval[140], aval[141], aval[142], aval[143]};
uint8 row11_data[SIZEOF_EEPROM_ROW] = {aval[144], aval[145], aval[146], aval[147], aval[148], aval[149], aval[150], aval[151], aval[152], aval[153], aval[154], aval[155], aval[156], aval[157], aval[158], aval[159]};
uint8 row12_data[SIZEOF_EEPROM_ROW] = {aval[160], aval[161], aval[162], aval[163], aval[164], aval[165], aval[166], aval[167], aval[168], aval[169], aval[170], aval[171], aval[172], aval[173], aval[174], aval[175]};
uint8 row13_data[SIZEOF_EEPROM_ROW] = {aval[176], aval[177], aval[178], aval[179], aval[180], aval[181], aval[182], aval[183], aval[184], aval[185], aval[186], aval[187], aval[188], aval[189], aval[190], aval[191]};
uint8 row14_data[SIZEOF_EEPROM_ROW] = {aval[192], aval[193], aval[194], aval[195], aval[196], aval[197], aval[198], aval[199], aval[200], aval[201], aval[202], aval[203], aval[204], aval[205], aval[206], aval[207]};
uint8 row15_data[SIZEOF_EEPROM_ROW] = {aval[208], aval[209], aval[210], aval[211], aval[212], aval[213], aval[214], aval[215], aval[216], aval[217], aval[218], aval[219], aval[220], aval[221], aval[222], aval[223]};
uint8 rownumber = 0;
if(eepromlocation == 0) rownumber = 0u ;
if(eepromlocation == 1) rownumber = 16u ;
if(eepromlocation == 2) rownumber = 32u;
if(eepromlocation == 3) rownumber = 48u;
if(eepromlocation == 4) rownumber = 64u;
if(eepromlocation == 5) rownumber = 80u;
if(eepromlocation == 6) rownumber = 96u;
if(eepromlocation == 7) rownumber = 112u;
/* Get the die temp. */
if(CySetTemp() == CYRET_SUCCESS)
{
/* Write TestData1 to EEPROM row 0 */
writeStatus = EEPROM_Write(row1_data, rownumber);
writeStatus = EEPROM_Write(row2_data, rownumber+1u);
writeStatus = EEPROM_Write(row3_data, rownumber+2u);
writeStatus = EEPROM_Write(row4_data, rownumber+3u);
writeStatus = EEPROM_Write(row5_data, rownumber+4u);
writeStatus = EEPROM_Write(row6_data, rownumber+5u);
writeStatus = EEPROM_Write(row7_data, rownumber+6u);
writeStatus = EEPROM_Write(row8_data, rownumber+7u);
writeStatus = EEPROM_Write(row9_data, rownumber+8u);
writeStatus = EEPROM_Write(row10_data, rownumber+9u);
writeStatus = EEPROM_Write(row11_data, rownumber+10u);
writeStatus = EEPROM_Write(row12_data, rownumber+11u);
writeStatus = EEPROM_Write(row13_data, rownumber+12u);
writeStatus = EEPROM_Write(row14_data, rownumber+13u);
writeStatus = EEPROM_Write(row15_data, rownumber+14u);
}
/*EEPROM_Stop();*/
}
/* end of function "storedata_in_eeprom" */
After writing this function I looked into how to read back the values. Reading is different than writing; reading can be done at byte level, and I need to read back the infrared carrier frequency, the unit interval used in data encoding (as I showed in the previous blog) and the array of 224 locations that contains the encoded data. I decided to write three functions, one for each of this type of data.
Here is the function that reads the carrier frequency. Basically the function reads the entire first row and then extracts the value from the specific location in the row where the carrier frequency information has been stored. I could have read only the byte that stores that value, but I decided to read the entire row so that I can reuse this piece of code in the other functions.
/* function read frequency from one of the 8 code locations in eeprom */
uint8 read_frequency_from_eeprom (uint8 locationnumber)
{
reg8 * RegPointer;
RegPointer = (reg8 *)CYDEV_EE_BASE;
uint16 Index;
uint8 return_freq;
uint8 eepromlocation = locationnumber;
uint8 row_read[SIZEOF_EEPROM_ROW];
uint16 base_number;
if(eepromlocation == 0) base_number = 0u;/*rownumber = 0u ;*/
if(eepromlocation == 1) base_number = 256u;/*rownumber = 16u ;*/
if(eepromlocation == 2) base_number = 512u;/*rownumber = 32u;*/
if(eepromlocation == 3) base_number = 768u;/*rownumber = 48u;*/
if(eepromlocation == 4) base_number = 1024u;/*rownumber = 64u;*/
if(eepromlocation == 5) base_number = 1280u;/*rownumber = 80u;*/
if(eepromlocation == 6) base_number = 1536u;/*rownumber = 96u;*/
if(eepromlocation == 7) base_number = 1792u;/*rownumber = 112u;*/
/* Read Data */
RegPointer = (reg8 *) CYDEV_EE_BASE + base_number;
for(Index = 0u; Index < SIZEOF_EEPROM_ROW; Index++)
{
row_read[Index] = RegPointer[Index];
}
return_freq = row_read[0];
verfreq2 = return_freq;
return(return_freq);
}
Next, I wrote a function that reads the unit interval. The unit interval is a uint16 type variable, so it is stored in two locations of the first EEPROM row. The function reads these two locations as uint8 values and then combines them into a uint16 variable that is then returned. Here is the function code:
/* function read unit interval from one of the 8 code locations in eeprom */
uint16 read_unitinterval_from_eeprom (uint8 locationnumber)
{
reg8 * RegPointer;
RegPointer = (reg8 *)CYDEV_EE_BASE;
uint16 Index;
uint16 return_unit;
uint8 unit_lower;
uint8 unit_upper;
uint8 eepromlocation = locationnumber;
uint8 row_read[SIZEOF_EEPROM_ROW];
uint16 base_number;
if(eepromlocation == 0) base_number = 0u;/*rownumber = 0u ;*/
if(eepromlocation == 1) base_number = 256u;/*rownumber = 16u ;*/
if(eepromlocation == 2) base_number = 512u;/*rownumber = 32u;*/
if(eepromlocation == 3) base_number = 768u;/*rownumber = 48u;*/
if(eepromlocation == 4) base_number = 1024u;/*rownumber = 64u;*/
if(eepromlocation == 5) base_number = 1280u;/*rownumber = 80u;*/
if(eepromlocation == 6) base_number = 1536u;/*rownumber = 96u;*/
if(eepromlocation == 7) base_number = 1792u;/*rownumber = 112u;*/
/* Read Data */
RegPointer = (reg8 *) CYDEV_EE_BASE + base_number;
for(Index = 0u; Index < SIZEOF_EEPROM_ROW; Index++)
{
row_read[Index] = RegPointer[Index];
}
unit_lower = row_read[1];
unit_upper = row_read[2];
return_unit = 0u;
return_unit = unit_upper;
return_unit = return_unit << 8;
return_unit = return_unit | unit_lower;
return(return_unit);
}
/* end function "read_unitinterval_from_eeprom" */
Next function reads the 224 location array and stores it in a global variable. I tried to return the array but I was not able to write a function that returns an array. All my attempts resulted in compilation errors, but this global variable approach works fine. Here is the function code:
/* function read array from one of the 8 code locations in eeprom */
/* and store values in an array defined in the main section: codebuffer[224] */
/* locationnumber is one of the 8 IR command code locations in eeprom: 0,1,2...7 */
void read_array_from_eeprom (uint8 locationnumber)
{
reg8 * RegPointer;
RegPointer = (reg8 *)CYDEV_EE_BASE;
uint16 Index;
uint8 eepromlocation = locationnumber;
uint8 row_read[SIZEOF_EEPROM_ROW];
uint16 base_number;
uint8 rowincrement;
if(eepromlocation == 0) base_number = 0u;/*rownumber = 0u ;*/
if(eepromlocation == 1) base_number = 256u;/*rownumber = 16u ;*/
if(eepromlocation == 2) base_number = 512u;/*rownumber = 32u;*/
if(eepromlocation == 3) base_number = 768u;/*rownumber = 48u;*/
if(eepromlocation == 4) base_number = 1024u;/*rownumber = 64u;*/
if(eepromlocation == 5) base_number = 1280u;/*rownumber = 80u;*/
if(eepromlocation == 6) base_number = 1536u;/*rownumber = 96u;*/
if(eepromlocation == 7) base_number = 1792u;/*rownumber = 112u;*/
rowincrement = 16;
/* Temporary Read Data from row 0 and write values into array (row1 has the vlues for carrier freq., unit intrval, ... */
RegPointer = (reg8 *) CYDEV_EE_BASE+base_number+rowincrement; /* red row 2; row 1 has carrier freq,...*/
for(Index = 0u; Index < SIZEOF_EEPROM_ROW; Index++)
{
row_read[Index] = RegPointer[Index];
codebuffer[rowincrement*(1 - 1) + Index] = row_read[Index];
temparray[Index] = row_read[Index];
}
/* Read Data from row 2 and write values into array (row1 has the vlues for carrier freq., unit intrval, ... */
RegPointer = (reg8 *) CYDEV_EE_BASE + base_number + 1*rowincrement; /* red row 2; row 1 has carrier freq,...*/
for(Index = 0u; Index < SIZEOF_EEPROM_ROW; Index++)
{
row_read[Index] = RegPointer[Index];
/*codebuffer[rowincrement*(1 - 1) + Index] = row_read[Index];*/
}
/* Read Data from row 3 and write values into array */
RegPointer = (reg8 *) CYDEV_EE_BASE + base_number + 2*rowincrement; /* red row 3; row 1 has carrier freq,...*/
for(Index = 0u; Index < SIZEOF_EEPROM_ROW; Index++)
{
row_read[Index] = RegPointer[Index];
codebuffer[rowincrement*(2 - 1) + Index] = row_read[Index];
}
/* Read Data from row 4 and write values into array */
RegPointer = (reg8 *) CYDEV_EE_BASE + base_number + 3*rowincrement; /* red row 4; row 1 has carrier freq,...*/
for(Index = 0u; Index < SIZEOF_EEPROM_ROW; Index++)
{
row_read[Index] = RegPointer[Index];
codebuffer[rowincrement*(3 - 1) + Index] = row_read[Index];
}
/* Read Data from row 5 and write values into array */
RegPointer = (reg8 *) CYDEV_EE_BASE + base_number + 4*rowincrement; /* red row 5; row 1 has carrier freq,...*/
for(Index = 0u; Index < SIZEOF_EEPROM_ROW; Index++)
{
row_read[Index] = RegPointer[Index];
codebuffer[rowincrement*(4 - 1) + Index] = row_read[Index];
}
/* Read Data from row 6 and write values into array */
RegPointer = (reg8 *) CYDEV_EE_BASE + base_number + 5*rowincrement; /* red row 6; row 1 has carrier freq,...*/
for(Index = 0u; Index < SIZEOF_EEPROM_ROW; Index++)
{
row_read[Index] = RegPointer[Index];
codebuffer[rowincrement*(5 - 1) + Index] = row_read[Index];
}
/* Read Data from row 7 and write values into array */
RegPointer = (reg8 *) CYDEV_EE_BASE + base_number + 6*rowincrement; /* red row 7; row 1 has carrier freq,...*/
for(Index = 0u; Index < SIZEOF_EEPROM_ROW; Index++)
{
row_read[Index] = RegPointer[Index];
codebuffer[rowincrement*(6 - 1) + Index] = row_read[Index];
}
/* Read Data from row 8 and write values into array */
RegPointer = (reg8 *) CYDEV_EE_BASE + base_number + 7*rowincrement; /* red row 8; row 1 has carrier freq,...*/
for(Index = 0u; Index < SIZEOF_EEPROM_ROW; Index++)
{
row_read[Index] = RegPointer[Index];
codebuffer[rowincrement*(7 - 1) + Index] = row_read[Index];
}
/* Read Data from row 9 and write values into array */
RegPointer = (reg8 *) CYDEV_EE_BASE + base_number + 8*rowincrement; /* red row 9; row 1 has carrier freq,...*/
for(Index = 0u; Index < SIZEOF_EEPROM_ROW; Index++)
{
row_read[Index] = RegPointer[Index];
codebuffer[rowincrement*(8 - 1) + Index] = row_read[Index];
}
/* Read Data from row 10 and write values into array */
RegPointer = (reg8 *) CYDEV_EE_BASE + base_number + 9*rowincrement; /* red row 10; row 1 has carrier freq,...*/
for(Index = 0u; Index < SIZEOF_EEPROM_ROW; Index++)
{
row_read[Index] = RegPointer[Index];
codebuffer[rowincrement*(9 - 1) + Index] = row_read[Index];
}
/* Read Data from row 11 and write values into array */
RegPointer = (reg8 *) CYDEV_EE_BASE + base_number + 10*rowincrement; /* red row 11; row 1 has carrier freq,...*/
for(Index = 0u; Index < SIZEOF_EEPROM_ROW; Index++)
{
row_read[Index] = RegPointer[Index];
codebuffer[rowincrement*(10 - 1) + Index] = row_read[Index];
}
/* Read Data from row 12 and write values into array */
RegPointer = (reg8 *) CYDEV_EE_BASE + base_number + 11*rowincrement; /* red row 12; row 1 has carrier freq,...*/
for(Index = 0u; Index < SIZEOF_EEPROM_ROW; Index++)
{
row_read[Index] = RegPointer[Index];
codebuffer[rowincrement*(11 - 1) + Index] = row_read[Index];
}
/* Read Data from row 13 and write values into array */
RegPointer = (reg8 *) CYDEV_EE_BASE + base_number + 12*rowincrement; /* red row 13; row 1 has carrier freq,...*/
for(Index = 0u; Index < SIZEOF_EEPROM_ROW; Index++)
{
row_read[Index] = RegPointer[Index];
codebuffer[rowincrement*(12 - 1) + Index] = row_read[Index];
}
/* Read Data from row 14 and write values into array */
RegPointer = (reg8 *) CYDEV_EE_BASE + base_number + 13*rowincrement; /* red row 14; row 1 has carrier freq,...*/
for(Index = 0u; Index < SIZEOF_EEPROM_ROW; Index++)
{
row_read[Index] = RegPointer[Index];
codebuffer[rowincrement*(13 - 1) + Index] = row_read[Index];
}
/* Read Data from row 15 and write values into array */
RegPointer = (reg8 *) CYDEV_EE_BASE + base_number + 14*rowincrement; /* red row 15; row 1 has carrier freq,...*/
for(Index = 0u; Index < SIZEOF_EEPROM_ROW; Index++)
{
row_read[Index] = RegPointer[Index];
codebuffer[rowincrement*(14 - 1) + Index] = row_read[Index];
}
}
/* end function "read_unittrim_from_eeprom" */
After writing these functions I spent a significant time debugging the program to make it work. It was great that I worked on the Cypress CY8CKIT-001 evaluation board. Without this board I don’t think I cold have done this task. The debugger in PSoC creator was very useful and also the LCD display of the evaluation board allowed me to write various “debug/test” messages along the code execution time, which give me an insight in what the algorithm and functions do and where problems are.
This is where I’ve gotten so far with developing the code learning algorithm. Next step I’ll need to write a user interface that would select in which location the code will be stored and will provide a way to verify that the code was stored without errors.
That’s it for now; I will come back with a new update as I get more work done.
Best Wishes,
Cosmin