• AVR Freaks

Helpful ReplyHot!Host - HID - Keyboard in pic24FJ32GB002 (SOLVED)

Author
KALLITOS
New Member
  • Total Posts : 13
  • Reward points : 0
  • Joined: 2012/03/06 16:44:28
  • Location: 0
  • Status: offline
2012/05/29 09:45:29 (permalink)
0

Host - HID - Keyboard in pic24FJ32GB002 (SOLVED)

I tried the sample code hid usb host keyboard using the ethernet starter kit and it worked properly, now I want to do is put it into a pic24fj32gb002 and only send by RS232 and eliminate the handling of lcd. using the optimization code C30 enters the pic memory but not working, I'm making the management of the switch that VBUSON desolde of the starter kit, but does not work.
can use the code example in this pic?

the attached diagram.

regards
post edited by KALLITOS - 2012/06/03 21:36:33

Attached Image(s)

#1
DarioG
Allmächtig.
  • Total Posts : 54081
  • Reward points : 0
  • Joined: 2006/02/25 08:58:22
  • Location: Oesterreich
  • Status: offline
Re:Host - HID - Keyboard in pic24FJ32GB002 2012/05/31 03:49:56 (permalink)
0
What are you asking for exactly?

GENOVA :D :D ! GODO
#2
KALLITOS
New Member
  • Total Posts : 13
  • Reward points : 0
  • Joined: 2012/03/06 16:44:28
  • Location: 0
  • Status: offline
Re:Host - HID - Keyboard in pic24FJ32GB002 2012/05/31 09:42:49 (permalink)
0
hi, thanks for responding.
I want to fix this step by step, the PIC24 probe with the following fuses and works well, when I paste in the example of the host hid usb keyboard, the microcontolador does nothing, I have placed LEDs to blink when running this code, but do not blink, I think it is for the fuses. as I can modify.
 
_CONFIG1(WDTPS_PS1 & FWPSA_PR128 & FWDTEN_OFF & ICS_PGx3 & GWRP_ON & GCP_OFF & JTAGEN_OFF)
_CONFIG2(POSCMOD_NONE & IOL1WAY_OFF & I2C1SEL_PRI & OSCIOFNC_ON  & FCKSM_CSDCMD & FNOSC_FRCPLL & PLL96MHZ_ON & PLLDIV_DIV2 & IESO_OFF)
_CONFIG3(SOSCSEL_IO & WUTSEL_LEG & WPDIS_WPDIS & WPCFG_WPCFGDIS & WPEND_WPENDMEM )
_CONFIG4(DSWDTPS_DSWDTPS3 & DSWDTOSC_LPRC & RTCOSC_LPRC & DSBOREN_OFF & DSBOREN_OFF )
 
regards.
 
 
#3
DarioG
Allmächtig.
  • Total Posts : 54081
  • Reward points : 0
  • Joined: 2006/02/25 08:58:22
  • Location: Oesterreich
  • Status: offline
Re:Host - HID - Keyboard in pic24FJ32GB002 2012/05/31 10:21:44 (permalink)
0
Ok, I have these CONFIG settings for a GB002 PIC, with USB and internal oscillator:
 

  _CONFIG1(WDTPS_PS8192 & FWPSA_PR32 & WINDIS_OFF & FWDTEN_ON & ICS_PGx1 & GWRP_OFF & GCP_OFF & JTAGEN_OFF)
  _CONFIG2(POSCMOD_NONE & I2C1SEL_SEC & IOL1WAY_OFF & OSCIOFNC_ON & FCKSM_CSDCMD & FNOSC_FRCPLL & PLL96MHZ_ON & PLLDIV_NODIV & IESO_ON)        // osc int
    // POSCMOD_NONE sopra serve per poter usare OSCIOFNC ossia ra2-3!
    // non uso I2C hardware ma cmq setto i pin su ASCL/ASDA...
//        _CONFIG3(WPFP_WPFP0 & SOSCSEL_SOSC & WUTSEL_LEG & WPDIS_WPDIS & WPCFG_WPCFGDIS & WPEND_WPENDMEM)            SOSC??? secondari osc.. NO RB4!
  _CONFIG3(WPFP_WPFP0 & SOSCSEL_IO & WUTSEL_LEG & WPDIS_WPDIS & WPCFG_WPCFGDIS & WPEND_WPENDMEM)
  _CONFIG4(DSWDTPS_DSWDTPS3 & DSWDTOSC_LPRC & RTCOSC_SOSC & DSBOREN_OFF & DSWDTEN_OFF)


 
(note that USB with internal oscillator is not stated as "working" in the datasheet, but it usually does)

GENOVA :D :D ! GODO
#4
KALLITOS
New Member
  • Total Posts : 13
  • Reward points : 0
  • Joined: 2012/03/06 16:44:28
  • Location: 0
  • Status: offline
Re:Host - HID - Keyboard in pic24FJ32GB002 2012/05/31 15:04:55 (permalink)
0
ok, I tried your fuses, but the microcontroller is reset, I made a modification in my fuses in PLLDIV_NODIV and no longer resets, I enabled usart2, and send the reset state, connected, disconnected as the case, when I plug the keyboard does not detect anything is disconnected, I removed the switch tps2011, and made the connection of VBUS to 5V directly but does not work.
I can do?

i am using the code example AN1212.


regards.
#5
KALLITOS
New Member
  • Total Posts : 13
  • Reward points : 0
  • Joined: 2012/03/06 16:44:28
  • Location: 0
  • Status: offline
Re:Host - HID - Keyboard in pic24FJ32GB002 2012/06/01 07:10:19 (permalink)
0
this is the report whith debug enabled:
 
HOST: Initializing DETACHED state.
[>HOST: Starting settling delay.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~HOST: Resetting the device.
HOST: Low Speed!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~HOST: Reset complete.
~~~~~~~~~~~HOST: Reset complete.
HOST: Getting Device Descriptor size.
!!!HOST: Getting device descriptor.
!!!!!HOST: Validating VID and PID.
HOST: Device not yet validated
HOST: Setting device address.
!!HOST: Getting Config Descriptor size.
!!!HOST: Getting Config Descriptor.
!!!!!!!!!!HOST: Client driver found.
HOST: Client driver found.
HOST: Parse Descriptor success
HOST: Determine OTG capability.
HOST: ...No OTG.
HOST: Set configuration.
!!HOST: Initializing client drivers...
HOST: Scanning interfaces.
HID: USBHostHIDInitialize(0x00)
HID: Checking descriptor 1 ...
HID:  Checking interface...
HID:  Checking interface...
HID: Valid device info
HID:  Checking interface...
HID: Valid device info
HID: Interrupt endpoint IN: 82 Interrupt endpoint OUT: 00
HID: USBHostHIDInitialize(0x00)
!!!!!!!!!!!!!!!!!!!!!!!!!!
HID Error Reported :  01 
 
In the usb_host.c the states machine is still in this case
 
        case STATE_RUNNING:
            switch (usbHostState & SUBSTATE_MASK)
            {
                case SUBSTATE_NORMAL_RUN:
                    #ifdef DEBUG_MODE
                        UART2PrintString( "HOST: Runing.\r\n" );
                    #endif
                    break;
 
i made an printf uart2 "RUNING" and the microcontroller send this text continuosly.
the error comes from usb_host_hid_parser.c, _USBHostHID_Parse_Report.
and according to the report, the error in usb_commom.h is   USB_INVALID_STATE
 
I do not know else to do.
 
regards
post edited by KALLITOS - 2012/06/01 09:21:13
#6
yts
Super Member
  • Total Posts : 605
  • Reward points : 0
  • Joined: 2005/09/06 17:45:30
  • Status: offline
Re:Host - HID - Keyboard in pic24FJ32GB002 2012/06/02 19:29:54 (permalink)
0
Strange. I use a Host - HID – Keyboard example of MAL on PIC24FJ64GB002.
I confirm that this example works properly. The log-file is as follows,

***** Microchip Explorer USB Keyboard Host Demo  *****

HOST: Initializing DETACHED state.
Device Detached
[>HOST: Starting settling delay.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~HOST: Resetting the device.
HOST: Low Speed!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~HOST: Reset complete.
~~~~~~~~~~~HOST: Reset complete.
HOST: Getting Device Descriptor size.
!!!!HOST: Getting device descriptor.
!!!!!!!!!!!!!HOST: Validating VID and PID.
HOST: Device not yet validated
HOST: Setting device address.
!!!!HOST: Getting Config Descriptor size.
!!!!HOST: Getting Config Descriptor.
!!!!!!!!!!!!!!!!!!!!!HOST: Client driver found.
HOST: Parse Descriptor success
HOST: Determine OTG capability.
HOST: ...No OTG.
HOST: Set configuration.
!!!!HOST: Initializing client drivers...
HOST: Scanning interfaces.
HID: USBHostHIDInitialize(0x00)
HID: Checking descriptor 1 ...
HID:  Checking interface...
HID:  Checking interface...
HID: Valid device info
HID: Interrupt endpoint IN: 81 Interrupt endpoint OUT: 00
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!HID: Memory for Report Descriptor: 34HID-HOST: ... 2nd Parse
            Explorer16 Board
USB HIDHost Demo
|||||||||||||||||||||||||||||||||||||||||!|}|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||!|}
HID: Raw Report  00-00-00-00-00-00-00-00-|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||!|}||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||!|}||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||


