PDA

View Full Version : usb - device not recognised



mpardinho
- 8th January 2007, 13:02
my code, create by easyhid



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 DoUSBIn
gosub DoUSBOut
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



i tryied cristal 20mhz or 8mhz and "device not recognised",
with 48 not detect

i tested demo program usbcdc and too "device not recognised".

Dave
- 8th January 2007, 13:32
mpardinho, If you are defining 48 Mhz. as your clock speed to PBP and you are using a 4X PLL then the master crystal frequency should be 4X less or 12 Mhz.

Dave Purola,
N8NTA

mister_e
- 8th January 2007, 17:47
If you don't use Mecanique Bootloader, you don't need the DEFINE LOADER_USED 1' line.

Make sure your Vusb cap is around 0.47uf.

and then, try the following
http://www.picbasic.co.uk/forum/showthread.php?t=5418

With a 8MHZ Crystal you need to modify the config fuses to...


__CONFIG _CONFIG1L, _PLLDIV_2_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
; ; ; USB clock source comes from the 96 MHz PLL divided by 2
; ; [OSC1/OSC2 Src: /1][96 MHz PLL Src: /2]
; Divide by 2 (8 MHz oscillator input)


__CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
; ; ; Oscillator Switchover mode disabled
; ; Fail-Safe Clock Monitor disabled
; HS oscillator, PLL enabled, HS used by USB

__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

Enjoy!