I am doing project about sending a signal onto DAC port at fixed speed. but I get problem now, could anyone help me? Thanks in advance. there is my problem below:
I set a timer before entering interrupt, and set other timer behind finishing interrupt using millis(), and make the interrupt run certain times say 1000 or 24000 or more, and write 1 value onto DAC port every time , . So the real sampling rate is equal to( the difference between two timer)/ the certain time(ms).
So when I test sampling rate in certain condition.
Setting the sampling rate on Arduino 2400 and let the interrupt run 24000 times, and write 1 value every time onto DAC port. So I get the difference between two timers is 10113ms, so the real sampling rate is 2400/10113 *1000 = 2373
so the real value 2373 is different from 2400 which I set before, could anybody know why this difference happens and how could I solve the difference?
also I attach my code about the interrupt below, Thanks again.
Sampling_rate1.ino (4.34 KB)