Can you try to use another keyboard for your PIC board?
#7
chinzei
Super Member
  • Total Posts : 2250
  • Reward points : 0
  • Joined: 2003/11/07 12:39:02
  • Location: Tokyo, Japan
  • Status: offline
Re:Host - HID - Keyboard in pic24FJ32GB002 2012/06/03 07:46:23 (permalink) ☄ Helpful
0
Hi KALLITOS and yts,

"HID Error Reported :  01" at the last line of the debug trace means heap overflow.
http://www.microchip.com/forums/fb.ashx?m=640685

Maybe, the keyboard gives a large report descriptor.
Increase the heap size (Project menu > Build Options), rebuild the project, and try the trace again.

I suppose we'll see another error with this large report descriptor [;]
It's because such a large report descriptor should define two or more report pairs with report IDs.
But the host keyboard example assumes single report without report ID, like this joystick (mouse) case.
http://www.microchip.com/forums/fb.ashx?m=633555

Anywya, increase the heap size, and see what occurs, next.

Tsuneo
#8
KALLITOS
New Member
  • Total Posts : 13
  • Reward points : 0
  • Joined: 2012/03/06 16:44:28
  • Location: 0
  • Status: offline
Re:Host - HID - Keyboard in pic24FJ32GB002 (solved) 2012/06/03 21:22:28 (permalink)
0
Funcionó!!!!.
 
Hi Chinzei, the circuit finally worked, I placed heap size in 1250 and is already working.
thank you very much, I can continue my project.
 
a question: This code also handles barcode scanner usb?
post edited by KALLITOS - 2012/06/03 21:35:39
#9
yts
Super Member
  • Total Posts : 605
  • Reward points : 0
  • Joined: 2005/09/06 17:45:30
  • Status: offline
Re:Host - HID - Keyboard in pic24FJ32GB002 2012/06/04 04:47:20 (permalink)
0
Hi Chinzei

Thank you. I am always impressed by your knowledge.
 
yts
#10
chinzei
Super Member
  • Total Posts : 2250
  • Reward points : 0
  • Joined: 2003/11/07 12:39:02
  • Location: Tokyo, Japan
  • Status: offline
Re:Host - HID - Keyboard in pic24FJ32GB002 (solved) 2012/06/04 09:18:15 (permalink)
+2 (1)
Dario and yts,
I just placed a last touch. Without your guide, he couldn't start.
 
KALLITOS:
a question: This code also handles barcode scanner usb?

Most likely. Historically, barcode scanner has emulated a keyboard over the current interface of the time (RS232, PS/2, USB).
You may need to add some code to the firmware, to enable options of your target scanner. In such case, a USB sniffer will tell you the way to set up the options, while the scanner connects to a PC. And then, your firmware arms it to run the scanner more smartly wink

Tsuneo
post edited by chinzei - 2012/06/04 09:37:38
#11
KALLITOS
New Member
  • Total Posts : 13
  • Reward points : 0
  • Joined: 2012/03/06 16:44:28
  • Location: 0
  • Status: offline
Re:Host - HID - Keyboard in pic24FJ32GB002 (solved) 2012/06/04 12:44:03 (permalink)
0
OK, thank you very much, proves with barcode scanner.
 
regards.
#12
Tom700
New Member
  • Total Posts : 3
  • Reward points : 0
  • Joined: 2020/03/25 03:25:36
  • Location: 0
  • Status: offline
Re: Host - HID - Keyboard in pic24FJ32GB002 (SOLVED) 2020/03/26 02:42:33 (permalink)
0
Hi KALLITOS,
 
Have you succeeded with you HID host? How Does it work?
I'm looking at PIC32MM0064GPM028 to make a HID Host to interface a USB barcode reader to uC via USART.
I wonder if the above pic has enough flash to handle this? How much flash have you used?
 
best regards
Tom 
#13
Jump to:
© 2020 APG vNext Commercial Version 4.5