PDA

View Full Version : Problem with enumeration and EasyHID



jizyjuice
- 5th April 2007, 03:51
Hi, I'm using a pic18f2550 with picbasic pro and easyhid.

I get the files generated from easyhid to compile correctly. The problem is that when I plug in the usb cable, the computer never enumerates the pic, no new hardware found box on windows.

I connected the pins correctly, i think, just as the schematic suggests on the easyhid website. I'm just trying to code something where it will send the a/d values from an RA pin to the pc.

Any suggestions or tips?
Thanks in advance

skimask
- 5th April 2007, 04:28
Hi, I'm using a pic18f2550 with picbasic pro and easyhid.

I get the files generated from easyhid to compile correctly. The problem is that when I plug in the usb cable, the computer never enumerates the pic, no new hardware found box on windows.

I connected the pins correctly, i think, just as the schematic suggests on the easyhid website. I'm just trying to code something where it will send the a/d values from an RA pin to the pc.

Any suggestions or tips?
Thanks in advance

Those that read this are supposed to help you figure out your code problems because we can all guess exactly how you have written your code. Am I correct in this assumption?


Post some code!!!

mister_e
- 5th April 2007, 14:44
http://www.picbasic.co.uk/forum/showthread.php?t=5418

jizyjuice
- 5th April 2007, 18:02
Heres the code that Easy HID created. I set up an led to see where the code stops at. It seems to stop after
USBOut 1, USBBuffer, USBBufferCount, DoUSBOut ' if bus available, . I guess this is because I dont have any code right now to send data, but I was more concerned with the pc recognizing the pic.

If usbinit is called, doesnt the pc enumerate the usb device? It never shows that a hid device is connected. Is there something I am missing to get the pc to recognize this device?!



DEFINE OSC 48
DEFINE LOADER_USED 1

USBBufferSizeMax con 8 ' maximum buffer size
USBBufferSizeTX con 8 ' input
USBBufferSizeRX con 8 ' output

' the USB buffer...
USBBuffer Var Byte[USBBufferSizeMax]
USBBufferCount Var Byte

' ************************************************** **********
' * main program loop - remember, you must keep the USB *
' * connection alive with a call to USBService every couple *
' * of milliseconds or so... *
' ************************************************** **********

usbinit ' initialise USB...
ProgramStart:

gosub DoUSBOut
goto ProgramStart


' ************************************************** **********
' * wait for USB interface to attach *
' ************************************************** **********

DoUSBOut:
USBBufferCount = USBBufferSizeTX ' TX buffer size
USBService ' keep connection alive
USBOut 1, USBBuffer, USBBufferCount, DoUSBOut ' if bus available, transmit data
return

Darrel Taylor
- 6th April 2007, 00:50
That's not the "Whole" code that easyHID created.

You've deleted some things that are very important.

If you just want to see it enumerate, change the main loop to this...
ProgramStart:
USBService ' keep connection alive
goto ProgramStart

But that will neither send or receive any data.
This also assumes you've setup your Configs properly.
<br>

jizyjuice
- 6th April 2007, 15:19
Oh, I took out the code for receiving data from the pc to the pic. I just want to communicate to the pc side.

All the configs are what easyhid has set up. I will try just polling serviceusb and see if that can get the pic to enumerate. Thanks

mister_e
- 6th April 2007, 15:27
What Darrel talked about was the PIC configuration Fuses... which EasyHID don't create for you.

http://www.picbasic.co.uk/forum/showthread.php?t=543

http://www.picbasic.co.uk/forum/showthread.php?t=5418

jizyjuice
- 6th April 2007, 17:09
I still cant get the pic to enumerate.

Here is my code for the fuses:

else
LIST
LIST p = 18F2550, r = dec, w = -311, w = -230, f = inhx32
INCLUDE "C:\PBasPro Projects\AirDrum\PICBasicPRO\P18F2550.INC" ; MPASM Header
__CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
__CONFIG _CONFIG1H, _FOSC_XTPLL_XT_1H & _IESO_OFF_1H
__CONFIG _CONFIG2L, _PWRT_OFF_2L & _BOR_OFF_2L & _BORV_2_2L & _VREGEN_OFF_2L
__CONFIG _CONFIG2H, _WDT_OFF_2H
__CONFIG _CONFIG3H, _MCLRE_ON_3H & _LPT1OSC_OFF_3H & _PBADEN_OFF_3H & _CCP2MX_OFF_3H
__CONFIG _CONFIG4L, _STVREN_OFF_4L & _LVP_OFF_4L & _XINST_OFF_4L & _DEBUG_OFF_4L
NOLIST
endif



Here is the main code again:

DEFINE OSC 48
DEFINE LOADER_USED 1

USBBufferSizeMax con 8 ' maximum buffer size
USBBufferSizeTX con 8 ' input
USBBufferSizeRX con 8 ' output

' the USB buffer...
USBBuffer Var Byte[USBBufferSizeMax]
USBBufferCount Var Byte
i var byte


' ************************************************** **********
' * main program loop - remember, you must keep the USB *
' * connection alive with a call to USBService every couple *
' * of milliseconds or so... *
' ************************************************** **********
usbinit ' initialise USB...
ProgramStart:
'gosub DoUSBIn
'gosub DoUSBOut

High PORTB.0
for i = 1 to 10
Pause 2
USBservice
next i

LOW PORTB.0
for i = 1 to 10
Pause 2
USBservice
next i
goto ProgramStart



' ************************************************** **********
' * receive data from the USB bus *
' ************************************************** **********
DoUSBIn:
USBBufferCount = USBBufferSizeRX ' RX buffer size
USBService ' keep connection alive
USBIn 1, USBBuffer, USBBufferCount, DoUSBIn ' read data, if available
return

' ************************************************** **********
' * wait for USB interface to attach *
' ************************************************** **********
DoUSBOut:
USBBufferCount = USBBufferSizeTX ' TX buffer size
USBService ' keep connection alive
USBOut 1, USBBuffer, USBBufferCount, DoUSBOut ' if bus available, transmit data
return





The LED lights up correctly, but the pic still does not enumerate even with calling the USBSERVICE. I have 0.5microF on VSUB, 20 MHZ crystal with 33 pF connected to it. D+, D- set up correctly. Bus powered.

I have no idea what the problem is!

Darrel Taylor
- 6th April 2007, 18:53
For a 20mhz crystal, second config line should be


__CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H & _IESO_OFF_1H

jizyjuice
- 6th April 2007, 21:03
I changed the config for 20 Mhz clock, but still no enumeration. I uploaded my project files in the following zip. Can someone please let me know if they can get this to enumerate on their bread board? Thanks

Darrel Taylor
- 6th April 2007, 23:50
It would have been much easier to start with mister_e's example ....

Apparently, you have an 18F2550.INC file in your project folder where you are changing the configs.
PBP won't use that file. It uses the one in the PBP folder.

But you should really put the configs in your program, and comment out the configs in the 18F2550.inc file in the PBP folder.

Use these ...
asm
__CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
__CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
__CONFIG _CONFIG2L, _PWRT_ON_2L & _BOR_ON_2L & _BORV_2_2L & _VREGEN_ON_2L
__CONFIG _CONFIG2H, _WDT_OFF_2H
__CONFIG _CONFIG3H, _MCLRE_ON_3H & _LPT1OSC_OFF_3H & _PBADEN_OFF_3H & _CCP2MX_ON_3H
__CONFIG _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _ICPRT_OFF_4L & _XINST_OFF_4L & _DEBUG_OFF_4L
endasm

Then remove the pauses in your loops, USBSERVICE must be called every ~1ms or less. (when enumerating)

After making those changes, I was able to get your program to enumerate on an 18F4550. Don't have a 2550.
<br>

jizyjuice
- 7th April 2007, 21:09
Well I changed the config files and took out the pause in the code. Still no enumeration. Could this be a hardware problem?

