Hey Guys,
I seem to have a memory problem, I look at the graph provided by the online compiler below and this shows me ive use 1.4k(5%) in memory.
And I also have used show memory function posted in another thread. And call the below whilst the program is running, it would seem that I only have 1.2k left.
Checking memory with blocksize 256 char ...
256 @ 0x10006540
512 @ 0x10006540
768 @ 0x10006540
1024 @ 0x10006540
1280 @ 0x00000000
Ok for 1024 char
So the program was crashing in all time, in different spots. So this lead me to memory issue, ive noticed on multiple write the device will hard fault like its not releasing memory. Here is my write code
int eeprom::write(int address, char *str) {
string s(str);
wp = 0; // disable write protect
int size = (strlen(str)/2) + 2;
char data[size];
data[0] = address >> 8;
data[1] = address ;//& 0xFF; // address is 0x0000, data is 0x5A
for (int i=2; i<size; i++) {
string sub = s.substr(((i-2)*2),2);
const char* pszConstString = sub.c_str ();
int value = (int) strtol (pszConstString,NULL,16);
data[i]=value;
}
if (i2c.write(0xA0, data, size)) {
printf("Write failed\n\r");
}
int poll = 0;
while (i2c.write(0xA0, NULL, 0)) { // wait until we get an acknowledge
poll++;
}
// printf("OK\n\r", poll);
printf("%d %d %d\n\rOK\n\r",data[0],data[1],size);
return 0;
}
I write in 0x2 hex value to get around the RPC class not being able to handle all characters.
I use this method with a static function call exposed as RPC function, for example (BOLD is output)
mcu:rcp /eeprom/write 0 01FD090000000000002A00005365747570566950454328313135323030293B0D53657443414E537065656428362C353030303030290001FD08140000000000AB
0 64 42
OK
mcu:rcp /eeprom/write 64 0000673D727063414E53656E6428362C30783238302C382C307834392C302C302C52536869667428
0 128 66
OK
mcu:rcp /eeprom/write 128 672C38292C52536869667428672C30292C302C302C30293B0D43414E53656E6428362C30783238382C382C307834322C31302C302C302C39352C37372C302C30
Hard Fault!
Jason
Hey Guys,
I seem to have a memory problem, I look at the graph provided by the online compiler below and this shows me ive use 1.4k(5%) in memory.
And I also have used show memory function posted in another thread. And call the below whilst the program is running, it would seem that I only have 1.2k left.
Checking memory with blocksize 256 char ...
256 @ 0x10006540
512 @ 0x10006540
768 @ 0x10006540
1024 @ 0x10006540
1280 @ 0x00000000
Ok for 1024 char
So the program was crashing in all time, in different spots. So this lead me to memory issue, ive noticed on multiple write the device will hard fault like its not releasing memory. Here is my write code
I write in 0x2 hex value to get around the RPC class not being able to handle all characters.
I use this method with a static function call exposed as RPC function, for example (BOLD is output)
mcu:rcp /eeprom/write 0 01FD090000000000002A00005365747570566950454328313135323030293B0D53657443414E537065656428362C353030303030290001FD08140000000000AB
0 64 42
OK
mcu:rcp /eeprom/write 64 0000673D727063414E53656E6428362C30783238302C382C307834392C302C302C52536869667428
0 128 66
OK
mcu:rcp /eeprom/write 128 672C38292C52536869667428672C30292C302C302C30293B0D43414E53656E6428362C30783238382C382C307834322C31302C302C302C39352C37372C302C30
Hard Fault!
Jason