Quote Originally Posted by Rob View Post
Are you using a 48MHz clock source for the USB and have you set bit 2 of the UCFG register to enable Full-speed?
Thank Rob, however, I cannot set UCFG.2=1 or FSEN=1 in my program. When I do this, I get error message . the below is my source code in pbp

================================================== =================
DEFINE OSC 48
DEFINE LOADER_USED 1

USBBufferSizeMax con 64 ' maximum buffer size
USBBufferSizeTX con 64
USBBufferSizeRX con 64

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

'Variables -----------------
I var byte
Ana var word

' Define ports
SP1 VAR PORTC.0

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

TRISD = %11110000 'Set PORTD 0-3 to output, 4-7 to input
'UCFG.2 = 1

usbinit ' initialise USB...

ProgramStart: 'Just want to test the USB speed

high sp1
gosub DoUSBIn
low sp1
gosub DoUSBOut

goto ProgramStart

' ************************************************** **********
' * receive data from the USB bus *
' ************************************************** **********
DoUSBIn:
USBBufferCount = USBBufferSizeRX ' RX buffer size
USBService ' keep connection alive (executed at least every 10ms)
USBIn 1, USBBuffer, USBBufferCount, DoNext ' read data, if available
PORTD = usbbuffer[2]
Ana = (usbbuffer[0] << 7) | usbbuffer[1]
freqout sp1,500,ana
DoNext:
return

' ************************************************** **********
' * wait for USB interface to attach *
' ************************************************** **********
DoUSBOut:
USBBufferCount = USBBufferSizeTX ' TX buffer size
USBService ' keep connection alive (executed at least every 10ms)
USBOut 1, USBBuffer, USBBufferCount, DoUSBOut ' if bus available, transmit data
return
================================================== =================

Do you know other way to get Full-Speed mode with pbp ?
Thank you in advance.