Author Topic: How to run USB in PIC32MZ  (Read 4653 times)

0 Members and 1 Guest are viewing this topic.

Offline UstekTopic starter

  • Newbie
  • Posts: 6
  • Country: pl
How to run USB in PIC32MZ
« on: January 15, 2018, 06:18:58 pm »
Hello guys, I have a problem with USB in MCU PIC32MZ2048EFH064. I'm registered on microchip forum but they don't send me activation email.

I want to make USB Audio 1.0 Device and i know how to turn on many peripherals in this MCU (I'm using MPLAB X Harmony). I think I'm connecting everything fine (D+, D-, VBUS, GND, SHIELD, USBID), I'm making Harmony project with USB Stack and external 12MHz crystal clock and when i write to linux terminal "lsusb" then i don't see this device. I'm changing vid/pid, device name etc. Tutorial files from Microchip are dedicated to evaluation boards and I can't modify it.

In Harmony there are a lot of demo vid's/pid's named for example "speaker demo" and this is not working.

What i do wrong?
Does anyone here can show me how to turn on USB in PIC32MZ, (or better) simple usb audio transmission without evaluation boards?
 

Offline Buriedcode

  • Super Contributor
  • ***
  • Posts: 1611
  • Country: gb
Re: How to run USB in PIC32MZ
« Reply #1 on: January 15, 2018, 07:51:16 pm »
I want to make USB Audio 1.0 Device and i know how to turn on many peripherals in this MCU (I'm using MPLAB X Harmony).

A USB audio device is quite advanced if you're just starting.  I believe there are example projects about, but they mostly act as a USB-I2S bridge, so you'll need an I2S ADC/DAC, preferably a codec.

Tutorial files from Microchip are dedicated to evaluation boards and I can't modify it.
In Harmony there are a lot of demo vid's/pid's named for example "speaker demo" and this is not working.

You can modify them. You could create a new HAL for your hardware based on the HAL for the evaluation boards.  It can be quite involved, and again, not something thats straight forward if you are just starting out.

How is the speaker demo "not working" ?  First thing is first - make sure your hardware is working with a "blink" program.  Then perhaps the USB CDC class demo (USB-UART bridge) to verify that the USB part is working.  This requires specific config bits, and hardware, do you have a schematic of your layout?

What i do wrong?
Does anyone here can show me how to turn on USB in PIC32MZ, (or better) simple usb audio transmission without evaluation boards?

There is no way of knowing why it isn't working without a schematic, a reference to the example you are working with, your setup (pickit 3? ICD?).  I get the impression you are not that experienced with PICs or micro's in general (I could be wrong) so I would start with small steps, each one verifies part of the design rather than just putting it all together loading on the example code and praying it works.
 

Offline UstekTopic starter

  • Newbie
  • Posts: 6
  • Country: pl
Re: How to run USB in PIC32MZ
« Reply #2 on: January 15, 2018, 08:58:54 pm »
I saw some tutorials with audio codec's but that need I2C (volume, mute control). I need only I2S because i want to use CS4334 Audio DAC.
USB Stack config "speaker demo" not working i mean that's my pc not see it. Then i program MCU i see LED on pin is pulsing, so program is not crashed.

When program have only SYSTEM_INIT() and SYSTEM_TASKS() in while loop, there's no effect.
I'm using PICkit3, the newest MPLAB X and Harmony.

I know some about PIC10...18F (I know how to configure 90% peripherals, interrupts etc) and I'm programming the micromouse robot. There im using PWM's, several timers, UART (Bluetooth module), I2C (Gyroscope) and ADC's (IR sensors).

Tomorrow I want to check USB CDC demo. I will send something with bluetooth module, maybe that can work.

I have only "UstekCAD" photo of schematic  :P:
https://imgur.com/a/NLREg

I meant that robot micromouse is based on this same PIC32 microcontroller.
« Last Edit: January 15, 2018, 11:49:24 pm by Ustek »
 

Online ajb

  • Super Contributor
  • ***
  • Posts: 2604
  • Country: us
Re: How to run USB in PIC32MZ
« Reply #3 on: January 16, 2018, 04:14:04 am »
USB devices alert the host to their presence by pulling D+ or D- (depending on speed) high with a resistor.  If your computer isn't detecting the device at all then it sounds like this isn't happening.  The pullup resistor and associated switch for it is built into some USB PHYs, but on others, including some MCUs, you will have to provide it externally.  If you look at USB device reference designs for your MCU this should tell you if you need to provide an external pullup or not.  With the hardware in place, you will need to make sure that the pullup gets turned on, so make sure this is happening somewhere in the USB initialization code.
 

Offline UstekTopic starter

  • Newbie
  • Posts: 6
  • Country: pl
Re: How to run USB in PIC32MZ
« Reply #4 on: January 17, 2018, 02:45:31 pm »
I added external pull-up to D+ for full-speed usb and that don't do nothing. I have installed MPLAB with XC32 compiler and harmony on windows. Still doesn't work.
I tried cdc_com_port_single modified to my MCU and windows only see unknown device with vid and pid 0x0000.
In original version of this demo firmware have PIC32MZ2048EFH144, so the only things I've done were comment higher ports and select my chip in project properties. That changes don't have errors etc.   :(
« Last Edit: January 17, 2018, 02:47:18 pm by Ustek »
 

Offline up8051

  • Frequent Contributor
  • **
  • Posts: 288
  • Country: pl
Re: How to run USB in PIC32MZ
« Reply #5 on: January 17, 2018, 05:50:52 pm »
Helo,

Please read the PIC32MZ errata data sheet (2. Module oscillator)
PIC32MZ (rev A1) cant work with crystal oscillator, you have to use external clock.

Regards
up8051

Przeczytaj errat? do ukladów PIC32MZ (punkt 2. Module oscillator).
PIC32MZ (rewizja A1) nie pracuj? poprawnie z kwarcem, musisz u?y? zewn?trznego generatora.

Pozdrawiam
up8051

 

Offline UstekTopic starter

  • Newbie
  • Posts: 6
  • Country: pl
Re: How to run USB in PIC32MZ
« Reply #6 on: January 17, 2018, 06:08:59 pm »
Hmmm maybe this is it but my project works fine all the time. I mean then I'm using (in harmony) primary oscillator as HS then MCU is working (PWM's and something like that). Tomorrow I will go buy 24MHz generator. I understand Revision A1 but Im confused because of Figure 1 and Table 3 in this errata. What they mean?
 

Offline UstekTopic starter

  • Newbie
  • Posts: 6
  • Country: pl
Re: How to run USB in PIC32MZ
« Reply #7 on: January 18, 2018, 01:28:37 pm »
I saw that USB peripheral can take clock signal from USBCLK and PBCLK5 (Table 8-1 in datasheet). There is that the clock can be changed in SFR but I can't find any register with similar settings. In earlier MCU (EC series) You can disable USBCLK with #pragma config UPLLEN = OFF but in EF series there is no UPLLEN. How to find that register?
 

Offline Niklas

  • Frequent Contributor
  • **
  • Posts: 395
  • Country: se
Re: How to run USB in PIC32MZ
« Reply #8 on: January 18, 2018, 04:39:35 pm »
Hmmm maybe this is it but my project works fine all the time. I mean then I'm using (in harmony) primary oscillator as HS then MCU is working (PWM's and something like that). Tomorrow I will go buy 24MHz generator. I understand Revision A1 but Im confused because of Figure 1 and Table 3 in this errata. What they mean?
If you are using A1 silicon then you can skip Figure 1 and Table 3 as that revision does not support an external crystal, use an external crystal oscillator instead. The A2 silicon had support for a limited set of crystals and Rp was then 510k and Rs 1k together with a 12 MHz crystal. With the A3 silicon you can skip Rp and use the internal gain resistance, check POSCGAIN<1:0>.
 

Offline UstekTopic starter

  • Newbie
  • Posts: 6
  • Country: pl
Re: How to run USB in PIC32MZ
« Reply #9 on: January 19, 2018, 02:09:18 am »
I have A3 revision, and I did all recomendations with crystal from errata and still nothing.  :'( I must wait for delivery with external clock 24MHz.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf