Page 1 of 1

USB HID Keyboard on PIC18F14K50

Posted: Wed Jun 27, 2012 5:42 am
by dproffer
I am trying to use the example code and USB libraries in Flowcode 5.2 Pro to create a USB Keyboard on the PIC18F14K50, no luck.

The code compiles and loads on the chip fine, Mac OS X 10.7, Windows XP, Windows 7 all see the HID device fine, but no characters are transmitted to the OS. I am using a simplified version of the USB Keyboard demo app from Matrix Multimedia v5 example file, that just send a single character from the PIC to the host when a button is pressed on the PIC. Nothing every comes through.

I note in some form posts from WAY back in 2010/2011 that after considerable work, a HID was working on the PIC18F14K30 chip, however people on this thread seem to call out specifically that that could would not work on the K50. Seem odd.

I have a simple USB serial port program working fine on the PIC18F14K50, works with Windows, OS X and Linux hosts fine.

I have attached a simple flow code test routine that does not work.

Thanks in advance for any help.
Dave

Re: USB HID Keyboard on PIC18F14K50

Posted: Wed Jun 27, 2012 2:26 pm
by Benj
Hi Dave,

Thanks for letting us know how your getting on with the K50, glad it is working correctly on the USB.

For the keyboard to work you need to be sending the packet of 8 bytes. Look at the example file again and you will see the HID component properties is setup in a way to receive a byte for the LED status and transmits 8 bytes. The HID configuration and example send and receive functions also reflect this number.

I think there also should be a excel document somewhere showing what key press the 8-bytes represent. I have attached it here just incase.
HID Keyboard Scan Codes.xls
(37.5 KiB) Downloaded 330 times
Also I found that if you try to send data too soon after the initialise then the host computer will not receive any data. The example should show how we got around this using a delay icon. Another thing to look out for is sending data too often as this can also stop the host from listening, ensure you have a 2nd delay in the loop as shown in the example to ensure this is ok.

Let us know how you get on.

I have moved this post to the v5 forums please visit here for details of how to sign up.
http://www.matrixmultimedia.com/mmforum ... =46&t=9958

Re: USB HID Keyboard on PIC18F14K50

Posted: Thu Jun 28, 2012 9:44 am
by Sparkoids
Hi Dave,

There were issues with the 13K50 which were resolved at that time by Ben.

The 14K50 though still doesn't operate correctly but since i wasn't using it I ignored the problem!


James :-}

Re: USB HID Keyboard on PIC18F14K50

Posted: Tue Jul 03, 2012 12:11 pm
by Gary Freegard
Hi Dave

The problem is that you have not sent a zero data straight after the key data.
So in you flowchart straight after the
  • test[2]=0x59
    SendDataDirect[test]
add
  • test[2]=0x00
    SendDataDirect[test]
This will cause the pc to respond to the simulated key press.

Good luck

Gary

Re: USB HID Keyboard on PIC18F14K50

Posted: Wed Jul 04, 2012 4:23 am
by dproffer
Gary, thank you very much for your code review and post! That was my problem, as you described. My simple keyboard HID button example is working like a champ on the PIC18F14K50.

Re: USB HID Keyboard on PIC18F14K50

Posted: Fri Jul 06, 2012 10:14 am
by Gary Freegard
:D