Memory problem? with Wio LTE JP version

Hi, everyone,

I made a program that reads 512 sets of accelaration values from ADXL345 accelarometer. Each data set has 3 values (X,Y,Z).
I use a struct like “float accData[512][3]” in a program shown below.

for(i=0;i<512;i++){
// This function stores 3 axis accelaration values to accData[i][0] to [i][2]
read_ADXL(accData[i];
}

My problem is,
When loop time is smaller than 192, it works fine for at least 10 hours.
But when loop time is greater than 192, it just freezes.
I wonder this behavior might be related to memory mapping of Arduino IDE’s linker.

IDE: Arduino IDE version 1.8
Wio LTE for Arduino Library is installed
Board: Seeed Wio LTE is selected.

CPU: STM32F405RG, ARM Cortex-M4, 168MHz
RAM 192kB(Battery-backuped 4KB, Core coupled 64KB, SRAM 128KB)
ROM 1MB

Could you kindly help me? Thank you very much for your help.

Masay0;

Hi @masay0 ,

I use a struct like “float accData[512][3]” in a program shown below.

Did you allocate accData variable in heap area or stack area?
If it is in stack area, it may cause problems.

I tried both, local variable and global one.
I now think I2C interface is too slow for my purpose and I am considering using SPI interface.
Could you provide how to connect Wio LTE with SPI device (wire connection) and how to use it (use spi.h? where I can find appropriate one? how to assign hardware pin to each SPI signal?) .