Help with debuging a for statement in BluePill
Hi, I'm using a base64 library to convert my data to my base64 on STM BluePill. everything works fine, but after 5 minutes i receive an imprecise data access violation hard fault error on a for statement. i'm using main loop to run my code every 1 second for testing :
while (1)
{
char string[] = "Hello world!";
sendMessage(string, sizeof(string));
printf("dec:");
count++;
HAL_Delay(1000);
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
and this is the encode function:
char *out;
size_t elen;
size_t i;
size_t j;
size_t v;
if (in == NULL || len == 0)
return NULL;
elen = b64_encoded_size(len);
out = malloc(elen+1);
out[elen] = '\0';
for (i=0, j=0; i<len; i+=3, j+=4) { <------------------- hard fault on this line
v = in[i];
v = i+1 < len ? v << 8 | in[i+1] : v << 8;
v = i+2 < len ? v << 8 | in[i+2] : v << 8;
out[j] = b64chars[(v >> 18) & 0x3F];
out[j+1] = b64chars[(v >> 12) & 0x3F];
if (i+1 < len) {
out[j+2] = b64chars[(v >> 6) & 0x3F];
} else {
out[j+2] = '=';
}
if (i+2 < len) {
out[j+3] = b64chars[v & 0x3F];
} else {
out[j+3] = '=';
}
}
return out;
i really don't know whats the problem. thanks for your help and your time.
