I'm trying to print arrays with 256 integers.
I used PlatformIO IDE(VSCode extension), and TeraTerm to print. Selected Board is HiFive1 Rev B(SiFive), and used Freedom E SDK framework.(Of course, I've connected Rev B board to my PC.)
Here is the structure of the array.
typedef struct {
int32_t coeffs[N];
} poly;
where N is 256.
Then I made a simple C code below to test the structure.
int main() {
poly a, b;
printf("init poly...\n");
for(int i = 0; i < N; i++){
a.coeffs[i] = 0x01;
b.coeffs[i] = 0x02;
printf("%d: %08lX %08lX\n", i, a.coeffs[i], b.coeffs[i]);
}
printf("init END...\n");
printf("for start...\n");
for(int j = 0; j < N; j++){
printf("%08lX %08lX\n", a.coeffs[j], b.coeffs[j]);
if (j % 16 == 15) {
printf("\n");
}
}
}
Here, N is 256 again.
Build and Upload have done successfully, but I got weird outputs from the code.
Here is the output printed at TeraTerm.
init poly...
0: 00000001 00000002
1: 00000001 00000002
2: 00000001 00000002
...(skipped)
188: 00000001 00000002
189: 00000001 00000002
190: 00000001 00000002
191: 00000001 00000002
As you can see, the expected output after printf("init END...\n");
did not appear.
Also, the first for loop looks like 'stopped' after i=192
.
I don't think the stack size cause this issue. Because I modified platformio.ini
file like below.
[env:hifive1-revb]
platform = sifive
framework = freedom-e-sdk
board = hifive1-revb
monitor_speed = 115200
; Configure stack size
board_build.freedom-e-sdk.heap_size = 0x3000
So I can use 99.4% of the RAM size(used 16288 bytes from 16384 bytes).
But when I use variable a
only in the main
(deleting variable b
), then I can get the expected outputs.
How can I solve this problem? Can't I check the outputs from several arrays with 256 entries?