Pic 18f Usb


Closed Thread
Results 1 to 40 of 135

Thread: Pic 18f Usb

Hybrid View

  1. #1
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lengcallrobot View Post
    My question is:
    How can I used PBP to send the data in hight speed mode or full speed mode?
    PIC18xxxx USB capable PICs are not capable of the high speed (480mpbs) mode.

  2. #2
    Join Date
    Jul 2008
    Location
    Now, I live in Tokyo, Japan
    Posts
    6


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    PIC18xxxx USB capable PICs are not capable of the high speed (480mpbs) mode.
    So, how about full speed mode? What to do?

  3. #3
    Join Date
    Feb 2005
    Location
    Essex, UK
    Posts
    94


    Did you find this post helpful? Yes | No

    Default

    Hi Lengcallrobot and welcome to the forums!

    This is taken from the EasyHID help file contained in the EasyHID folder:

    "What is a HID Device?

    ...... One of the major advantages of HID is that you do not need to supply a custom driver, as one is already supplied with the operating system. A limitation of HID is that its data transfer rate is limited to a maximum of 64KB per second. However, this is still significantly faster than RS-232 (115200 baud is approximately 12KB per second)......"

    You should be able to send 64kBytes/sec in Full-speed mode as shown above.

    It looks to me as though you are sending data in Low-speed mode 64kbits/sec (or 8kBytes/sec) from what you have shown.

    Are you using a 48MHz clock source for the USB and have you set bit 2 of the UCFG register to enable Full-speed?

    I could be leading you up the garden path about the speeds but this is my understanding

    Hope this helps

    Rob
    Last edited by Rob; - 15th July 2008 at 09:09. Reason: Really should proof read before posting!

  4. #4
    Join Date
    Jul 2008
    Location
    Now, I live in Tokyo, Japan
    Posts
    6


    Did you find this post helpful? Yes | No

    Default

    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.

  5. #5
    Join Date
    Feb 2005
    Location
    Essex, UK
    Posts
    94


    Did you find this post helpful? Yes | No

    Default

    Thank Rob, however, I cannot set UCFG.2=1 or FSEN=1 in my program. When I do this, I get error message
    I think you're using PBP 2.47 or older so the UCFG register is not included. Try this:

    UCFG var byte EXT
    UCFG.2 = 1

    Cheers

    Rob

  6. #6
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Unless you're using descriptors you found somewhere else, you shouldn't need to mess with
    UCFG. Your PBP USB template descriptor file should have this already in place.

    #define UCFG_VAL _PUEN|_TRINT|_FS|MODE_PP ; Full-speed

    Arguments for the define are listed in the USB18.inc include file under UCFG Initialization
    Parameters.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

Similar Threads

  1. USB CDC Communications for Dummies!
    By Squibcakes in forum USB
    Replies: 104
    Last Post: - 15th January 2014, 13:43
  2. Reading a slave USB with a pic
    By pcaccia in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 25th October 2008, 12:00
  3. Replies: 15
    Last Post: - 30th October 2007, 19:25
  4. USB communication with pic
    By Shamir in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 14th August 2006, 23:43
  5. USB PIC without USB Connection
    By Tissy in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 26th December 2005, 17:39

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts