I'm making a USB HID device using PIC18F2550 using 20 MHz crystal input and using the MikroC PRO C compiler for PIC.
These are my configuration settings:
unsigned char readbuff[64] absolute 0x500;
unsigned char writebuff[64] absolute 0x540;
char cnt;
char kk;
void interrupt() {
USB_Interrupt_Proc();
}
void main()
{
TRISA = 0;
ADCON1 |= 0x0f;
CMCON |= 7;
HID_Enable(&readbuff, &writebuff);
while(1)
{
/*
LATA=0;
delay_ms(200);
LATA=0xFF;
delay_ms(200);
*/
while(!HID_Read())
;
for(cnt=0; cnt<64; cnt++)
writebuff[cnt] = readbuff[cnt];
while(!HID_Write(&writebuff, 64))
;
}
}
Also included in the project is the file USBdesc.c which can be generated inside the HID terminal of MikroC. But the device is not detected at all...
[UPDATE]
I've tried the older version on MikroC, that is, version 8.2, and I got it working (the HID device gets detected.). But I still can't make it work with the MikroC PRO.
PS.: To make sure the microcontroller is working fine, I loaded a sample hex file for a USB HID mouse onto the microcontroller, and it was working. I just can't figure out what's wrong with my code...