I am currently working on a library to generate arrays of sampled data to be put into an FFT.
Because the standard analogRead is too slow for this purpose (i need to get a good-enough representation of the signal up to 2 kHz), i want to do it using DPM and the ADC in Free-running mode.
This - of course - requires an ISR(ADC_vect), which is no problem in a normal project. But because my code is quite big (the Arduino will serve as the nerve center of a bigger project), I want to pack it into a library.
But I have absolutely no clue how to use C- interrupts in there (and I can also not find any existing threads - they are all using the Arduino methods). Any suggestions?
I would have probably noticed once the compiler got to it, but thank you.
Error message is (put into braces because yes):
C:\Users\------\AppData\Local\Temp\ccqQfOMg.ltrans0.ltrans.o: In function `__vector_21':
sketch/AnalogSignalAquisition.cpp:29: undefined reference to `AnalogSignalAquisition::_samples'
sketch/AnalogSignalAquisition.cpp:29: undefined reference to `AnalogSignalAquisition::_samples'
sketch/AnalogSignalAquisition.cpp:29: undefined reference to `AnalogSignalAquisition::_numSamples'
sketch/AnalogSignalAquisition.cpp:29: undefined reference to `AnalogSignalAquisition::_numSamples'
C:\Users\Daniel\AppData\Local\Temp\ccqQfOMg.ltrans0.ltrans.o: In function `getSamples':
sketch/AnalogSignalAquisition.cpp:23: undefined reference to `AnalogSignalAquisition::_samples'
sketch/AnalogSignalAquisition.cpp:23: undefined reference to `AnalogSignalAquisition::_samples'
sketch/AnalogSignalAquisition.cpp:24: undefined reference to `AnalogSignalAquisition::_numSamples'
sketch/AnalogSignalAquisition.cpp:24: undefined reference to `AnalogSignalAquisition::_numSamples'
collect2.exe: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino/Genuino Uno.
FYI: __vector_21 is ADC_vect
Also, I just noticed that all access to those variables is unsuccessful. I can't remember this being the case earlier, but I don't know how to solve it, so I guess it's part of the question now...
EDIT: To get this error message, I also removed the static modifiers from the two methods (not from the variables, tho)!
I might have found a workaround without using the ISR.
I will have to look a bit more into Arduino library programming, as you can see, I don't really know what I'm doing...
Still, if anyone has resources about using an ISR inside a library (or just tips if it's just like any other method), I'm open for suggestions.
Thank you for all your help!
EDIT: I am just an idiot. The giant drop in sampling frequency didn't come from the lack of the ISR (even though that did slow things down a bit), but from me printing every time a sample was collected instead of waiting till the end.