mikronauts wrote: ↑Wed Feb 05, 2020 8:53 pm
Excellent work!
You must be sampling faster than 20Mhz to see a 20Mbps uart...
Thank you.
Yes, If you are working on
analog signals, you are correct. You need sample at least 4 times faster than signal you gonna analyze for proper sampling.
But if you are gonna sample
digital signals... Nope. You can sample at (exactly) same speed.
If two sampling clocks are exactly in same speed, they will be
synchronized and you can analyze/capture the transmission.
But if there is a slight de synchronization, result is not looks like what you expect.
Since I sampling using DMA and clock generated by ESP32's hardware and is exactly 20Mhz (and minimal jitter on it), I could read precise 20Mbaud digital transmissions. And ESP8266 send TX burst via Hardware (again, no jitter and in exact 20Mhz clock), viola!
At top, 10Mbaud signal, at bottom 20Msps one. On 20Msps UART signal, there are some minor errors on stopbits section but transmission captured value is correct.
And here is the ESP8266 code which I generate signal from,
DIY and see if you could.
#include "sigma_delta.h"
#include <ESP8266WiFi.h>
#include <ArduinoOTA.h>
#include <WiFiManager.h>
const char* host_name = "esp8266-TestSignal";
//#define SignalBaud 2304000 // 2M baud!
//#define SignalBaud 4000000 // 4M baud!
//#define SignalBaud 4608000 // 4M baud!
//#define SignalBaud 8000000 // 8M baud!
#define SignalBaud1 10000000 // 10M baud!
//#define SignalBaud 16000000 // 16M baud!
#define SignalBaud2 20000000 // 10M baud!
#define SignalFreq 1000000 //1M
//#define SignalFreq 2000000 //2M
//#define SignalFreq 10000000 //10M
//#define SignalFreq 20000000 //20M
byte xbyte;
void setup() {
Serial.begin(115200);
Serial1.begin(SignalBaud1);// 8M baud!
Serial.println("\r\n\r\n\r\n");
Serial.println("ESP8266 TestSignal");
Serial.println("Connecting...");
WiFi.mode(WIFI_STA);
WiFiManager wifiManager;
wifiManager.setConfigPortalTimeout(600);
if (!wifiManager.autoConnect()) {
Serial.println("failed to connect and hit timeout");
//reset and try again.
ESP.reset();
delay(1000);
}
WiFi.hostname( host_name );
WiFi.setSleepMode( WIFI_LIGHT_SLEEP );
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
ArduinoOTA.setHostname(host_name);
ArduinoOTA.begin();
//Serial.println("Turn of built in LED.");
//digitalWrite(BUILTIN_LED, HIGH);//Turn off led
pinMode(4, OUTPUT);
uint32_t SigmaDeltaPin = D6;
int prescaler = 8;
int SigmaDeltaChannel = 0;
int freq = sigmaDeltaSetup(0, SignalFreq);
prescaler = 80000000/SignalFreq;
sigmaDeltaAttachPin(SigmaDeltaPin); // D6
//sigmaDeltaWrite(SigmaDeltaChannel, 1);
sigmaDeltaWrite(SigmaDeltaChannel, 125);
sigmaDeltaSetPrescaler(prescaler); // 80Mhz / prescaler
Serial.printf("\n\n\nSigmaDelta PWM working on port D6 with Freq of %0.2f Mhz\r\n", SignalFreq/1000000.0);
Serial.println("Starting Test signal on Serial1 (D4)");
Serial.println("Setting GPIO4 HIGH while sending.");
Serial.printf("SignalBaud from Serial1 TXD using %d baud\r\n", SignalBaud1 );
Serial.printf("SignalBaud from Serial TXD using %d baud\r\n", SignalBaud2 );
Serial.println("Closing terminal.");
Serial.flush();
Serial.end();
xbyte=0;
Serial.begin(SignalBaud2);
}
uint32_t w=0;
void loop() {
if((w++%100)==0) //To reduce wait between samples.
ArduinoOTA.handle();
digitalWrite(4, HIGH );
Serial1.write(xbyte);
Serial.write(xbyte++);
digitalWrite(4, LOW );
}