cmaglie / FlashStorage

A convenient way to store data into Flash memory on the ATSAMD21 and ATSAMD51 processor family
203 stars 69 forks source link

840 byte struct can crash function ? #33

Open gioreva opened 4 years ago

gioreva commented 4 years ago

Can crash ?

Cpu is ARM SAMD and has 32KB of RAM

#include <FlashStorage.h>
Tbb Timer;
FlashStorage(Tim, Tbb);

Timer = Tim.read();

typedef  struct {
  byte L_on1_H;
  byte L_on1_M;
  byte L_of1_H;
  byte L_of1_M;
  byte L_on2_H;
  byte L_on2_M;
  byte L_of2_H;
  byte L_of2_M;

  byte M_on1_H;
  byte M_on1_M;
  byte M_of1_H;
  byte M_of1_M;
  byte M_on2_H;
  byte M_on2_M;
  byte M_of2_H;
  byte M_of2_M;

  byte Me_on1_H;
  byte Me_on1_M;
  byte Me_of1_H;
  byte Me_of1_M;
  byte Me_on2_H;
  byte Me_on2_M;
  byte Me_of2_H;
  byte Me_of2_M;

  byte G_on1_H;
  byte G_on1_M;
  byte G_of1_H;
  byte G_of1_M;
  byte G_on2_H;
  byte G_on2_M;
  byte G_of2_H;
  byte G_of2_M;

  byte V_on1_H;
  byte V_on1_M;
  byte V_of1_H;
  byte V_of1_M;
  byte V_on2_H;
  byte V_on2_M;
  byte V_of2_H;
  byte V_of2_M;

  byte S_on1_H;
  byte S_on1_M;
  byte S_of1_H;
  byte S_of1_M;
  byte S_on2_H;
  byte S_on2_M;
  byte S_of2_H;
  byte S_of2_M;

  byte D_on1_H;
  byte D_on1_M;
  byte D_of1_H;
  byte D_of1_M;
  byte D_on2_H;
  byte D_on2_M;
  byte D_of2_H;
  byte D_of2_M;

} Taa;  // 8x7 = 56 byte.

typedef  struct {
    Taa Giorno[15];
  byte AutoZero;

} Tbb; // 56 x 15 = 840 bytetypedef  struct {
  byte L_on1_H;
  byte L_on1_M;
  byte L_of1_H;
  byte L_of1_M;
  byte L_on2_H;
  byte L_on2_M;
  byte L_of2_H;
  byte L_of2_M;

  byte M_on1_H;
  byte M_on1_M;
  byte M_of1_H;
  byte M_of1_M;
  byte M_on2_H;
  byte M_on2_M;
  byte M_of2_H;
  byte M_of2_M;

  byte Me_on1_H;
  byte Me_on1_M;
  byte Me_of1_H;
  byte Me_of1_M;
  byte Me_on2_H;
  byte Me_on2_M;
  byte Me_of2_H;
  byte Me_of2_M;

  byte G_on1_H;
  byte G_on1_M;
  byte G_of1_H;
  byte G_of1_M;
  byte G_on2_H;
  byte G_on2_M;
  byte G_of2_H;
  byte G_of2_M;

  byte V_on1_H;
  byte V_on1_M;
  byte V_of1_H;
  byte V_of1_M;
  byte V_on2_H;
  byte V_on2_M;
  byte V_of2_H;
  byte V_of2_M;

  byte S_on1_H;
  byte S_on1_M;
  byte S_of1_H;
  byte S_of1_M;
  byte S_on2_H;
  byte S_on2_M;
  byte S_of2_H;
  byte S_of2_M;

  byte D_on1_H;
  byte D_on1_M;
  byte D_of1_H;
  byte D_of1_M;
  byte D_on2_H;
  byte D_on2_M;
  byte D_of2_H;
  byte D_of2_M;

} Taa;  // 8x7 = 56 byte.

typedef  struct {
    Taa Giorno[15];
  byte AutoZero;

} Tbb; // 56 x 15 = 840 byte