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
fix(swan_r5): 3v3 was enabled but then immediately reset. #6458
Conversation
…alization to `reset_board` which happens after `reset_all_pins`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want CircuitPython to reset the pin? You can "never_reset" it so that CircuitPython leaves it alone.
Thanks for the suggestion! I tried playing with the |
Could you cancel the running checks and restart please? I pushed the pre-commit suggested fixes. I really need to add the precommit hook to my local repo. Doing that now... |
Just thinking aloud here, the functionality that would be ideal in this case is along these lines
In essence, that would allow the board to setup some pins while also allowing scriptable changes. |
I've done some testing with mat's script and his PR changes and for what it's worth this is what I found:
|
@RetiredWizard Thanks for taking the time to test these changes! If there's no load on the 3V3 pin then the discharge will take some time. I had a LED hooked up and saw it blink without a slow discharge, although in testing I needed to allow several tenths of a second for full discharge. Your setup may require a larger I didn't see the USB terminal hang completely - Ctrl-C works, as does making a change to Thanks again for testing! |
Ah, I think the claiming may be an STM port quirk. I don't think that's true on other ports.
I think the best option is that you have a static DigitalInOut object that you add to the Some, ESP ports do have board specific pin reset state but I don't think that's what you want. |
@m-mcgowan I'll do some more testing later tonight, but on a hunch I connected up to the microcontroller using a "screen" terminal from Linux rather than the puTTY terminal from Windows 8 and I don't seem to have the terminal window hang. I have to do some more careful testing but when I let the script run through Windows/puTTY the voltages continued to alternate after the terminal froze for a minute or two and then everything seemed to halt. Perhaps filling up the output buffer to the terminal caused that. In any case, from the screen/Linux connection the script seems to run indefinitely without issues and can be exited with a ctrl-C |
@m-mcgowan I've run the script on both the clean 8.0.0 (from a couple days ago) and with these PR changes edited from both puTTY on the PC and a Screen terminal from on Linux. Here are the results: CLEAN BUILD FROM REPOSITORY: On PC: (bootloader issue?)
on reset 3v3 pin goes to 3Volts but drops slowly unless an LED attached in which case drops rapidly to about 1.5V and Running Script:
reset board and reran script
On Linux:
on reset 3v3 pin goes to 3Volts but drops slowly unless an LED attached in which case drops rapidly to about 1.5V and Running Script:
BUILD WITH PULL REQUEST INCLUDED: On PC: Same bootloader issues requiring copying UF2 file twice. on reset 3V3 pin goes high and stays there with LED connected Running Script: 3 to 5 print statements print but other than that script behaves exactly as it did in the clean build version On Linux: Same bootloader issue requiring copying the UF2 file twice On reset 3v3 output goes to 3.3V and stays there with an LED attached. Running Script: Initial print statements worked this time but other than that script behaves exactly as it did in the clean build version |
Thanks for the detailed reply - all makes sense. I wanted to create a |
So what you'd do is have a globally allocated // Allocate the global instance struct. Usually this happens on micropython heap but nothing cares
// if it actually is on it. (Though you do need be careful that it doesn't use the heap.)
digitalio_digitalinout_obj_t power_pin;
// when you init
power_pin.base.type = &digitalio_digitalinout_t;
// then use the common_hal with it
common_hal_digitalio_digitalinout_construct(&power_pin, &pin_PE06);
common_hal_digitalio_digitalinout_never_reset(&power_pin);
// in pins.c
{ MP_ROM_QSTR(MP_QSTR_DISCHARGE_3V3), &power_pin }, |
@RetiredWizard from what I understand from your testing, there are issues relating to the bootloader and USB handling which I don't believe are caused by this PR (from A/B testing with and without this PR.) To narrow the focus of this PR to just the 3V3 output, I'll add new issues to track the bootloader and USB behavior. |
@m-mcgowan I can't seem to recreate the bootloader issue I was having when I did the earlier testing. I would hold off on the new issue unless you see the same behavior. If it pops up again for me, I'll try and figure out what the trigger is and open an issue on it if I can make it repeatable. |
Here's the updated test script - the main change is that we don't need to wrap the pins in a DigitalInOut instance. Also the discharge pin is kept as open drain while discharging so that discharging can complete fully.
|
I built the new PR files into the CP 8.0.0-alpha.1 tag and ran Mat's new script and the voltage now swings between 3.3V and 0V, with or without an LED attached to the 3v3 output. |
Thanks for testing again @RetiredWizard - the PR is ready to merge. 🎉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Problem
The 3v3 output was active only for a brief period.
Solution
Move
initialize_discharge_pin()
toreset_board
which happens afterreset_all_pins
so that the 3v3 output remains active.Test Code