//Machine Vars For Save/Restore struct MachVars { byte save_valid; // marks if the save flash has been written unsigned long slope[9]; // slope corrections unsigned long offset[9]; // offset corrections unsigned int seq[8][64][8]; // Main preset setting unsigned int encseq[8][64][8]; // Stores offsets from encoder byte gateseq[8][64][8]; // Stores offsets from encoder } saves; // the call to save to flash writePageOfBytes(0,&saves,256); void writePageOfBytes(uint32_t addr, const void* buf, uint16_t len) { for (uint16_t i = 0; i < len; i++) { SPI.transfer(OUT_DAC_CS,((uint8_t*) buf)[i] ); }
I need to store some variables in a flash chip which takes pages of 256 bytes. My thought was to set a pointer of type uint8_t to the beginning of the structure then step through it. I have verified the flash and the read/write routines work with test data in arrays. But when I use the pointer to the above structure the data gets messed up, the values appear scrambled. It looks like it should work to me. What am I missing?