GPIO settings change after USB disconnect, reconnect (caused bympconfigboard.h lines?)

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
User avatar
jgriessen
Posts: 191
Joined: Mon Sep 29, 2014 4:20 pm
Contact:

GPIO settings change after USB disconnect, reconnect (caused bympconfigboard.h lines?)

Post by jgriessen » Sat Aug 11, 2018 5:51 pm

I'm using a STM32F401 platform similar to the G30TH with 512k flash.
Is there anything known about this symptom:

From hardware reset without USB plugged in,
my program starts and port A GPIOs stay as I set them for 60 seconds (more, but I stopped counting)
plug in USB connector port A GPIOs stay as I set them for 60 seconds (more, probably)
run rshell and connect port A GPIOs change.
start repl port A GPIOs stay same (changed from my settings)
<ctl>d port A GPIOs return to as I set them
unplug USB connector port A GPIOs stay as I set them for 60 seconds (more, probably)

Does this trouble sound general, or platform specific?

my boot.py

Code: Select all

# boot.py -- run on boot-up
import machine
import pyb
#pyb.usb_mode('VCP+MSC') # act as a serial and a storage device
pyb.usb_mode('VCP') # act as a serial and not as a storage device
pyb.main('pulser_main.py')
Last edited by jgriessen on Mon Aug 13, 2018 9:37 pm, edited 1 time in total.
John Griessen blog.kitmatic.com

User avatar
dhylands
Posts: 2818
Joined: Mon Jan 06, 2014 6:08 pm
Location: Shuswap, BC, Canada
Contact:

Re: GPIO settings change after USB disconnect, reconnect (with rshell)

Post by dhylands » Mon Aug 13, 2018 3:07 am

rshell issues a few commands when it starts. It calls pyb.RTC or machine.RTC and then issues a datetime command to synchronize the time. It will also access the filesystem (it tries to importthe board module).

Can you be more specific about which exact pins change?

User avatar
jgriessen
Posts: 191
Joined: Mon Sep 29, 2014 4:20 pm
Contact:

Re: GPIO settings change after USB disconnect, reconnect (caused bympconfigboard.h lines?)

Post by jgriessen » Mon Aug 13, 2018 3:07 pm

Can you be more specific about which exact pins change?
Port A 1 and 2. PA1 PA2 go to floating, (probably input), from output.
rshell issues a few commands when it starts. It calls pyb.RTC or machine.RTC
I've seen the port A problem with import also, and rearranged my startup to get all imports done early.
There may be something in micropython that does this in a hard to notice way.
Last edited by jgriessen on Mon Aug 13, 2018 9:38 pm, edited 1 time in total.
John Griessen blog.kitmatic.com

User avatar
dhylands
Posts: 2818
Joined: Mon Jan 06, 2014 6:08 pm
Location: Shuswap, BC, Canada
Contact:

Re: GPIO settings change after USB disconnect, reconnect (with rshell)

Post by dhylands » Mon Aug 13, 2018 7:50 pm

Does your mpconfigboard.h file show anything on either of those pins?

The only way that I know that rshell can effect the hardware is indirectly, through something like LEDs.

User avatar
jgriessen
Posts: 191
Joined: Mon Sep 29, 2014 4:20 pm
Contact:

Re: GPIO settings change after USB disconnect, reconnect (caused bympconfigboard.h lines?)

Post by jgriessen » Mon Aug 13, 2018 9:36 pm

Oh, thanks for reminding me to look in the board definition files -- mpconfigboard.h
has a pin definition for UART2 that I was using when having a hard time with soldering of the QFN48 package of STM32F401CE.

Code: Select all

// UART config
#define MICROPY_HW_UART2_TX     (pin_A2)
#define MICROPY_HW_UART2_RX     (pin_A3)
//   #define MICROPY_HW_UART2_RTS    (pin_A1)
//   #define MICROPY_HW_UART2_CTS    (pin_A0)
#define MICROPY_HW_UART_REPL        PYB_UART_2
#define MICROPY_HW_UART_REPL_BAUD   115200
I'll comment that out and I think I will see that (pin_A2) is unaffected again.
I can't test that right now though since I sent out my latest prototype... need to build more.
John Griessen blog.kitmatic.com

Post Reply