How to run USB in PIC32MZ - Page 1
Forum section: electronics / general

author: Ustek
author_rank: Newbie
timestamp: January 15, 2018, 06:18:58 pm
content: 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?

author: Buriedcode
author_rank: Super Contributor
timestamp: January 15, 2018, 07:51:16 pm
content: Quote from: Ustek on January 15, 2018, 06:18:58 pmA 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.Quote from: Ustek on January 15, 2018, 06:18:58 pmYou 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?Quote from: Ustek on January 15, 2018, 06:18:58 pmThere 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.

author: Ustek
author_rank: Newbie
timestamp: January 15, 2018, 08:58:54 pm
content: 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:https://imgur.com/a/NLREgI meant that robot micromouse is based on this same PIC32 microcontroller.

author: ajb
author_rank: Super Contributor
timestamp: January 16, 2018, 04:14:04 am
content: 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.

author: Ustek
author_rank: Newbie
timestamp: January 17, 2018, 02:45:31 pm
content: 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.

author: up8051
author_rank: Frequent Contributor
timestamp: January 17, 2018, 05:50:52 pm
content: 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.Regardsup8051Przeczytaj errat? do ukladów PIC32MZ (punkt 2. Module oscillator).PIC32MZ (rewizja A1) nie pracuj? poprawnie z kwarcem, musisz u?y? zewn?trznego generatora.Pozdrawiamup8051

author: Ustek
author_rank: Newbie
timestamp: January 17, 2018, 06:08:59 pm
content: 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?

author: Ustek
author_rank: Newbie
timestamp: January 18, 2018, 01:28:37 pm
content: 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?

author: Niklas
author_rank: Frequent Contributor
timestamp: January 18, 2018, 04:39:35 pm
content: Quote from: Ustek on January 17, 2018, 06:08:59 pmIf 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>.

author: Ustek
author_rank: Newbie
timestamp: January 19, 2018, 02:09:18 am
content: 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.