Regarding SD royalties check out this post.
Do I need to pay SD Royalties
Most decent companies will offer samples of their products. You won't lose out by asking and most vendors understand that developers need samples before committing to a large purchase.
Note that I believe some vendors may have already paid the SD royalty cost so it would be in your interest to ask your memory supplier if royalties are required, otherwise you may just end up topping up the SD association's bank balance for no good reason.
EMMc cards appear to be very very fast although because they are new and haven't yet been widely adopted like SD cards are at the present...you'd need to weight that up in your design.
Hope it helps.
Are you sure you need to exit at ANY time wherever the execution pointer is? Normally, you could just check the button press at the end of the while
and for
loops and call return
when it is pressed.
Sometimes we think our program has to do something and break out of execution, but upon careful examination, we conclude that it can finish one loop interation and then quit.
Could you tell us what's done inside the loops, so we can make sure what's needed?
Edit: As I suspected, the problem with your program is that your delay intervals are too long, e.g. delay(1000)
and delay(500)
, and you can't check for button presses while the program is waiting.
To fix that, create the following function, that will replace your calls to delay:
// waits for the specified miliseconds
// or return (almost) immediately if button is pressed
// return value indicates whether button was pressed or not
boolean waitOrButtonPressed(int miliseconds) {
for (int i = 0; i < miliseconds / 10; i++) {
if (readButtons(5)) == 5)
return true;
delay(10);
}
return false;
}
Then, inside your for
loop, replace your calls to delay(1000)
by the following code:
if (waitOrButtonPressed(1000)) return;
The function I created will make your program wait almost like delay()
, but will return true
if a button was pressed during that time. If that happens, the if
statement above will exit loop()
which will be called again by the Arduino generated code.
Remember to keep the miliseconds to wait when you replace your calls to delay()
to keep your program waiting behavior unchanged.
Edit 2: Ramblings
Cases like this remind me of the movie Tron, in which the main character is dragged into a computer, where time passes much slowlier than in real life. So, like in the movie, 1000 miliseconds (1s) is a LOT OF TIME for the MCU. You can do a whole lot more than waiting in that time. Try and break up the long Waits and do useful stuff with your MCU cycles.
Also, learn how to use interrupts, like others mentioned in their comments and answers. It's just another (a bit more complicated) way of doing stuff while you wait. In your case, interrupts could be use to detect the button press without the need to check it everytime everywhere. Here's a place to start learning about interrupts with Arduino.
Best Answer
You are getting ahead of yourself.
First specify what exactly needs to be stored with what precision and range. Does it really need to be floating point? Very likely you don't need either the resolution or dynamic range, probably neither.
For example, if these are voltage measurements from 0-10 V measured with a 12 bit A/D, then you don't have more than 12 bits of real information. In this example, you could store the raw A/D readings directly, or use a common format like integer millivolts.
Added
You now say these values are derived from 24 bit A/D readings. If storage size is important, you can use a 24 bit representation (Are all 24 bits really meaningful? Probably not) and store two of them every 3 words. For more convenience but 1/3 more memory usage, use two whole words for each reading. I'd pick a convenient unit and zero offset and store the readings as 32 bit integers. Floating point is a bit silly in this case, but that's only 32 bits too.
Either way you have 32 bits, or two words, to write to the non-volatile memory for each reading. In any case, I fail to see a problem here. It doesn't matter whether you write the two words in high-low or low-high order as long as you are consistant and the reader follows the same scheme. Again, what exactly is the problem?