Here's a graph I quickly threw together with Excel.
Does it look at all familiar? Maybe just a little like your last scope capture?
That's because this is what you get when you sample a 13kHz sine wave at 44.41kHz.
What you're seeing is exactly what you should expect to see. What you're definitely not seeing there is aliasing.
When you only sample 3 or 4 ...
You don't need either the 10K or the diode.
The gate is insulated and provided you stay within the Vgs voltage rating, driving it higher than the source will have no ill effects.
Some MOSFETs have gate protection zeners gate to source, but that's calculated into the maximum Vgs rating. Most are rated for at least 8V.
Just make sure your MOSFET is guaranteed ...
When you write if REG & 0x10 you're checking whether bit 4 of the register REG is set.
If the value of REG is 0x30, then bit 4 is set, and you should do the thing you want to do when bit 4 is set.
If the value of the REG is 0x20 then bit 4 isn't set, so you shouldn't do the thing you want to do when bit 4 is set.
And that's exactly the behavior you get ...
Rule of thumb:
Use & when you care about individual bits and only those bits.
Use == when you care about the whole value of a variable.
You can of course also use & to check a whole variable against a mask, and in that case it is almost equivalent to ==. Except & returns either zero or a non-zero value, while == always returns either 0 or 1.
The Arduino analogRead takes 100 microseconds per read. That limits you to a sampling rate under 10kHz. You will never reach your intended 20kHz sampling rate.
The Serial.println takes time. Since you are using it in your sampling loop, it makes the time between samples longer. You will never reach the Arduino's theoretical 10kHz sampling rate.
The Due ...
Look here: -
The most obvious problem is that the enable pin (EN) is floating. Try connecting it to Vin as per the data sheet: -
Other potential issues?
Why haven't you got 220 uF on the output like the data sheet suggests?
What output voltage are you trying to achieve?
What is SW1 all about?
Why haven't you got the recommended input capacitance?
In a word - filtering.
In 2 words - brickwall filter.
brhans is on to something when he answered,
When you only sample 3 or 4 points for every cycle of the sine wave,
you're never going to be able to just push those samples out of a DAC
and expect to see something resembling that original sine wave.
but he's wrong. What you're seeing is an output which has ...
The resolution in volts is the reference voltage of the analog to digital converter (ADC) divided by the number of counts from the ADC.
The input voltage of the signal isn't involved.
Given a 10 bit ADC (1024 counts) and a 5V reference voltage for the ADC, the voltage resolution is 5V/1024 = 4.8828125 millivolts per count.
Your input signal of maximum 1V ...
Generally agree with Spehro answer.
Where multiple DC supplies are involved, consider what happens when one or other is not active. Since your schematic is incomplete, we cannot guess.
Also consider the turn-on condition of the PMOS driver. In most microcontrollers, GPIO pins default power-up condition is to be high-impedance input, not output. So the MOSfet'...
The notation S5, S8, and S9 are times that are shown elsewhere in a table.
S5 looks like the Clock to output data transition time. There are both minimum and maximum times.
S8 is the data setup time for the receiver.
S9 is the data hold time for the receiver.
What you describe as a "Gaussian distribution arrow" are just arrows indicating the times ...
You are mixing two completely different things. Writing data to the register makes it shift out, so there is data available for transmission. The data is shifted out by using the clock signal.
The devices must operate with the clock so that they have a chance to see stable data, i.e. if the master update the data on falling edge of the clock, the slave must ...