-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Switching between output port and serial port not working. #4198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Adding: I randomly found the fix after looking through pull requests |
Next problem is that its taking 40ms to do Serial2.begin(...) |
Serial.end is fixed in #3894 |
Is the 40ms it takes for Serial.begin() related to this problem too? I have also noticed that the first digitalWrite(LOW) after switching from serial to digital takes a full 10ms. Then when switching back to serial, the begin() method takes 40ms. These timings take microseconds on a real Arduino. |
Hardware:
Board: espressif dev board v4 - ESP32-WROVER-IE 8MB FLASH
Core Installation version: 1.0.3
IDE name: Arduino IDE
Flash Frequency: 40Mhz
PSRAM enabled: no
Upload Speed: 115200
Computer OS: Windows 10
Description:
For my application I need to switch a port pin between being an output port and being a serial port. This is for the automotive k-line protocol - you need to pull the k-line low for 25ms then start sending serial comms 25ms later.
This is the KWP2000 fast-init protocol. And it may need to be re-done if the link times out etc. And I may need to try a different init type if fast-init repeatedly fails, such as KWP2000 slow-init, or ISO9141 5 baud init. I also need to run 2 separate k-lines, which run independently. So as you can see, simply resetting the machine and always stating up with the correct sequence of events won't work. It really needs to be switchable on the fly to properly support the SAE protocol.
The code works fine on an Arduino Mega2650, but on ESP32 it doesn't work.
I made a simple sketch using the blink demo as a base.
I also tried using Serial2 directly without the hardwareSerial instantiation, with the same results. I set up 2 ports in the sketch but specifically I need the Tx port to work "ledPin2".
I really need this to work to be able to adhere to the KWP2000 k-line serial protocol.
Sketch:
The text was updated successfully, but these errors were encountered: