Mikroelektronika's USB Library for non-HID devices

General discussion on mikroC PRO for PIC32.
Author
Message
mfranco
Posts: 10
Joined: 01 Jun 2013 21:51

Mikroelektronika's USB Library for non-HID devices

#1 Post by mfranco » 01 Jun 2013 22:19

Hello,

I would like to ask you guys for some help regarding USB firmware development. I am searching the Internet for some documentation and examples, but they all seem very confusing (as there is too much information, but none seems to address what I need).

I have just purchased EasyPic Fusion v7 board, as I will need to develop a new printer with USB and Ethernet capabilities. As I would like to start with the USB part of the project, after reading lots and lots of tutorials and Application Notes, sometimes I think I am getting even more confused.

From what I could understand, 99,9% of the examples I found develop the projects considering the HID class, as there are plenty of usb-ready device libraries with simple functions to be used. Also, there is no need to develop custom host-side drivers, as any OS already has HID drivers. So, people just build some blinking led project on top of this HID class, using some very simple functions, such as HID_Enable, etc...

However, if I need to develop some device hardware that is not classified as HID, how do I start? Is there any kind of USB device library to use, or do I need to write every single function from scratch? :shock:

Can I use Mikroelektronika's USB library to write firmware for non-HID devices?

Thank you all in advance.

User avatar
dejan.odabasic
mikroElektronika team
Posts: 2649
Joined: 30 Apr 2012 14:20

Re: Mikroelektronika's USB Library for non-HID devices

#2 Post by dejan.odabasic » 03 Jun 2013 17:52

Hello,

Yes, you can use USB Device library to create projects with desired USB class.
When you install the latest version of USB Device library you can find example projects for three different classes(CDC, HID, MSC).
In ..compiler\Packages\USB_Device_PIC32\examples\ folder.

Also, I suggest reading the library help file for explanation of library functions.
Help file is located at ..compiler\Packages\USB_Device_PIC32\help\ folder.

Best regards.

Dxmaxim
Posts: 80
Joined: 30 Sep 2008 08:10
Location: South Africa
Contact:

Re: Mikroelektronika's USB Library for non-HID devices

#3 Post by Dxmaxim » 04 Jun 2013 20:50

Hi,

I am trying to use the new CDC library with a PIC18F2553, when I try to use the VCP Driver I get an error message that the driver is not X64 compatible. I am using 64 BIT Windows 7.

What do I do ?

Any help would be appreciated.
ZarDynamix | Fidelis et fortis semper
An embedded solutions company
Site | http://www.zardynamix.com

Dxmaxim
Posts: 80
Joined: 30 Sep 2008 08:10
Location: South Africa
Contact:

Re: Mikroelektronika's USB Library for non-HID devices

#4 Post by Dxmaxim » 04 Jun 2013 21:23

When I attempt the same using windows 8, the device driver change gets further up until post installation. The error says " A request for the device descriptor failed". The device cannot start...

Any ideas, step by step guides would be greatly appreciated ...

Regards
ZarDynamix | Fidelis et fortis semper
An embedded solutions company
Site | http://www.zardynamix.com

User avatar
dejan.odabasic
mikroElektronika team
Posts: 2649
Joined: 30 Apr 2012 14:20

Re: Mikroelektronika's USB Library for non-HID devices

#5 Post by dejan.odabasic » 05 Jun 2013 07:58

Hello,

Driver which is provided with example in VCPDriver folder is tested on Window8 x64 operating system.
I suggest that you check your oscillator configurations in Edit Project window.

Error message: "A request for the device descriptor failed" is similar to "Device not recognized" on Windows XP operating system.

Best regards.

Dxmaxim
Posts: 80
Joined: 30 Sep 2008 08:10
Location: South Africa
Contact:

Re: Mikroelektronika's USB Library for non-HID devices

#6 Post by Dxmaxim » 05 Jun 2013 08:24

I copied the settings for the PIC18F2553 from the example project, but the difference is that I have a 48 MHZ ceramic resonator in circuit as opposed to the 8MHZ crystal that I think your example is based on.

Can you please assist with what the configuration settings should be ? It would be appreciated so that I have a better idea what to look for and figure out what is wrong.

Regards
ZarDynamix | Fidelis et fortis semper
An embedded solutions company
Site | http://www.zardynamix.com

Dxmaxim
Posts: 80
Joined: 30 Sep 2008 08:10
Location: South Africa
Contact:

Re: Mikroelektronika's USB Library for non-HID devices

#7 Post by Dxmaxim » 06 Jun 2013 20:07

As I requested previously, can you assist with what the settings should be ?

Because I have tried every combination of setting testing on both Windows 7 and Windows 8 and I keep getting the Device not recognised error. It may work on your windows 8 machine, IT DEFINATELY does not work on mine.

I am testing Windows 7 x64 and Windows 8 x86,

1) Device driver not supported by windows 7 x64 && Device not recognised error

2) Device not recognised && this device cannot start Code 10 on windows 8 x86

Any help, please ?
Attachments
Device cannot start.png
Device cannot start.png (14.74 KiB) Viewed 9451 times
ZarDynamix | Fidelis et fortis semper
An embedded solutions company
Site | http://www.zardynamix.com

Xaser
Posts: 7
Joined: 09 Jun 2012 22:31

Re: Mikroelektronika's USB Library for non-HID devices

#8 Post by Xaser » 06 Jun 2013 22:22

If you are running a 48Mhz crystal, I assume you have changed the oscillator frequency in project settings to 48Mhz, in doing this you will also have to change the PLL Prescaler to divide by 12 so the internal USB clock is scaled correctly.

