Pages: [1]   Go Down
Author Topic: Due Flash Memory  (Read 342 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

I have a collection of short music samples and effects for a board game. The sounds don't change and would ideally be included with a sketch at compile time.

I would like to burn then into the DUE from the IDE and then read the audio data from FLASH whilst the program is running.

Is this possible?

Thanks
Pascal
Logged

The Netherlands
Offline Offline
Full Member
***
Karma: 1
Posts: 124
MKDS hacker and Programmer
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

I have a collection of short music samples and effects for a board game. The sounds don't change and would ideally be included with a sketch at compile time.

I would like to burn then into the DUE from the IDE and then read the audio data from FLASH whilst the program is running.

Is this possible?

Thanks
Pascal
You need to do it like this:
Code:
const byte sound[something] =
{
Data here
};
Logged

Subscribe my youtube channel: http://www.youtube.com/user/MKDS3

Offline Offline
God Member
*****
Karma: 32
Posts: 506
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Do you mean like including a binary file into a sketch? I've done it on Linux using inline assembler, I don't know if the same trick will work on Windows or Mac though.

Code:
extern char binfile[];
 asm(   "\n.section .text\n.globl binfile \n binfile : \n.incbin \"/home/user/full/path/to/sketch/file.bin\" \n");

void setup() {
  Serial.begin(115200);
  char tmp[1000];
  for(int i=0;i<999;i++)tmp[i]=*(binfile+i);
  tmp[999]=0;
  Serial.println(tmp);
  Serial.println((long)binfile,HEX);
}

void loop() {
}
Logged


Pages: [1]   Go Up
Jump to: