Does using pyb.repl_uart(uart) stop the USB REPL?

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:

Does using pyb.repl_uart(uart) stop the USB REPL?

Post by jgriessen » Sun Apr 22, 2018 5:35 pm

I have a REPL on the uart from using this code:

Code: Select all

import pyb
uart = pyb.UART(2, 4800)
pyb.repl_uart(uart)
Supporting that in mpconfigboard.h are these lines:

Code: Select all

#define MICROPY_HW_ENABLE_USB       (1)

// USB config
#define MICROPY_HW_USB_FS           (1)
// recognizing a USB host requires VBUS_DETECT_PIN
#define MICROPY_HW_USB_VBUS_DETECT_PIN (pin_A9)
// recognizing a USB host requires OTG_ID_PIN
#define MICROPY_HW_USB_OTG_ID_PIN      (pin_A10)


// 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   9600
// UART 6 not avail in F401CE package..

Is any of that conflicting with a USB REPL?
My USB_DM and USB_DP lines are at 0.0V during reset -- no REPL message going out.
They both measure about 19k Ohms to GND when power is off. They are not shorted.
Those pins can be driven as outputs.
When I ask at the UART REPL prompt:
>>>pyb.usb_mode()
>>>'VCP+MSC'
comes back.

One thing unusual is that I am compiling frozen module code, so the filesystem is not being used yet, and I'm not sure I've set that up right for frozen. I'm also using a minimally modified copy of the G30TH board definition files. I just tried verifying the USB_DM and USB_DP lines via micropython and it stopped at main.c saying it could not execute main.py -- which means there is probably a syntax error or something impossible in what I added -- PA11 and PA12 pins. I found that pins.csv did not have those defined -- the G30TH does not use all of the pins of its MCU and so does not define all of the ones my platform uses either. Adding those back...and making them toggle like the LEDs, fail to move their volts off 0.0V. What could be stopping that?

Before toggling pinA11 pinA12 with machine.pin commands, I turn off the USB with this:
pyb.mode_usb(None)

Now I modify the code that could not move pinA11 pinA12 off 0.0V and PA8, PA9 toggle just fine. Something is not letting the
USB pins be GPIOs it seems. ( pinA11 pinA12 have been tested as outputs with C code not using micropython)

Just found this by Dave H. -- "In order to actually affect the USB mode, pyb.usb_mode needs to be called before the USB is initialized."
So, will do that next, soon.
John Griessen blog.kitmatic.com

Post Reply