I have connected arduino uno with an external dataflash using spi. I have made some tests and everything working good.
Now, in the dataflash i wrote a sound data file, 4118 bytes. I have to run it continuously, but the result is not as good as i had them stored in flash, and read it with progmem. Propably, because the spi speed is low.
I was thinking if i could load it from dataflash to flash, not at the begginig during programming arduino, and read it with Progmem.
Is it feasible?
I 've read that progmem is used once at the beggining but on Progmem description is not clear.
I am not an expert on arduino, i try to learn.
I have done some tests, going step by step, to read the file, but there are many errors and i couldn't compile them.
In the attachment, i try to read one by one the dataflash pages, and stored them as data. Then i want to create the sound_data from them, as this is the sound file i want to play it later.
#include <dataflash.h>
#include <avr/pgmspace.h>
Dataflash dflash;
unsigned char sounddata_data;
unsigned char data_0[],data_1[],data_2[],data_3[],data_4[],data_5[],data_6[],data_7[];
char buffer[30];
void setup()
{
Serial.begin(115200);
Serial.println("Start Reading LF Array... ");
dflash.init();
for (word z =0; z<528; z++){const char data_0[z] PROGMEM = {dflash.ContArrayReadLF(0,z);}}
for (word z =0; z<528; z++){const char data_1[z] PROGMEM = {dflash.ContArrayReadLF(1,z);}}
for (word z =0; z<528; z++){const char data_2[z] PROGMEM = {dflash.ContArrayReadLF(2,z);}}
for (word z =0; z<528; z++){const char data_3[z] PROGMEM = {dflash.ContArrayReadLF(3,z);}}
for (word z =0; z<528; z++){const char data_4[z] PROGMEM = {dflash.ContArrayReadLF(4,z);}}
for (word z =0; z<528; z++){const char data_5[z] PROGMEM = {dflash.ContArrayReadLF(5,z);}}
for (word z =0; z<528; z++){const char data_6[z] PROGMEM = {dflash.ContArrayReadLF(6,z);}}
for (word z =0; z<422; z++){const char data_7[z] PROGMEM = {dflash.ContArrayReadLF(7,z);}}
const char* const sounddata_data[] PROGMEM = {data_0, data_1, data_2, data_3, data_4, data_5, data_6, data_7};
//for (int i = 0; i < 6; i++){strcpy_P(buffer, (char*)pgm_read_word(&(sounddata_data[i]))); }
}
void loop()
{
}