-
Notifications
You must be signed in to change notification settings - Fork 7.6k
[arduino-esp32 as component in idf hello world] one character 0xFF allways receive and sucks #1061
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
ughhh... things like that are usually caused by unstable UART lines that detect fake data if there is some voltage fluctuation on the pins (you can start UART1 on other pins and try touching them. you will see the same thing to happen). |
:) yes this was my first thinking too so i used and tested:
UARTS:
all with same result. this small pause before start i think it is ok - but the one 0xFF character ( 115200 baud ) sucks |
flush is done here right`? |
Make a loop in setup that eats any initial characters... Serial.begin(115200);
delay(500);
while (Serial.available()) {
char c = Serial.read();
} If its getting in the output buffer the above wont help, neither will Serial.flush() because flush works more like unix drain() in that it just waits for all output to be written out. Flush should really just drop the output buffer completely but thats not how it works on arduino or esp. |
It doesn't affect straight esp-idf.. just tried and got no sign of any garbage characters (lolin32 ch341). I (240) cpu_start: Starting scheduler on PRO CPU. |
@markyad the garbage comes, if you use esp-idf and the arduino as component, did you try this? if yes, which esp-idf version did you use with the arduino component? btw: same one garbage character with this
best wishes |
I just now tried it in arduino as component of esp-idf with 3 different setups mostly different logging and peripheral configs... I (250) cpu_start: Pro cpu start user code Im really stumped now... I used all latest git code and latest xtensa gcc. |
which baudrate you use? |
upload 230400 and monitor 115200. |
txs, you use monitor? |
@markyad 0xff is being generated by a glitch on the tx pin. The UART of the USB Serial converter is seeing a low going pulse that is being interpreted as a Start bit. After the glitch, the TX pin is returning to a high level which the Serial Converter interprets as a 0xFF character. I would recommend you search through the UART init code, compare the differences between your working (ESP-IDF) and non Working (Arduino-esp32). Somewhere in the init code of the the Arduino section the TX pin is being driven Low. We are encountering similar problems with I2C bus initialization. A low going glitch is being created when the GPIO pins are attached to the I2C hardware. Our glitch cause the I2C hardware state machine to lockup, not just output a erroneous character. Chuck. |
all 3 of arduino-ide, esp-idf, and arduino as component are working here with no glitches... I am using miniterm.py python terminal. |
also I tried various uart configs... serial gps connected, nothing connected, and long wires connected to nothing. I never could reproduce it. |
which OS you use - i use windows 7 for this. |
linux ubuntu and usb is through a powered usb hub (esp32 powered by hub). |
Also tried on a non-powered usb port which a usb voltmeter shows supply voltage lagging to 4.9V... still works here lol, I'm stumped. |
@negativekelvin txs! |
@me-no-dev edit:
|
@ESP32DE I'll try that sequence on the I2C init tomorrow. This is what we are currently using in esp32-hal-i2c.c pinMode(scl, OUTPUT_OPEN_DRAIN | PULLUP);
pinMatrixOutAttach(scl, I2C_SCL_IDX(i2c->num), false, false);
pinMatrixInAttach(scl, I2C_SCL_IDX(i2c->num), false); It might work, unless the OPEN_DRAIN causes and issue. Chuck. |
@stickbreaker @me-no-dev |
https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/esp32-hal-uart.c#L156 before ( 0xFF )
after: ( -- )
i think - it is fixed with this Sketch: ( pausing/delay and workaround not more need )
best wishes |
@me-no-dev @stickbreaker |
@ESP32DE Both SDA and SCL are open drain signals. The glitch happens when attaching the GPIO pin to the I2C hardware state machine I haven't tried it yet. I have to setup my test case and unwind my work on Slave mode I2C. I don't want my Slave mode code to interfere with this glitch resolution. I have Tried the Issue #349 has a good scope screen capture of the glitchs when the hardware is init'd. These I2C glitches cause devices on the I2C bus to lockup, sometimes the glitch also hangs the I2C peripheral inside the ESP32 when it does this, sometimes we cannot recover without a powercycle. The signal adjacent to the glitch is our attempt to release the lockup by manually sending a null out the port. One problem with this glitch recovery method, is that the 0x00 will cause a problem if there is a second ESP32 on the I2C bus. The default initial state of the I2C hardware is SlaveMode, Address 0x00. So that initial 'reset' causes the second Slave to jump into a Slave Receive mode. with a zero length packet. This is one of the Issues I am having with my Slave Mode work. When I power cycle my test set, I can get into unconfigured/partially configured/ unstable states. If I could avoid the SDA glitch (which is treated as a START without a STOP) which can create a TIMEOUT cascade Bus hang. My life would be much easier. Chuck. |
@stickbreaker this i2c spice / setup we did talk in esp32.com cause you helped me here with this, first, we must talk simply the base in I2C,
and this result: now cause the Wire.begin() makes here some unlucky things, ok, this helps not how looks this to you ? :) now finaly we go on in Test 3 with this: vola! take this as workaround in the meantime :) let me know, if you need more help or anything and how you go on now. hope you can now go on ( i did simply use a logic anal , i have Rigol here too but i think it is not need for the setup in wire and conversions, if there are spikes in the data conversion, i would use rigol then, let me know ) |
see espressif#1061 here a tested version and an optional suggestion
have phun! |
see talk: espressif#1061 PR on origin master : espressif#1073
nice weekend! |
mhm.. ( you have fully right ) so we need an other setup procedure for this pins what, if we change this setup to a procedure "only for shake each" pins moretimes? |
@stickbreaker comment it simple for a test with your rigol.. test
the zero packet comes from this code:
example: suggest, we change the
code so that we setup all fine but |
@ESP32DE The zero byte output was decided up because as the I2C protocol is defined, no compatible Device may answer to that address. Your decoded I2C display is not showing the electrical signal. It is just showing 'valid' I2C decoding. The hardware glitch we are working around is a very short pulse. in the nanosecond range. I believe your measurement device is suppressing this glitch from being displayed. The issue is that a START condition is defined as SDA going low While SCL is high. A STOP is defined as SDA going High while SCL is High. So, a glitch on SDA (low going pulse while SCL is high creates a null transaction, A START no data bits then a STOP. A NULL transaction is an illegal transaction on the I2C bus. The only guaranteed reset operation to recover from this invalid transaction is to Preform a START, (SDA going low while SCL is HIGH). PULSE SCL low nine times(8bits data one bit ACK) then Preform a STOP( SCL HIGH and then release SDA (Low to High). This operation will reset other devices connected to the I2C bus, but if the I2C StateMachine inside the ESP32 is confused It will disallow operations through itself(Bus Busy state). To reset the Internal hardware the I2C peripheral is disabled and enabled (The glitch is generated when the peripheral is enabled, can you see where this could create an infinite recursion? disable/enable creates a glitch which causes the statemachine to detect a START (bus is now busy), the Bus Busy state is cleared by disable/enable ....) I haven't had a chance to test your solution, setting the output high before attaching the pins. Chuck. |
@ESP32DE A simple bus busy state can be generated by simply grounding SDA while the I2C bus is inactive. Wire up a simple breadboard with an ESP32, some I2C device, an 3.3k pullups to 3.3v. Initialize the Manually stimulate SDA (touch a wire from GND to SDA). Then try to communicate with your I2C device. The ESP32 I2C state machine will be locked up in a bus busy condition, or, perhaps in a re occurring TimeOut loop. Depending on how clean your grounding signal was (how many oscillations SDA went through from High to Low and how they were interpreted by the State Machine,) the state machine could shift into a TimeOut countdown. If it does, every 13.1ms a I2C Timeout interrupt is generated because the state machine does not see any activity on the I2C bus and It "Knows" there is a transaction underway! But nothing is happening! The only current recovery method is either a power Cycle, or peripheral disable/enable that doesn't cause a glitch cascade. Chuck. |
There must be a way to reset the I2C state-machine without having to resort to a reset ... sounds like a sledge hammer to kill a mosquito. |
@stickbreaker btw what if the master send "mistakenly a start?" and so long SDA is on gnd the waittime then for a new try ( 13.1 ms ? ) do then a full reset? the test will be first time between 2 esp32 i will try to use some I2C parts that have different addresses, and not switch enable active by GPIO. @dpharris |
As the main issue was solved (rubbish character after boot) and the I2C core was changed to @stickbreaker code officially after 13dcfe5 (thanks @stickbreaker) with several modifications of the code discussed here. Let's close this old issue and if you still have problems with the new I2C code, open new issues =) |
hi
after a few time i try esp32-arduino core
( last actually version with 490 commits ) with ESP-IDF ( last ESP-IDF version with 4630 commits )
as component for a fun project
i noted that i get allways some rubbish character after boot
the code is simple:
the output:

i change the code then with a delay for enough time give for setup the peripherals
the output is little better only one character on begin sucks
i try then few things but this one character goes not away
but this character sucks allways again
the character is 0xFF ( on baud 115200 )
from where this character comes?
which task has this sign?
why is it here?
can we eliminate it?
thanks
best wishes
The text was updated successfully, but these errors were encountered: