Problem trying HID Read/Write Example

Beta Testing discussion on mikroC PRO for PIC.
Post Reply
Author
Message
dadoubou
Posts: 22
Joined: 09 Jan 2013 23:16

Problem trying HID Read/Write Example

#1 Post by dadoubou » 13 Jan 2013 11:10

Hi !

As a beginner with PIC HID communication, I started by trying the HID Read-Write Example of MikroC's (4.60) help.

So... It works... but only one time !

Some explainations :

I send a character ('8' for example) using HID Terminal, so I see the PIC immediately responds something like:
0x38, 0x00, 0x00, 0x00, 0x00 [...]

So I try with another character ('A' for example), and I got no answer from the PIC on the HID terminal.

Then, I can try to send anything, the HID Terminal crashes (button 'Send' remains pushed and nothing happens, I can't click anywhere...). Until y reset the PIC, if I try restarting the HID Terminal, my PIC which was seen as a "My PIC Device" as I called it, gets named "Device VID=1234 PID=0001"...

As I can handle a bit C# programming, I made a program to use the HID communication with the PIC, but same problem: first sending : OK, second sending : OK but no answer, and third sending : my application crashes.

I'm using a 18F2450, and the example I use is this one :

Code: Select all

unsigned char readbuff[64] absolute 0x500;   // Buffers should be in USB RAM, please consult datasheet
unsigned char writebuff[64] absolute 0x540;

char cnt;
char kk;

void interrupt(){
   USB_Interrupt_Proc();                   // USB servicing is done inside the interrupt
}

void main(void){
  ADCON1 |= 0x0F;                         // Configure all ports with analog function as digital
  CMCON  |= 7;                            // Disable comparators

  HID_Enable(&readbuff,&writebuff);       // Enable HID communication

  while(1){
    while(!HID_Read())
      ;

    for(cnt=0;cnt<64;cnt++)
      writebuff[cnt]=readbuff[cnt];

    while(!HID_Write(&writebuff,64))
      ;
  }
}
Does someone experienced this problem ? Do you know how can I solve it ?

Thanks in advance,
dadoubou


(I'm French and I hope my English is not too bad)

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Problem trying HID Read/Write Example

#2 Post by filip » 15 Jan 2013 14:14

Hi,

I believe I have answered you here :
http://www.mikroe.com/forum/viewtopic.p ... 50#p204850

Regards,
Filip.

dadoubou
Posts: 22
Joined: 09 Jan 2013 23:16

Re: Problem trying HID Read/Write Example

#3 Post by dadoubou » 15 Jan 2013 16:30

Hi !

Yes, sorry, I didn't know I posted twice, thanks

Post Reply

Return to “mikroC PRO for PIC Beta Testing”