Pic18f2550 HID Keyboard


Closed Thread
Results 1 to 21 of 21

Hybrid View

  1. #1
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,170

    Default Re: Pic18f2550 HID Keyboard

    Just noticed something else, only send when you have to:

    Quote Originally Posted by Demon View Post
    Code:
    if portb.7 = 1 then
    USBBuffer[0] = 0
    USBBuffer[1] = 0
    USBBuffer[2] = $33 ; 33 = ";"
    USBBuffer[3] = 0
    USBBuffer[4] = 0
    USBBuffer[5] = 0
    USBBuffer[6] = 0
    USBBuffer[7] = 0
    gosub DoUSBOut
    ELSE
    ....clear buffer...
    ENDIF
    Robert

  2. #2

    Default Re: Pic18f2550 HID Keyboard

    Hi there,

    Is that your entire code?

    Shouldn't be also something like: " include KBDDESC.ASM " in the main code ?

    Regards
    Rui

  3. #3
    Join Date
    Jan 2012
    Location
    Grid EN19MV
    Posts
    159

    Default Re: Pic18f2550 HID Keyboard

    Wouldn't it shorten things to do this:

    Code:
    if portb.7 = 1 then
        FOR i = 0 to 7
             IF i = 2 then
                 USBBuffer[i] = $33 ; 33=";"
             ELSE
                 USBBuffer[i] = 0
             ENDIF
        NEXT i
        gosub DoUSBOut
    ELSE
    ....clear buffer...
    ENDIF
    Last edited by andywpg; - 15th September 2014 at 23:29.
    "I have noticed that even those who assert that everything is predestined and that
    we can change nothing about it still look both ways before they cross the street"


    -Stephen Hawking

  4. #4
    Join Date
    Jun 2007
    Posts
    25

    Default Re: Pic18f2550 HID Keyboard

    Many Thanks , Its Working Now , And The Code Is Down , But Any One Knows How Can I Include Multimedia Keys (Play,Stopn, Mute . . .etc) , i know i must add it to usb descreptor but i never knows how , i read alot without luck .


    DEFINE OSC 48
    @ __CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
    @ __CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H
    @ __CONFIG _CONFIG2H, _WDT_OFF_2H & _WDTPS_512_2H
    @ __CONFIG _CONFIG3H, _PBADEN_OFF_3H & _MCLRE_OFF_3H
    @ __CONFIG _CONFIG4L, _LVP_OFF_4L &_XINST_OFF_4L
    INCLUDE "DT_INTS-18.bas"
    ASM
    INT_LIST macro
    INT_Handler USB_INT, _DoUSBService, ASM, yes
    endm
    INT_CREATE
    endasm
    USBBufferSizeTX con 8
    USBBufferSizeRX con 8
    USBBufferCount Var Byte
    USBBufferIn var byte[8]
    USBBufferOut Var Byte[8]
    DataToSend var byte[8]
    asm
    SendUSB macro array
    variable i=0
    while i<8
    MOVE?BB (array+i),(_USBBufferOut+i)
    i+=1
    endw
    L?CALL _DoUSBOut
    endm
    endasm
    SwHwInit:
    GOSUB DoUSBinit:
    Start:
    clear
    if portb.7 = 1 then
    DATATOSEND[1] = 0
    DATATOSEND[2] = 0
    DATATOSEND[3] = $51 ; if i change it to be "80" >> volume up, it didnt work .
    DATATOSEND[4] = 0
    DATATOSEND[5] = 0
    DATATOSEND[6] = 0
    DATATOSEND[7] = 0
    gosub DoUSBOut
    else
    clear
    DATATOSEND[1] = 0
    DATATOSEND[2] = 0
    DATATOSEND[3] = 0
    DATATOSEND[4] = 0
    DATATOSEND[5] = 0
    DATATOSEND[6] = 0
    DATATOSEND[7] = 0
    endif
    @ SendUSB _DataToSend
    gosub dousbin
    goto start
    DoUSBIn:
    @ INT_DISABLE USB_INT
    USBBufferCount = USBBufferSizeRX
    USBService
    USBIn 1, USBBufferin, USBBufferCount, Timeout
    Timeout:
    @ INT_ENABLE USB_INT

    DoUSBOut:
    @ INT_DISABLE USB_INT
    WaitPC:
    USBBufferCount = USBBufferSizeTX
    USBService
    USBOut 1, USBBufferOut, USBBufferCount, Waitpc
    @ INT_ENABLE USB_INT
    return
    usb_device_state var byte EXT
    CONFIGURED_STATE CON EXT
    DoUSBinit:
    pause 500
    usbinit
    repeat
    usbservice
    until usb_device_state = CONFIGURED_STATE
    @ INT_ENABLE USB_INT
    return
    DoUSBService:
    usbservice
    @ INT_RETURN
    Attached Files Attached Files

  5. #5
    Join Date
    Sep 2009
    Posts
    755

  6. #6
    Join Date
    Jun 2007
    Posts
    25

    Default Re: Pic18f2550 HID Keyboard

    Sorry , But Didn't work i tried it , Beside its just multimedia keybad not full qwerty & Media Keyboard .

  7. #7
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,170

    Default Re: Pic18f2550 HID Keyboard

    You forgot element zero (length of 8 is from 0 to 7):

    DATATOSEND[0] = 0

    I can't help you with the keyboard command, sorry.

    Robert

  8. #8
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,170

    Default Re: Pic18f2550 HID Keyboard

    Code:
    DoUSBinit:
    pause 500
    usbinit 
    repeat 
    usbservice
    until usb_device_state = CONFIGURED_STATE
    @ INT_ENABLE USB_INT
    return
    1. That PAUSE can screw up USB.

    2. DT INT takes care of USB INIT for you.

    3. You shouldn't have to write your own assembler routines for USB, they should be available in DT INT.

    4. I didn't see ReEnterPBP-18.bas included.

    Robert

Similar Threads

  1. USB HID is slower than often using PIC18f2550
    By Ahmadabuomar in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 16th November 2010, 14:05
  2. HID Keyboard Example
    By apitaru in forum USB
    Replies: 8
    Last Post: - 6th August 2010, 16:27
  3. PIC18F2550 Newbie
    By JeffnDana in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 26th April 2007, 15:13
  4. Replies: 3
    Last Post: - 18th January 2006, 14:12
  5. USB, PIC18F2550 and VB
    By Tissy in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 27th November 2005, 18:37

Members who have read this thread : 0

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