• AVR Freaks

AnsweredHot!No signal on D+ or D- when I plug the USB

Author
thoraz
Senior Member
  • Total Posts : 129
  • Reward points : 0
  • Joined: 2013/06/01 18:37:43
  • Location: 0
  • Status: offline
2021/01/13 08:01:35 (permalink)
4 (1)

No signal on D+ or D- when I plug the USB

I'm working on the vendor_pic32mz_ef_sk example to develop a USB device with a PIC32MZ2048EFH144. I'm using an EasyPIC Fusion v7 by Mikroelektronika configured as the PIC32MZ Embedded Connectivity with FPU (EF) Starter Kit for the LEDs and SWITCHs. The external clock is the same, 24MHz oscillator, and the USB bus seems to be the same too, except for two 27Ohm serie resistors on D+ and D-, and a 220Ohm resistor and a BAT43 diode in serie on VBUS:
 
EasyPIC Fusion v7 bus
[See EasyPIC_Fusion_v7_USB_Bus.png attached]
 
PIC32MZ Embedded Connectivity with FPU (EF) Starter Kit bus
[See Starter_Kit_USB_Bus.png attached]
 
I've loaded the vendor_pic32mz_ef_sk example on the PIC32MZ but when I plug the USB cable nothing appen: no USB plug sound and no signals on both D+ and D-. The project is configured as High speed device so I espect an high signal on the D+ pin for the speed negotiation. But nothing appen: I checked with oscilloscope on D+ and D- but they are always low.
I'm pretty sure that the USB_DEVICE_EVENT_POWER_DETECTED event is triggered
 
case USB_DEVICE_EVENT_POWER_DETECTED:

            /* VBUS is detected. Attach the device */
            USB_DEVICE_Attach(appData.usbDevHandle);
            Task_Led_On();  //I turn on the led to confirm the event
            break;

 
and nothing else. But if I check the USBOTG, USBCSR0 and USBCRCON registers before and after I plug the cable, I get:
 
Cable disconnected
register USBOTG: 00 00 00 80
BDEV = 1: USB is operating as 'B' device

register USBCRCON: 01 00 80 04
USBWK = 1: Connect, disconnect, or other activity on USB detected since last cleared
USBIE = 1: Enables general interrupt from USB module
USBRIE = 1: Enable remote resume from suspend Interrup

register USBCSR0: 00 00 20 00
HSEN = 1: The USB module will negotiate for Hi-Speed mode when the device is reset by the hub

 
Cable connected
register USBOTG: 00 00 00 98
BDEV = 1: USB is operating as 'B' device
VBUS = 1: Above VBUS Valid

register USBCRCON: 01 00 80 04
USBWK = 1: Connect, disconnect, or other activity on USB detected since last cleared
USBIE = 1: Enables general interrupt from USB module
USBRIE = 1: Enable remote resume from suspend Interrup

register USBCSR0: 00 00 70 00
SOFTCON = 1: The USB D+/D- lines are enabled and active
HSEN = 1: The USB module will negotiate for Hi-Speed mode when the device is reset by the hub
HSMODE = 1: Hi-Speed mode successfully negotiated during USB reset

 
The VBUS field goes to '11' then the level is valid and the HSMODE goes to '1' too, which means that Hi-Speed mode negotiation occurred!
My first thought was that the internal (?) pull-up resistors on the D+ and D- were not activated (strange, since the USB_DEVICE_Attach function in the USB_DEVICE_EVENT_POWER_DETECTED was called), so I tryed to hard connect an external pull-up resistor on D+. With that resistor I can get the plug sound from  my host PC and I can see some signals on D+ but the host can't recognize it:
 
[See USB_Error.png attached]
 
But at least is a little step forward. I think the problem is at its source.
 
Why whitout external pull-up resistor the D+ and D- lines are low? It should work without it, right?
And why the HSMODE is set while I have no negotiation signals on D+ or D-?
 
PS: I've tryed on another PIC and same problem.

Attached Image(s)

#1
MisterHemi
Super Member
  • Total Posts : 326
  • Reward points : 0
  • Joined: 2017/11/02 12:24:21
  • Location: Commerce, CA USA
  • Status: offline
Re: No signal on D+ or D- when I plug the USB 2021/01/13 09:04:13 (permalink)
0
I don't use Harmony but know a bit about the PIC32MZ's USB
 
The internal resistors are connected to the D+ and D- lines when SOFTCON = 1
 
At which point the host (your PC)or hub should recognize that a device has attached itself to the bus and it should attempt to start the enumeration process.
 
I have also had similar issues with different boards. Some worked when using a hub in between the device and computer and others have worked fine when connected directly to the computer (in my case a MacBook Pro).
 
You can use software such as Wireshark to monitor the USB and see if it recognizes the device and if it begins enumeration.
 
Also be sure to remove the external resistors you connected as this would cause errors such as making the host recognize the device as a different speed, e.g. - low speed vs high speed, etc.

My configuration:
MacBook Pro (Retina, 15-inch, Mid 2015) with MacOS Mojave (10.14.6) and MPLAB X IDE v5.30
 
Curiosity PIC32MZ EF 1 & 2, PIC24F Curiosity, XPRESS EVAL BOARD (PIC16F18855), SAMA5D3 Xplained and various custom boards.
#2
thoraz
Senior Member
  • Total Posts : 129
  • Reward points : 0
  • Joined: 2013/06/01 18:37:43
  • Location: 0
  • Status: offline
Re: No signal on D+ or D- when I plug the USB 2021/01/13 12:52:33 (permalink)
0
MisterHemi
I don't use Harmony but know a bit about the PIC32MZ's USB
 
The internal resistors are connected to the D+ and D- lines when SOFTCON = 1
 
At which point the host (your PC)or hub should recognize that a device has attached itself to the bus and it should attempt to start the enumeration process.
 
I have also had similar issues with different boards. Some worked when using a hub in between the device and computer and others have worked fine when connected directly to the computer (in my case a MacBook Pro).
 
You can use software such as Wireshark to monitor the USB and see if it recognizes the device and if it begins enumeration.
 
Also be sure to remove the external resistors you connected as this would cause errors such as making the host recognize the device as a different speed, e.g. - low speed vs high speed, etc.




Thanks for your point but:
 
- As I shown, the SOFTCON goes to '1' after I plug the cable; so the D+ and D- should be connected to the internal pull-up resistors.
 
- I'm monitoring both D+ and D- bacause first of all, before the enumeation, I expect the speed negotiation: D+ pulled high for High/Full Speed device, D- pulled high for Low Speed device. But on the D+ and D- I have ALWAYS low level, then no speed negotiation and consequently no enumeration.
 
- I've added the external pull-up resistor only to try. And it seems work! But why, without external resistor, I have SOFTCON = 1 and D+ and D- ALWAYS low?
 
I plug the cable from board directly to PC USB port; no HUB, cause using it I have the Vbus level lower than the valid limit. Connected direct to PC I have Vbus = 4.9V .
 
I read in another post that a pull-down resistor on Vbus line solved the problem (in the Starter Kit schematic I've attached in the previous post the pull-down resistor is present!), but I've tryed it and problem occurs again. Is necessary a pull-down resistor on Vbus?
#3
MisterHemi
Super Member
  • Total Posts : 326
  • Reward points : 0
  • Joined: 2017/11/02 12:24:21
  • Location: Commerce, CA USA
  • Status: offline
Re: No signal on D+ or D- when I plug the USB 2021/01/13 15:29:33 (permalink)
0
No, it shouldn't be necessary. VBUS is just to notify the device that it is attached to the bus (before enumeration) and to supply some power.
 
One of the first steps it for the device to detect VBUS **before** it attaches the resistors.
 
It is odd .... i'll be home soon... I do remember something about one of the registers. I'll post it soon.

My configuration:
MacBook Pro (Retina, 15-inch, Mid 2015) with MacOS Mojave (10.14.6) and MPLAB X IDE v5.30
 
Curiosity PIC32MZ EF 1 & 2, PIC24F Curiosity, XPRESS EVAL BOARD (PIC16F18855), SAMA5D3 Xplained and various custom boards.
#4
MisterHemi
Super Member
  • Total Posts : 326
  • Reward points : 0
  • Joined: 2017/11/02 12:24:21
  • Location: Commerce, CA USA
  • Status: offline
Re: No signal on D+ or D- when I plug the USB 2021/01/13 21:45:35 (permalink) ☼ Best Answerby thoraz 2021/01/15 02:06:20
5 (1)
On your schematic I see you have the USB ID pin connected, it should work but I found on one of my boards I had to add the following code and override it.
 
Perhaps try this:

// PHYIDEN: PHY ID Monitoring Enable bit
// 1 = Enable monitoring of the ID bit from the USB PHY
// 0 = Disable monitoring of the ID bit from the USB PHY
USBCRCONbits.PHYIDEN = 0; // 0

// USBIDOVEN: USB ID Override Enable bit
// 1 = Enable use of USBIDVAL bit
// 0 = Disable use of USBIDVAL and instead use the PHY value
USBCRCONbits.USBIDOVEN = 1; // 1

// USBIDVAL: USB ID Value bit
// 1 = ID override value is 1 (Device)
// 0 = ID override value is 0 (Host)
USBCRCONbits.USBIDVAL = 1; // 1

 
 

My configuration:
MacBook Pro (Retina, 15-inch, Mid 2015) with MacOS Mojave (10.14.6) and MPLAB X IDE v5.30
 
Curiosity PIC32MZ EF 1 & 2, PIC24F Curiosity, XPRESS EVAL BOARD (PIC16F18855), SAMA5D3 Xplained and various custom boards.
#5
thoraz
Senior Member
  • Total Posts : 129
  • Reward points : 0
  • Joined: 2013/06/01 18:37:43
  • Location: 0
  • Status: offline
Re: No signal on D+ or D- when I plug the USB 2021/01/14 02:06:27 (permalink)
0
MisterHemi
On your schematic I see you have the USB ID pin connected, it should work but I found on one of my boards I had to add the following code and override it.




No, I haven't the USB ID connected. The schematic you refer is the PIC32MZ Embedded Connectivity with FPU (EF) Starter Kit by Microchip, but actually I'm working on the EasyPIC Fusion v7, the first schematic (I attached it to this post again). The VBUS, USB_D-N and USB_D-P pins are connected directly to microcontroller, as in the Microchip's Statrer Kit. The vendor_pic32mz_ef_sk example in MPLABX is based on the Starter Kit so I suppose that it should work on it. And on my EasyPIC board the USB connection are the same on the starter kit, so it should be ok on my board too...I suppose.
 
The vendor_pic32mz_ef_sk example configuration has only 3 LEDs and 3 SWITCHs active and USB peripheral, nothing else. Then I don't think that the code is incompatibile with the EsayPIC board siche the USB bus is almost the same (except fot some little value resistors in serie on D+ and D-, as explained in my first post).
 
Again, in this page is shown that the USB ID can be unconnect is the microcontroller has a device role, as actually is. And I'm using also a B type connector (as you can see in the schematic attached) which has not the USB ID pin.

Attached Image(s)

#6
MisterHemi
Super Member
  • Total Posts : 326
  • Reward points : 0
  • Joined: 2017/11/02 12:24:21
  • Location: Commerce, CA USA
  • Status: offline
Re: No signal on D+ or D- when I plug the USB 2021/01/14 05:50:51 (permalink)
0
I believe it's necessary to have the pin connected or use the code example I posted to force the PIC into device mode.
 
Try that and let me know if it works.

My configuration:
MacBook Pro (Retina, 15-inch, Mid 2015) with MacOS Mojave (10.14.6) and MPLAB X IDE v5.30
 
Curiosity PIC32MZ EF 1 & 2, PIC24F Curiosity, XPRESS EVAL BOARD (PIC16F18855), SAMA5D3 Xplained and various custom boards.
#7
thoraz
Senior Member
  • Total Posts : 129
  • Reward points : 0
  • Joined: 2013/06/01 18:37:43
  • Location: 0
  • Status: offline
Re: No signal on D+ or D- when I plug the USB 2021/01/15 02:50:40 (permalink)
4 (1)
MisterHemi
I believe it's necessary to have the pin connected or use the code example I posted to force the PIC into device mode.
 
Try that and let me know if it works.




Today is a good day thanks to MisterHemi! grin: grin
 
You're right and I understood the source of my problem: on the EasyPIC Fusion I had the USBID pin (RF3) pulled down by one resistor enabled by a switch (the SW7-RF3, for the ones that have an EasyPIC board and are reading this post). Than, I disabled that pull-down resistor and all works fine.
 
I can keep the pull-down resistor active, but in that case I need to set the USBCRCON bits as MisterHemi said to override the signal on USBID pin.
 
The OTG feature, with the USBID pulled down, leads the microcontroller act like a host device and that's why the D+ and D- signals were both keep low.
 
Thanks again.
#8
MisterHemi
Super Member
  • Total Posts : 326
  • Reward points : 0
  • Joined: 2017/11/02 12:24:21
  • Location: Commerce, CA USA
  • Status: offline
Re: No signal on D+ or D- when I plug the USB 2021/01/15 09:04:23 (permalink)
0
thoraz
MisterHemi
I believe it's necessary to have the pin connected or use the code example I posted to force the PIC into device mode.
 
Try that and let me know if it works.




Today is a good day thanks to MisterHemi! grin: grin
 
You're right and I understood the source of my problem: on the EasyPIC Fusion I had the USBID pin (RF3) pulled down by one resistor enabled by a switch (the SW7-RF3, for the ones that have an EasyPIC board and are reading this post). Than, I disabled that pull-down resistor and all works fine.
 
I can keep the pull-down resistor active, but in that case I need to set the USBCRCON bits as MisterHemi said to override the signal on USBID pin.
 
The OTG feature, with the USBID pulled down, leads the microcontroller act like a host device and that's why the D+ and D- signals were both keep low.
 
Thanks again.




You're welcome!
 
Glad you were able to get it working!

My configuration:
MacBook Pro (Retina, 15-inch, Mid 2015) with MacOS Mojave (10.14.6) and MPLAB X IDE v5.30
 
Curiosity PIC32MZ EF 1 & 2, PIC24F Curiosity, XPRESS EVAL BOARD (PIC16F18855), SAMA5D3 Xplained and various custom boards.
#9
Jump to:
© 2021 APG vNext Commercial Version 4.5