Hello all -- we're attempting to develop a rudimentary DSP system on the mBed as part of our second-year university project. We're using a Ticker with the following function to grab data from the ADC and bung it into a circular buffer (and the inverse with the DAC):
CircularBuffer inBuffer(1024), outBuffer(1024);
AnalogIn in(p20);
AnalogOut out(p18);
void pushPull() {
inBuffer.writeShort(in.read_u16() - SHRT_MAX);
out.write_u16(outBuffer.readShort() + SHRT_MAX);
}
We then have the main loop of our program take a window of audio from the in buffer, manipulate it, and write it to the out buffer. We've been cuckolded by the mBed's software floats, to the point where we can't even use a sin() call in our code for fear of introducing all sorts of mad (and strange-sounding) rounding errors, so everything's in short ints.
My question is: how fast can we clock a Ticker object? We've got it chugging along happily at about 80us now (but with some strange noise artefacts that might be inevitable). The problem is, we want a sample rate of about 32kHz, which is a period of 31.25us. Whenever I try to set the Ticker's interval to that kind of value, it seems like the mBed is so overwhelmed by the stress of interrupting so regularly that no other code gets executed!
Can anyone suggest a solution to this issue?
Hello all -- we're attempting to develop a rudimentary DSP system on the mBed as part of our second-year university project. We're using a Ticker with the following function to grab data from the ADC and bung it into a circular buffer (and the inverse with the DAC):
We then have the main loop of our program take a window of audio from the in buffer, manipulate it, and write it to the out buffer. We've been cuckolded by the mBed's software floats, to the point where we can't even use a sin() call in our code for fear of introducing all sorts of mad (and strange-sounding) rounding errors, so everything's in short ints.
My question is: how fast can we clock a Ticker object? We've got it chugging along happily at about 80us now (but with some strange noise artefacts that might be inevitable). The problem is, we want a sample rate of about 32kHz, which is a period of 31.25us. Whenever I try to set the Ticker's interval to that kind of value, it seems like the mBed is so overwhelmed by the stress of interrupting so regularly that no other code gets executed!
Can anyone suggest a solution to this issue?