Just want to create signal in gnuradio and send him in Arduino Due with ethernet shield w5100 using TCP protocol, that will be generate signal on DAC0 pin. But I'm stuck more over three days trying resolve this. GRC project has Signal source block (type - byte, frequency - 100Hz, waveform - sine, sampl rate 32000Hz) connected to TCP sink block. Arduino receive signal, but signal from pin DAC looks like square wave. What's wrong? And second question, how is possible to convert 32 bit value to 12 bit in arduino sketch (if choose in gnuradio signal source block float type)?
Arduino sketch:
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 137, 10);
EthernetServer server(8788);
void setup() {
analogWriteResolution(8); // set DAC resolution to 8 bits
Ethernet.begin(mac, ip);
server.begin();
}
void loop() {
EthernetClient client = server.available();
if (client) {
while (client.connected()) {
if (client.available()) {
byte val = client.read();
analogWrite(DAC0, val); // generate signal on DAC0 pin
}
}
client.stop();
}
}