Reputation: 1
#include "mbed.h"
DigitalOut gpo(PTD7);
AnalogOut Aout(PTE30);
float x;
unsigned int i,j;
int main() {
x=0;
i=0;
while(1) {
gpo=i & 1;
x=16*2047.0*(1+sin(2*3.142*i/64));
j=x;
Aout.write_u16(j);
i++;
}
}
This code is supposed to produce a sine wave from the DAC. The microcontroller I'm using is 16 bits while the DAC that the information is being sent to is 12 bits. The line x=... is the equation for a sine wave and produces new values for a sine wave every loop. Can someone explain why we need to multiply the value by 16*2047? like how does this help calibrate the waveform ?
Upvotes: 0
Views: 422