Skip to content
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

Unstable trailing edge of stopbit pulse while using software UPDI I/O #59

Closed
kosilin opened this issue Mar 5, 2022 · 8 comments
Closed

Comments

@kosilin
Copy link

kosilin commented Mar 5, 2022

Good day!

Earlier I spent some time trying to make working UPDI HV mini programmer that I'd made using slightly modified schematics. I'd investigated that updi_io_soft.cpp contains an error (at my sight) that leads to either unstable or completely failed programmer operating.

The problem is that at stop bit transmission UPDI pin is switched to input mode (line 225, updi_io_soft.cpp) just after it has set to "1" (line 214, updi_io_soft.cpp). The trailing edge of the stop bit might not be detected by target device due to very short positive pulse that is damping completely as a fact because of parasitic capacitances. I think it's an issue.

I suggest to add some delay after stop bit transmission. I'm not sure but it seems to be reasonable for me to append the same time as "0" pulse has (txdelay).

At least in my environment the modification has led to stable operating of my UPDI programmer.

This patch is included.
0001-Fixes-unstable-trailing-edge-of-stopbit-pulse-while-using-software-UPDI-IO.txt

Best regards,
Alexey

@ElTangas
Copy link
Owner

ElTangas commented Mar 12, 2022

Thank you. Yes actually I did that on purpose at the time for some reason it seemed like a good idea :P
edit: yeah I remember now, I wanted to return from the transmit function as soon as possible I thought it would matter for performance. But not really.

I think I will add your modification after some tests.

@ElTangas
Copy link
Owner

Just an update, tests are progressing well, I've been able to reproduce your problem by using a 1k resistor and 500pF capacitance in the UPDI line.
A delay of 1/2 bit time seems to be enough, I will run some more tests over the next days.

@kosilin
Copy link
Author

kosilin commented Mar 19, 2022

Thanks! I'm glad that my investigation could help somebody.
But... 500pF seems to be quite large capacitance. What MCU are you using? And what clock frequency?
As for me, my programmer is basing on ATTiny1616 at 20MHz clock.

[upd] I've understood why this happens in my programmer. I made high-voltage model (based on this schematics) that has Zener diode in UPDI circuit. It's 225pF of capacitance (and 1K resistor, yeah). Also BSS84 mosfet is connected to UPDI pin of programmer - 10 pF more (in series of 4.8K of resistance totally).

@ElTangas
Copy link
Owner

But... 500pF seems to be quite large capacitance. What MCU are you using? And what clock frequency?

I increased the capacitance until the problem appeared. It's an artificial experiment.
As you say, the problems start at about 200pF but not always in my case. So I used 500pF to make sure it always fails.

But with the fix it can work even with 1nF :) so thanks.

ElTangas added a commit that referenced this issue Mar 21, 2022
Under certain conditions, the software UART used for UPDI connection could fail, generating a "bad response to enter progmode command: RSP_ILLEGAL_MCU_STATE" error.

For more details see this:
#59

Thanks to https://github.com/kosilin for figuring out the cause of the problem and suggesting a fix.
@ElTangas
Copy link
Owner

Ok, I've updated the code. It's not exactly the same delay you used, but it should work.
I would be grateful if you could test it.

@kosilin
Copy link
Author

kosilin commented Mar 21, 2022

Thanks! I'll test the patch in few days.

@kosilin
Copy link
Author

kosilin commented Mar 22, 2022

Hello!

I've just tested the patch - everything is ok. My opinion... At one hand the delay can be much less in principle. But at the other hand the target will not begin transmission before time of two stop bits has expired. So I think the applied delay is quite reasonable.

As an illustration i've included the picture from my oscilloscope:
DS1ET203908622_0

I think the issue is solved. Thank you very much!

Best regards,
Alexey

@ElTangas
Copy link
Owner

Cool. I'll close it then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants