Page 3 of 3

Re: USB Composite library MIDI Get Bytes without using Callbacks

Posted: Fri Jan 14, 2022 4:33 pm
by ag123
USB has something called the 'single ended zero' - usb reset. i.e. pull both D+ / D- to gnd for 10ms
https://www.usbmadesimple.co.uk/ums_3.htm
resetting the mcu do not necessarily send the 'single ended zero'. so it may be a problem on the *host* side, i.e. the host 'remembers' the previous state and do not enumerate ports again.
a usual 'trick' is to enable or disable the device in windows, i'm not sure if there are other 'short cuts'
in linux there is a little piece of code that can do that usb reset
https://github.com/jkulesza/usbreset

it is possible to do this usb reset in your codes, e.g. in setup etc
e.g.

Code: Select all

pinMode(PA11, OUTPUT);
pinMode(PA12, OUTPUT);
digitalWrite(PA11, LOW);
digitalWrite(PA12, LOW);
delay(10);
pinMode(PA11, INPUT);
pinMode(PA12, INPUT);
the trouble here is actually this is incorrect, you need to restore the AFIO to USB after this.
it would be better to search in RM0008 for a proper means to do this usb reset

and you probably need to do this prior to calling usbComposite.begin() for that matter.

Re: USB Composite library MIDI Get Bytes without using Callbacks

Posted: Sat Jan 15, 2022 1:53 pm
by jhsa
fpiSTM wrote: Fri Jan 14, 2022 4:22 pm Maybe You can force to reenumerate in that case.
I don't understand what you mean :) I am a beginner with this arduino thing :mrgreen:

EDIT: Oh, I didn't see your other post as it was on a different page.

João

Re: USB Composite library MIDI Get Bytes without using Callbacks

Posted: Sat Jan 15, 2022 1:57 pm
by jhsa
And I can try that and see if it works, it is simple enough. Thanks.

João

Re: USB Composite library MIDI Get Bytes without using Callbacks

Posted: Sat Jan 15, 2022 4:46 pm
by jhsa
ag123 wrote: Fri Jan 14, 2022 4:33 pm

it is possible to do this usb reset in your codes, e.g. in setup etc
e.g.

Code: Select all

pintMode(PA11, OUTPUT);
pintMode(PA12, OUTPUT);
digitalWrite(PA11, LOW);
digitalWrite(PA12, LOW);
delay(10);
pintMode(PA11, INPUT);
pintMode(PA12, INPUT);
This seems to have worked, at least right after flashing the board while powering it via USB, it started immediately receiving MIDI over USB from my Windows PC. This didn't seem to happen before.

But "pintMode"???? :mrgreen: :mrgreen: :mrgreen:
I do like to be in "pint of beer Mode", specially in the evening ha ha :mrgreen:

Anyway, thank you, I will check this better. will flash now the Blue Pill board that is on the breadboard.

João

Re: USB Composite library MIDI Get Bytes without using Callbacks

Posted: Sun Jan 16, 2022 7:53 am
by ag123
ok it must be getting late that time, so i just typed the codes away :lol:

Re: USB Composite library MIDI Get Bytes without using Callbacks

Posted: Sun Jan 16, 2022 4:36 pm
by jhsa
ag123 wrote: Sun Jan 16, 2022 7:53 am ok it must be getting late that time, so i just typed the codes away :lol:
Could you please correct it? I have marked it as "Best Answer". Thank you.
It did the trick for me. It seems it always reconnect now if the board resets for some reason. I press reset, and it reconnects immediately without having to reboot it.

João

Re: USB Composite library MIDI Get Bytes without using Callbacks

Posted: Mon Jan 17, 2022 3:50 pm
by jhsa
Thank you..

Re: USB Composite library MIDI Get Bytes without using Callbacks

Posted: Tue Mar 01, 2022 9:58 am
by yanisroy
if the board resets in the middle of it, it may be due to other reasons.
you could try to find out if a watchdog implementation could have been done in your codes or library.

Re: USB Composite library MIDI Get Bytes without using Callbacks

Posted: Mon Apr 11, 2022 8:51 pm
by CharlesBottoms
I encountered a similar problem, I will try to do as you advised, and I hope it works out. I really hope that I can recover all the data from the USB, because there are a lot of projects that I am working on. I'm still writing an article for a website with free summary samples for students. There's also a lot of personal information, so I'm really worried.