AnalogIn Example 2 crash with 40000 samples.

14 Mar 2017

I use a modify version of AnalogIn 2 Example to sampling audio from a Nordic nFR52 DK SAADC:

include the mbed library with this snippet

#include "mbed.h"

AnalogIn input(A0);

int main() {
    uint16_t samples[40000];
    
    printf("Recording start:\n\r");
    for(int i=0; i<40000; i++) {
        samples[i] = input.read_u16();
        wait(0.000125f);
    }

    printf("Recording stop and result:\n");
    for(int i=0; i<40000; i++) {
        printf("%d ",samples[i]);
    }
} 

Why the code stop to work with 40000 samples but it's working with 8000?

Thanks in advance

Marco

17 Mar 2017

The nRF52 DK device has 64k byte SRAM on chip and you can not assign 80,000 byte memory in the stack area.