diff --git a/apps/recorder/pcm_record.c b/apps/recorder/pcm_record.c
index 217d276..e5a5107 100644
--- a/apps/recorder/pcm_record.c
+++ b/apps/recorder/pcm_record.c
@@ -127,7 +127,11 @@ static unsigned long pre_record_ticks; /* pre-record time in ticks */
****************************************************************************/

/** buffer parameters where incoming PCM data is placed **/
+#if MEM <= 2
+#define PCM_NUM_CHUNKS 16 /* Power of 2 */
+#else
#define PCM_NUM_CHUNKS 256 /* Power of 2 */
+#endif
#define PCM_CHUNK_SIZE 8192 /* Power of 2 */
#define PCM_CHUNK_MASK (PCM_NUM_CHUNKS*PCM_CHUNK_SIZE - 1)

@@ -168,15 +172,22 @@ static int flood_watermark; /* boost thread priority when here */
#endif

/* Constants that control watermarks */
-#define LOW_SECONDS 1 /* low watermark time till empty */
#define MINI_CHUNKS 10 /* chunk count for mini flush */
#ifdef HAVE_PRIORITY_SCHEDULING
#define PRIO_SECONDS 10 /* max flush time before priority boost */
#endif
-#if MEM <= 16
+#if MEM <= 2
+/* fractions must be integer fractions of 4 because they are evaluated with
+ * X*4*XXX_SECONDS, that way we avoid float calculation */
+#define LOW_SECONDS 1/4 /* low watermark time till empty */
+#define PANIC_SECONDS 1/2 /* flood watermark time until full */
+#define FLUSH_SECONDS 1 /* flush watermark time until full */
+#elif MEM <= 16
+#define LOW_SECONDS 1 /* low watermark time till empty */
#define PANIC_SECONDS 5 /* flood watermark time until full */
#define FLUSH_SECONDS 7 /* flush watermark time until full */
#else
+#define LOW_SECONDS 1 /* low watermark time till empty */
#define PANIC_SECONDS 8
#define FLUSH_SECONDS 10
#endif /* MEM */
@@ -734,7 +745,9 @@ static void pcmrec_refresh_watermarks(void)
logf("ata spinup: %d", storage_spinup_time());

/* set the low mark for when flushing stops if automatic */
- low_watermark = (LOW_SECONDS*4*sample_rate + (enc_chunk_size-1))
+ /* don't change the order in this expression, LOW_SECONDS can be an
+ * integer fraction of 4 */
+ low_watermark = (sample_rate*4*LOW_SECONDS + (enc_chunk_size-1))
/ enc_chunk_size;
logf("low wmk: %d", low_watermark);

@@ -743,8 +756,10 @@ static void pcmrec_refresh_watermarks(void)
this allows encoder to boost with just under a second of
pcm data (if not yet full enough to boost itself)
and not falsely trip the alarm. */
+ /* don't change the order in this expression, PANIC_SECONDS can be an
+ * integer fraction of 4 */
flood_watermark = enc_num_chunks -
- (PANIC_SECONDS*4*sample_rate + (enc_chunk_size-1))
+ (sample_rate*4*PANIC_SECONDS + (enc_chunk_size-1))
/ enc_chunk_size;

if (flood_watermark < low_watermark)
@@ -756,7 +771,7 @@ static void pcmrec_refresh_watermarks(void)
logf("flood at: %d", flood_watermark);
#endif
spinup_time = last_storage_spinup_time = storage_spinup_time();
-
+#if (CONFIG_STORAGE & STORAGE_ATA)
/* write at 8s + st remaining in enc_buffer - range 12s to
20s total - default to 3.5s spinup. */
if (spinup_time == 0)
@@ -765,6 +780,7 @@ static void pcmrec_refresh_watermarks(void)
spinup_time = 2*HZ; /* ludicrous - ramdisk? */
else if (spinup_time > 10*HZ)
spinup_time = 10*HZ; /* do you have a functioning HD? */
+#endif

/* try to start writing with 10s remaining after disk spinup */
high_watermark = enc_num_chunks -
@@ -773,9 +789,9 @@ static void pcmrec_refresh_watermarks(void)

if (high_watermark < low_watermark)
{
+ logf("warning: low 'write at' (%d)", high_watermark);
high_watermark = low_watermark;
low_watermark /= 2;
- logf("warning: low 'write at'");
}

logf("write at: %d", high_watermark);
diff --git a/firmware/export/config/sansac200v2.h b/firmware/export/config/sansac200v2.h
index bf6f460..ff68e97 100644
--- a/firmware/export/config/sansac200v2.h
+++ b/firmware/export/config/sansac200v2.h
@@ -12,7 +12,7 @@
#define HW_SAMPR_CAPS SAMPR_CAP_ALL

/* define this if you have recording possibility */
-//#define HAVE_RECORDING
+#define HAVE_RECORDING

#define REC_SAMPR_CAPS SAMPR_CAP_ALL

diff --git a/firmware/export/config/sansaclip.h b/firmware/export/config/sansaclip.h
index 6cf7ec7..c139d91 100644
--- a/firmware/export/config/sansaclip.h
+++ b/firmware/export/config/sansaclip.h
@@ -12,7 +12,7 @@
#define HW_SAMPR_CAPS SAMPR_CAP_ALL

/* define this if you have recording possibility */
-//#define HAVE_RECORDING
+#define HAVE_RECORDING

#define REC_SAMPR_CAPS SAMPR_CAP_ALL

diff --git a/firmware/export/config/sansam200v4.h b/firmware/export/config/sansam200v4.h
index 9a544ff..fa91631 100644
--- a/firmware/export/config/sansam200v4.h
+++ b/firmware/export/config/sansam200v4.h
@@ -14,7 +14,7 @@
#define HW_SAMPR_CAPS SAMPR_CAP_ALL

/* define this if you have recording possibility */
-//#define HAVE_RECORDING
+#define HAVE_RECORDING

#define REC_SAMPR_CAPS SAMPR_CAP_ALL