Page 1 of 1

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

Posted: Sat Aug 11, 2018 5:51 pm
by jgriessen
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')

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

Posted: Mon Aug 13, 2018 3:07 am
by dhylands
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?

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

Posted: Mon Aug 13, 2018 3:07 pm
by jgriessen
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.

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

Posted: Mon Aug 13, 2018 7:50 pm
by dhylands
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.

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

Posted: Mon Aug 13, 2018 9:36 pm
by jgriessen
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.