Skip to content

Using EEWrapto store array in EEPROM #3

Description

@MCUdude

Hi!
I'm doing a project where I want to store some parameters to the EEPROM in case of power loss. The data is JSON formatted, and stores data for an audio DSP.

I created this simple program as a test. However, the microcontroller (ATmega32, doesn't really matter) hangs before it gets to the printing part. If I comment out dsp.vol and dsp.eq_band1 strcyp part, it works fine.

I'm sure I'm doing something wrong here, but I can't figure out what. Do you have any idea whats wrong?

Thanks 😃

#include <EEPROM.h>
#include <EEWrap.h>

//Struct to store DSP data
struct dspData {
  char* eq_band1;
  char* vol;
  char* mux;
};

dspData dsp EEMEM; //EEMEM tells the compiler that the object resides in the EEPROM

void setup(){
  // Init
  Serial.begin(9600);
  Serial.println("Begin!");

  // Store data to EEPROM
  strcpy(dsp.mux, "{\"address\":24,\"mux_data\":1}");
  strcpy(dsp.vol, "{\"address\":1,\"volume\":1900000,\"slew\":2048}");
  strcpy(foo.eq_band1, "{\"b0\": 8425988,\"b1\":-16712212,\"b2\":8288286,\"a1\":16712212,\"a2\":-8325666}");
  
  // Print data
  Serial.println(dsp.eq_band1);
  Serial.println(dsp.vol);
  Serial.println(dsp.mux);
}

void loop() {}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions