USB Endpoints


Closed Thread
Results 1 to 13 of 13

Thread: USB Endpoints

  1. #1
    Join Date
    Oct 2003
    Location
    Australia
    Posts
    257

    Unhappy USB Endpoints

    Does anybody understand what end points are?

    eg
    USBIn endpoint,buffer,countvar, label
    USBOut endpoint,buffer,count, label


    Trying to get my head around this and not gettin very far

    Squib

  2. #2
    Join Date
    Jan 2007
    Posts
    70

    Default

    The USB 2.0 specification from usb.org discuses endpoints.

  3. #3
    Join Date
    Mar 2006
    Location
    Hyderabad (India)
    Posts
    123

    Default

    Quote Originally Posted by Squibcakes View Post
    Does anybody understand what end points are?

    eg
    USBIn endpoint,buffer,countvar, label
    USBOut endpoint,buffer,count, label


    Trying to get my head around this and not gettin very far

    Squib
    please try this

    http://www.symbian.com/developer/tec...Constants.html
    Regards,
    Sarma

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

    Default

    Endpoints are just blocks of RAM on the device that are used for inbound
    and outbound data exchange between the device & USB host.
    Regards,

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

  5. #5
    Join Date
    Oct 2003
    Location
    Australia
    Posts
    257

    Default

    Still not getting it.

    I guess what i am trying to ask is how do I know what value to set as an endpoint number? ie 0 1 2 or 3?

    Squib

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

    Default

    With PBP, you have a boat-load of USB assembly language 'framework' files
    that get included at compile time. One of these is the 'descriptor' file. This
    one includes your endpoint initialization/setup info - along with tons of other
    information.

    ; HID
    ; Endpoints Allocation
    #define HID_INTF_ID 0x00
    #define HID_UEP UEP1
    #define HID_BD_OUT ep1Bo
    #define HID_INT_OUT_EP_SIZE 8
    #define HID_BD_IN ep1Bi
    #define HID_INT_IN_EP_SIZE 8
    #define HID_NUM_OF_DSC 1

    If your 'Endpoints Allocation' section looks similar to the one above, then you
    would issue USBIn 1, USBBuffer, blah, blah to use endpoint 1.

    USBOut would also use endpoint 1.

    PBP's USBIn & USBOut commands are pretty generic, and don't really do much
    except call the .asm USB framework routines, and pass data. The real meat
    of what's going on is handled by the assembler USB framework files.

    It's a great deal to learn if you want to get 'really' familiar with USB - for sure.
    The Microchip C18 'C' USB framework files are easier to understand than the
    .asm files MeLabs ported over from C18. If you're not familiar with assembler,
    you might find those easier to decipher.
    Regards,

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

  7. #7
    Join Date
    Oct 2003
    Location
    Australia
    Posts
    257

    Default

    Thanks Bruce,

    I'm away from my pic for a while but will look into it somemorewhen I get back....

    Cheers
    Squib

  8. #8
    Join Date
    May 2005
    Posts
    33

    Default re: endpoints

    this is just wat i understand about endpoints... wish to share.. i've been working on a usb keyboard from my previous company therefore kinda know a little bout how endpoint works... basicly endpoint 1 is used for setup and cofig and also for mass storage if i am not wrong... the rest is up to you to use and whether u have define its endpoint descriptor... for example u might have a keyboard with a bootloader probably for the display on the keyboard i.e. an lcd... u can use endpoint 2 for ur keyboard and proly endpoint 3 for communicating with the pc just for the bootloader or the lcd display for example.. its more like a databus but with different address for specific thigns.. checkout the HID usage tables from usb.org for more information on descriptor files and such... and if u have a usb hub build in to the keyboard then u can proly also have endpoint 4 for ur mouse for example..

    regards..

    dan

  9. #9
    Join Date
    Oct 2003
    Location
    Australia
    Posts
    257

    Question

    Thanks nimonia,

    Yeah I just use EP 1 for my usb programs and it seems to always work. There is a lot of stuff out there on USB, but most of it's jargon and doesn't explain it easily.

    I too have been messing with a HID keyboard interface and almost have it working.

    I can mimic the Num lock, scroll lock, and caps lock leds on my test PCB when they're pressed on the main PC keyboard.

    I can send the special keys (shift, control, GUI)

    I can and send regular key chars but... I have a problem with the chars repeating. So if I press the key "J" for instances it keeps on sending, my program seems to be stuck in the DoUSBout out loop. I've tried sending a $00 code as a keystop but this doesn't work.

    Have you run into this problem at all? Anyone else?
    Cheers
    Squib

    ----

    OK I sussed this one out hrs after posting... always the way!
    Last edited by Squibcakes; - 10th May 2007 at 02:05.

  10. #10
    Join Date
    May 2005
    Posts
    33

    Default

    yeap.. happen to me the first time.. u said u send $00 keystop u mean as the USBout buffer right.. tht should do the trick.. but if it doesnt then proly it could be the simple things like maybe u were sending a variable out and u didnt clear the variable to $00... always clear after sending them once.. wat i do is clear before sending and after sending.. just a suggestion if it still repeating then proly its just a small routine mistake somewhere..

    one mroe thing the scan key routine i did would check for special modifier keys first.. keep it in a variable then check for normal keys and add them to the variable.. then only u send it out..
    Last edited by nimonia; - 11th May 2007 at 03:14.

  11. #11
    Join Date
    Oct 2003
    Location
    Australia
    Posts
    257

    Default

    Hi,

    Yep, thats exactly what I've been doing too. It's great when the penny finally drops with this USB stuff!

    Cheers
    Squib

  12. #12
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429

    Default

    Quote Originally Posted by Squibcakes View Post
    Thanks nimonia,

    Yeah I just use EP 1 for my usb programs and it seems to always work. There is a lot of stuff out there on USB, but most of it's jargon and doesn't explain it easily.

    I too have been messing with a HID keyboard interface and almost have it working.

    I can mimic the Num lock, scroll lock, and caps lock leds on my test PCB when they're pressed on the main PC keyboard.

    I can send the special keys (shift, control, GUI)

    I can and send regular key chars but... I have a problem with the chars repeating. So if I press the key "J" for instances it keeps on sending, my program seems to be stuck in the DoUSBout out loop. I've tried sending a $00 code as a keystop but this doesn't work.

    Have you run into this problem at all? Anyone else?
    Cheers
    Squib

    ----

    OK I sussed this one out hrs after posting... always the way!
    Squibcakes, could you post your code for using USBIN to receive the PC's packets with the keyboard LED status?

    I'm also making a USB keyboard, and I've got the PIC->PC communication working perfectly, but struggling with the PC->PIC communication.

    Thanks

  13. #13
    Join Date
    Jun 2006
    Posts
    13

    Cool

    look, here is a interrupt handler of keyboard LED on 16C745 / 765

    ' Define interrupt handler
    DEFINE INTHAND usbint
    ' Assembly language interrupt handler
    asm
    ; W, STATUS and PCLATH registers already saved, save FSR
    usbint movf FSR, W
    movwf fsave
    ; Check interrupt source and vector there
    movlw high ServiceUSBInt
    movwf PCLATH
    btfsc PIR1, USBIF
    call ServiceUSBInt
    btfsc PIR2, USBIF
    call ServiceUSBInt
    ; Restore saved registers
    banksel UIR
    movf 0xC8,w
    clrf STATUS
    movwf kbdLED
    movf fsave, W
    movwf FSR
    movf psave, W
    movwf PCLATH
    swapf ssave, W
    movwf STATUS
    swapf wsave, F
    swapf wsave, W

    retfie ; Return from interrupt
    endasm

    before the kbdLED should be defined in Picbasic static (important !):
    kbdLED VAR BYTE bank0 system

    on 18F Chips the code have to be placed in the USB interrupt routine.
    LEDs are using the EP0 control transfere.
    To get pc->pic communication use a component device with a HID + Keyboard interface.
    Last edited by sirnoname; - 27th June 2007 at 17:48.
    www.x-sim.de
    freeware simulator software
    with real MS Force Feedback solution

Similar Threads

  1. USB CDC Communications for Dummies!
    By Squibcakes in forum USB
    Replies: 104
    Last Post: - 15th January 2014, 13:43
  2. USB Bootloader.
    By HenrikOlsson in forum USB
    Replies: 22
    Last Post: - 2nd May 2013, 02:46
  3. Simple USB Comms Problem
    By awmt102 in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 6th January 2010, 20:17
  4. One USB keyboard to Two USB Ports
    By picnaut in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 11th June 2009, 00:04
  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