Hope this helps.

Dxmaxim
Posts: 80
Joined: 30 Sep 2008 08:10
Location: South Africa
Contact:

Re: Mikroelektronika's USB Library for non-HID devices

#9 Post by Dxmaxim » 06 Jun 2013 22:40

Hi Xaser,

I have included a snap shot of the configuration settings. If you have the time I would appreciate it if you can spot something that is amiss. Personally, I don't know why these config settings have to be such an issue, makes getting a simple start up and run tedious.

Interestingly, I loaded the example Mikroe project with a PIC18F4550, 20 MHZ crystal (yup made the obvious changes) and still got the same errors as I have been getting with the PIC18F2553. Also, got an error that the driver VCP etc was not captiable with a 32 BIT operating system, had the same error on a windows 7 x64 machine.

So, perhaps the problem is not the PIC but whatever else is required on the machine for it to work, . . .
Attachments
Configuration Settings.png
Configuration Settings.png (71.17 KiB) Viewed 9441 times
ZarDynamix | Fidelis et fortis semper
An embedded solutions company
Site | http://www.zardynamix.com

Xaser
Posts: 7
Joined: 09 Jun 2012 22:31

Re: Mikroelektronika's USB Library for non-HID devices

#10 Post by Xaser » 06 Jun 2013 23:09

I can't see anything wrong with your settings. These configuration register are built in to the processor allowing the user to change hardware related differences they are using i.e. different clock speeds etc. This editor that Mikroe has developed is the most user friendly implementation of controlling these register that I have seen but again they can still cause problems.

I am yet to test the new USB device library(therefore my help is limited) but I am very interested in playing with the new CDC class when I get a chance. I was just trying to remember what things helped me when I was playing with their older HID class examples. I am pretty sure that the PLL was all I had changed for the setup I was running which also had a different crystal from the Mikroe examples.

The additional complexity of debugging the VCP example is you have the driver to contend with as well. Mikroe have tested with 64bit OS's so I would go with it being fine so this must be something wrong with the PIC code or configuration. But nothing else obvious is sticking out in my mind rite now sorry.

hexreader
Posts: 1784
Joined: 27 Jun 2010 12:07
Location: England

Re: Mikroelektronika's USB Library for non-HID devices

#11 Post by hexreader » 06 Jun 2013 23:15

Dxmaxim wrote:I have a 48 MHZ ceramic resonator in circuit
The datasheet states that maximum oscillator input frequency for HSPLL mode is 24 MHz.

48MHz crystal or ceramic resonator is of no use with this PIC.
Start every day with a smile...... (get it over with) :)

Xaser
Posts: 7
Joined: 09 Jun 2012 22:31

Re: Mikroelektronika's USB Library for non-HID devices

#12 Post by Xaser » 07 Jun 2013 00:04

hexreader wrote:The datasheet states that maximum oscillator input frequency for HSPLL mode is 24 MHz.
Is that not only the case for operating in low speed USB(1.5Mb/s)?

I have just tested the VCP example on my StartUSB board which uses an 8Mhz crystal, I took the 4550 example change the PIC to 2550 the PLL to divide by 2 and the USB clock selection to use the 96Mhz PLL divided by 2 and it worked perfectly fine.

What size capacitors are you using with your resonator and are you running a 200nF cap from Vusb to ground?

Dxmaxim
Posts: 80
Joined: 30 Sep 2008 08:10
Location: South Africa
Contact:

Re: Mikroelektronika's USB Library for non-HID devices

#13 Post by Dxmaxim » 07 Jun 2013 05:50

With the crystal I was using 22 pf capacitors and a 100nf capacitor.

For the PIC18f4550, 20 MHZ crystal 22pf capacitors and I will try the 200nf Capacitor, maybe that will help.

Regards
ZarDynamix | Fidelis et fortis semper
An embedded solutions company
Site | http://www.zardynamix.com

hexreader
Posts: 1784
Joined: 27 Jun 2010 12:07
Location: England

Re: Mikroelektronika's USB Library for non-HID devices

#14 Post by hexreader » 07 Jun 2013 06:36

Xaser wrote:Is that not only the case for operating in low speed USB(1.5Mb/s)?
No, it is a limitation of the PICs oscillator module.

25MHz is the maximum crystal frequency that the oscillator can handle (if you want to stay within specification)
25Mhz cannot divide accurately enough to give a suitable USB clock, so 24MHz is the maximum crystal value if using USB.

The only way to be in specification and provide external 48MHz timing source is to provide an external square wave, such as from a 4-pin crystal oscillator module.

Since the OP cannot use a 48MHz ceramic resonator, I would recommend using 8 MHz crystal with 2x 22pF capacitors exactly as the Mikro examples expect. Then configuration used in the example programs will work without modification.
Start every day with a smile...... (get it over with) :)

Dxmaxim
Posts: 80
Joined: 30 Sep 2008 08:10
Location: South Africa
Contact:

Re: Mikroelektronika's USB Library for non-HID devices

#15 Post by Dxmaxim » 14 Jun 2013 09:59

Thanks for all the help. It started to work using a PIC18F4550 with the adjustments to the project as suggested. The driver installs and appears in the device manager as the Mikroe Virtual Comport.

All smiles :)

However, when I then go to Mikroe > USART Terminal, the comport is visible but then when I click "Open", I get an error message that states "Cannot Open comport".

Any ideas . . .

Thanks in advance
ZarDynamix | Fidelis et fortis semper
An embedded solutions company
Site | http://www.zardynamix.com

Post Reply

Return to “mikroC PRO for PIC32 General”