I attached everything the same way as the 4550 pictured by easyhid, but just adapted to the 2550.

Darrel Taylor
- 7th April 2007, 22:20
There's always a chance for a hardware problem. But that's a liitle hard to troubleshoot on this end.
The schematic is good though.

Just noticed you have a DEFINE LOADER_USED 1

Are you using a bootloader?

jizyjuice
- 7th April 2007, 22:27
No im not, im using melabs pic programmer. Should I take out that define statement?

jizyjuice
- 7th April 2007, 22:36
Okay, Finally I got the thing to show up on the pc! A 1k pull up resistor needs to be put on D+ and Vsub!! I was under the assumption that there was an internal pull up resistor there. Maybe I didn't configure that in the code.

Well Thanks for everyones help so far.

The windows doesnt recognize the device tho. So it wont enumerate as an HID device yet.

Darrel Taylor
- 8th April 2007, 20:35
There are internal pull-ups. And EasyHID configures them for Full-Speed, so you shouldn't need external ones.

Did you use all the configs from post #11?

In particular _VREGEN_ON_2L.

Your original configs had that turned OFF, just want to make sure it's turned ON now.


Should I take out that define statement?

It doesn't really matter, it's fine even if not using a bootloader. But if you were using a bootloader it may have caused problems with the config settings, so I thought I'd ask.
<br>

jizyjuice
- 8th April 2007, 21:08
I used the config code from post 11, but _BORV_2_2L and _FCMEN_OFF_1H dont seem to be define for the 2550, so I took them out.

Is there another file i need to include to get these fuses to work correctly?

Darrel Taylor
- 8th April 2007, 21:47
You still have MPASM 5.02 so it's _FCMEM_OFF_1H
That'll change after you upgrade MPASM.

_BORV_2_2L is defined for the 2550. I can see it in the .LST file in your .ZIP in post #10
Can't image why there would be a problem with it. But since it's in the same line as _VREGEN_ON_2L, it makes me wonder if there's something else wrong with that line which caused the error.
<br>

jizyjuice
- 8th April 2007, 22:13
I looked at the list file and it should be _BORV_21_2L. So, now I've set the fuses correctly, nothing happens now. Windows doesnt pop up with anything, not even usb device unrecognized. I have no idea what could be wrong

jizyjuice
- 8th April 2007, 22:18
I set the fuses finally. The brown out reset voltage fuse is _BORV_21_2L, found this looking through the lst file. Now nothing seems to work, not even simple LED flashes. I have no idea what is going on.

Darrel Taylor
- 8th April 2007, 23:16
Now that you get "nothing". It seems like FCMEM_OFF is doing it's job, and now it's not running on the internal oscillator.

I think your problem might be the 33pf caps on the crystal. Or a bad/wrong crystal.

The datasheet shows that it should be around 22pf for 20mhz.
With FCMEM_ON, the chip will switch over to the internal oscillator if the primary isn't working. You'll see LED's blink, but it's not the right frequency for USB to work.
<br>
___________
DT

Q. Why do they put braille on the number pads of drive-through bank machines?

rhino
- 9th April 2007, 04:40
Q. Why do they put Braille on the number pads of drive-through bank machines?


Q. Why do they put Braille on the number pads of drive-through bank machines?

A. The manufacture of the number pads on bank machines, have Braille on the numbers. Whether it is a drive through or walk up. It would be expensive to change the number pads on drive through machines, or put the braille enhanced number pads on walk up. The buttons being mass produced, are put on all of the number pads, no matter where they are located.

Source:http://www.confusionwithin.us/docofbs/?p=11 (http://www.confusionwithin.us/docofbs/?p=11)

jizyjuice
- 9th April 2007, 20:40
Okay I finally got it to work!

I had to set the fuse values in melabs serial programmer as well as the fuses in the config files. I didn't know the programmer would rewrite the config values from picbasic pro.

Thanks for the help guys!