Error Routine InitUSBdsc not defined

General discussion on mikroC.
Post Reply
Author
Message
neozero
Posts: 2
Joined: 26 Mar 2008 18:18

Error Routine InitUSBdsc not defined

#1 Post by neozero » 06 Apr 2008 20:06

I m doing a program that using PIC18F4550 that could send different alert SMS based on user button input. But while compile i came across this error Routine InitUSBdsc not defined. anyone could help me here?

Code: Select all

unsigned unsigned userRD_buffer[64];
unsigned unsigned userWR_buffer[64];

const char *txtmode = "AT+CMGF=1\r\n";
const char *alert0 = "AT+CMGS=\"60173317358\"\r ALERT 0\n";
const char *alert1 = "AT+CMGS=\"60173317358\"\r ALERT 1\n";
const char *alert2 = "AT+CMGS=\"60173317358\"\r ALERT 2\n";

void interrupt(){
  asm CALL _Hid_InterruptProc
  asm nop
  }//~


//******************************************************************************
//Initialization routine
//******************************************************************************
void Init_Main() {
  //Disable all interrupts
  //Disable GIE, PEIE, TMR0IE, INT0IE, RBIE
  INTCON = 0;
  INTCON2 = 0xF5;
  INTCON3 = 0xC0;

  //Disable all priority level
  RCON.IPEN = 0;
  PIE1 = 0;
  PIE2 = 0;
  PIR1 = 0;
  PIR2 = 0;
  
  //Configure all ports with analog function as digital
  ADCON1 |= 0x0F;
  
  //Port Configuration
  TRISA = 0;
  TRISB = 0b00000111;        //pin RB0, RB1, RB2 are inputs
  TRISC = 0xFF;
  TRISD = 0xFF;
  TRISE = 0x07;

  LATA = 0;
  LATB = 0;
  LATC = 0;
  LATD = 0;
  LATE = 0;
  
  //Clear user RAM
  //Banks [00..07] ( 8 x 256 = 2048 Bytes )
  asm{
    LSFR    FSR0, 0x000
    MVLSW   0x08
    CLRF    POSTINC0, 0
    CPFSEQ  FRR0H, 0
    BRA     $ - 2
    }

  //Timer 0
  T0CON = 0x07;
  TMR0H = (65536-156) >> 8;
  TMR0L = (65536-156) & 0xFF;
  INTCON.T0IE = 1;    //Enable T0IE
  T0CON.TMR0ON = 1;
}//~


//******************************************************************************
//Main Program Routine
//******************************************************************************
void main () {
  char i;
  Init_Main();
  Hid_Enable(&userRD_buffer, &userWR_buffer);
  
  //Configure Button Pins as input
  //TRISB.F0 = 1;
  //TRISB.F1 = 1;
  //TRISB.F2 = 1;

  //infinite loop
  do {
    i=0;
      while(txtmode[i]) {
        userWR_buffer[0]= txtmode[i++];
        while (!HID_Write((unsigned)&userWR_buffer, 1));
      }

    if (RB0){
      i=0;
      while(alert0[i]) {
        userWR_buffer[0]= alert0[i++];
        while (!HID_Write((unsigned)&userWR_buffer, 1));
      }
      //main();
    }
       
    else if (RB1){
      i=0;
      while(alert1[i]) {
        userWR_buffer[0]= alert1[i++];
        while (!HID_Write((unsigned)&userWR_buffer, 1));
      }
      //main();
    }
    
    else if (RB2){
      i=0;
      while(alert2[i]) {
        userWR_buffer[0]= alert2[i++];
        while (!HID_Write((unsigned)&userWR_buffer, 1));
      }
      //main();
    }
  }while (1);
  
  Delay_mS(100);
  HID_Disable();
}//~
thx

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

#2 Post by filip » 07 Apr 2008 14:13

Try copying definit.h , var.h , and USBdsc.c to your project folder, from:

...\mikroElektronika\mikroC\Examples\EasyPIC5\extra_examples\HID-library

This should work now.

M. Abdelkader
Posts: 4
Joined: 18 Sep 2009 21:41

dear sir,

#3 Post by M. Abdelkader » 18 Sep 2009 21:54

filip wrote:Try copying definit.h , var.h , and USBdsc.c to your project folder, from:

...\mikroElektronika\mikroC\Examples\EasyPIC5\extra_examples\HID-library

This should work now.
dear sir,

i trying this link but without any result, is this link correct.
can i put www.befor this link or what, please inform me.

Best Rregards.

pwdixon
Posts: 1431
Joined: 13 Apr 2005 11:14
Location: UK

#4 Post by pwdixon » 19 Sep 2009 13:06

it's a directory on your harddisk

M. Abdelkader
Posts: 4
Joined: 18 Sep 2009 21:41

#5 Post by M. Abdelkader » 19 Sep 2009 20:26

pwdixon wrote:it's a directory on your harddisk
Dear sir,

Frist i would like to thank tou for your interest, i copy the files from the directory you recommended but i still have the same error "Routine initusbdsc not defined"

the code i use is:

unsigned short m, k;
unsigned short userRD_buffer[64];
unsigned short userWR_buffer[64];

void interrupt() {
asm CALL _Hid_InterruptProc
asm nop
}//~

void Init_Main() {
// Disable all interrupts
// Disable GIE, PEIE, TMR0IE, INT0IE,RBIE
INTCON = 0;
INTCON2 = 0xF5;
INTCON3 = 0xC0;
// Disable Priority Levels on interrupts
RCON.IPEN = 0;
PIE1 = 0;
PIE2 = 0;
PIR1 = 0;
PIR2 = 0;

// Configure all ports with analog function as digital
ADCON1 |= 0x0F;

// Ports Configuration
TRISA = 0;
TRISB = 0;
TRISC = 0xFF;
TRISD = 0xFF;
TRISE = 0x07;

LATA = 0;
LATB = 0;
LATC = 0;
LATD = 0;
LATE = 0;

// Clear user RAM
// Banks [00 .. 07] ( 8 x 256 = 2048 Bytes )
asm {
LFSR FSR0, 0x000
MOVLW 0x08
CLRF POSTINC0, 0
CPFSEQ FSR0H, 0
BRA $ - 2
}

// Timer 0
T0CON = 0x07;
TMR0H = (65536-156) >> 8;
TMR0L = (65536-156) & 0xFF;
INTCON.T0IE = 1; // Enable T0IE
T0CON.TMR0ON = 1;
}//~


/** Main Program Routine **/

void main() {
Init_Main();
Hid_Enable(&userRD_buffer, &userWR_buffer);

do {
for (k = 0; k < 255; k++) {
// Prepare send buffer
userWR_buffer[0] = k;

// Send the number via USB
Hid_Write(&userWR_buffer, 1);
}
} while (1);

Hid_Disable();
}//~!

Please inform me as soon as posible.
Many thanks again.

M. Abdelkader.

pronk
Posts: 18
Joined: 16 Jul 2009 01:02

#6 Post by pronk » 21 Sep 2009 03:17

Put a delay about 200ms in do-while loop and try

M. Abdelkader
Posts: 4
Joined: 18 Sep 2009 21:41

#7 Post by M. Abdelkader » 27 Sep 2009 15:12

pronk wrote:Put a delay about 200ms in do-while loop and try
Dear sir,

I tried to put a delay about 200ms but it dosen't work, any new recommendations?.

M. Abdelkader.

pronk
Posts: 18
Joined: 16 Jul 2009 01:02

#8 Post by pronk » 28 Sep 2009 03:04

try using another version of micro c if this error appear again
if you can send your project files , i will try to compile it

User avatar
anikolic
mikroElektronika team
Posts: 1775
Joined: 17 Aug 2009 16:51
Location: Belgrade
Contact:

#9 Post by anikolic » 28 Sep 2009 12:11

i copy the files from the directory you recommended but i still have the same error "Routine initusbdsc not defined"
Hi,
In order to use HID library routines, you must have:
1. USBdsc.c HID descriptor file
2. Definit.h header file
3. VARs.h header file

included in your project. You can copy those files from your HID Read Write Test example, that you can find in \Mikroelektronika\mikroC PRO for PIC\Examples\Internal MCU modules\p18F4550\HID Read Write Test folder.
Just copying these files to your project folder isn't enough. You'll have to add them to your project like this:
1. If you don't see Project manager window you can open it if you go to View->Project Manager
2. In your project manager window right-click on Sources folder, and chose Add File to Project in the popup window
3. Select your USBdsc.c, Definit.h and VARs.h files and click Open.
4. Rebuild the project

Best regards
Aleksandar
Web Department Manager

M. Abdelkader
Posts: 4
Joined: 18 Sep 2009 21:41

#10 Post by M. Abdelkader » 27 Oct 2009 17:19

aleksandar.nikolic wrote:
i copy the files from the directory you recommended but i still have the same error "Routine initusbdsc not defined"
Hi,
In order to use HID library routines, you must have:
1. USBdsc.c HID descriptor file
2. Definit.h header file
3. VARs.h header file

included in your project. You can copy those files from your HID Read Write Test example, that you can find in \Mikroelektronika\mikroC PRO for PIC\Examples\Internal MCU modules\p18F4550\HID Read Write Test folder.
Just copying these files to your project folder isn't enough. You'll have to add them to your project like this:
1. If you don't see Project manager window you can open it if you go to View->Project Manager
2. In your project manager window right-click on Sources folder, and chose Add File to Project in the popup window
3. Select your USBdsc.c, Definit.h and VARs.h files and click Open.
4. Rebuild the project

Best regards
Aleksandar

Dear Aleksandar,
thank you for your interest, i compile the code and burn it in PIC18f452 then i implemmented the hardware circuit then when i connected the circuit to the usb which in the pc the windows didn't recognize the new hard ware. so what is the problem.

my code is:

unsigned short m, k;
unsigned short userRD_buffer[64];
unsigned short userWR_buffer[64];

void interrupt() {
asm CALL _Hid_InterruptProc
asm nop
}

void Init_Main() {
// Disable all interrupts
// Disable GIE, PEIE, TMR0IE, INT0IE,RBIE
INTCON = 0;
INTCON2 = 0xF5;
INTCON3 = 0xC0;
// Disable Priority Levels on interrupts
RCON.IPEN = 0;
PIE1 = 0;
PIE2 = 0;
PIR1 = 0;
PIR2 = 0;

// Configure all ports with analog function as digital
ADCON1 |= 0x0F;

// Ports Configuration
TRISA = 0;
TRISB = 0;
TRISC = 0xFF;
TRISD = 0xFF;
TRISE = 0x07;

LATA = 0;
LATB = 0;
LATC = 0;
LATD = 0;
LATE = 0;

// Clear user RAM
// Banks [00 .. 07] ( 8 x 256 = 2048 Bytes )
asm {
LFSR FSR0, 0x000
MOVLW 0x08
CLRF POSTINC0, 0
CPFSEQ FSR0H, 0
BRA $ - 2
}

// Timer 0
T0CON = 0x07;
TMR0H = (65536-156) >> 8;
TMR0L = (65536-156) & 0xFF;
INTCON.T0IE = 1; // Enable T0IE
T0CON.TMR0ON = 1;
}


/** Main Program Routine **/

void main() {
Init_Main();
Hid_Enable(&userRD_buffer, &userWR_buffer);

do {
for (k = 0; k < 255; k++) {
// Prepare send buffer
userWR_buffer[0] = k;

// Send the number via USB
Hid_Write(&userWR_buffer, 1);
}
} while (1);

Hid_Disable();
}

Note:
i added usbdsc.c, VARS.h and Definit.h

User avatar
anikolic
mikroElektronika team
Posts: 1775
Joined: 17 Aug 2009 16:51
Location: Belgrade
Contact:

#11 Post by anikolic » 28 Oct 2009 13:44

Hi,
You have probably used wrong configuration bits in your project. You have to select 48MHz clock for USB communication, so if you use 8MHz crystal, you should enable 96MHz/2 PLL as an oscillator source. Please copy-paste following [DeviceFlags] configuration into your .ppc project file:

Code: Select all

[DeviceName]
Value=P18F4550
[DeviceClock]
Value=48
[MainUnit]
Value=HID_test.c
[DeviceFlags]
Count=13
Value0=_PLLDIV_2_1L = $00F9
Value1=_CPUDIV_OSC1_PLL2_1L = $00E7
Value2=_USBDIV_2_1L = $00FF
Value3=_FOSC_HSPLL_HS_1H = $00FE
Value4=_PWRT_OFF_2L = $00FF
Value5=_BOR_OFF_2L = $00F9
Value6=_VREGEN_ON_2L = $00FF
Value7=_WDT_OFF_2H = $00FE
Value8=_MCLRE_ON_3H = $00FF
Value9=_PBADEN_OFF_3H = $00FD
Value10=_CCP2MX_OFF_3H = $00FE
Value11=_STVREN_ON_4L = $00FF
Value12=_DEBUG_OFF_4L = $00FF
[BuildType]
bType=0
[ProjectFiles]
Count=2
Value0=HID_test.c
Value1=USBdsc.c
[HeaderFiles]
Count=0
[ObjLibFiles]
Count=0
[PLDFiles]
Count=0
[EEPROMinfo]
isused=0
[SearchPath]
Count=2
Value0=C:\Program Files\Mikroelektronika\mikroC\Defs\
Value1=C:\Program Files\Mikroelektronika\mikroC\Uses\p18\
[IncludePath]
Count=0
This is the entire project file, so you can compare it with yours. Try if it works for you.

Best regards,
Aleksandar
Web Department Manager

wjfong
Posts: 8
Joined: 07 Mar 2011 21:15

Re:

#12 Post by wjfong » 29 Mar 2011 03:50

filip wrote:Try copying definit.h , var.h , and USBdsc.c to your project folder, from:

...\mikroElektronika\mikroC\Examples\EasyPIC5\extra_examples\HID-library

This should work now.
good day, i have installed this software but i still cant find definit.h , var.h in the directory... only USBdsc is available... can u send me the file?? thanks :D

wjfong
Posts: 8
Joined: 07 Mar 2011 21:15

Re: Error Routine InitUSBdsc not defined

#13 Post by wjfong » 29 Mar 2011 03:59

hello, when i check the example directory on my harddisc, i just saw USBdsc & i cant find Definit.h & VARs.h files...

can someone email me the files?? wjfong@hotmail.com

thanks a lot :D

Th3W3i
Posts: 1
Joined: 06 Feb 2012 04:52

Re: Error Routine InitUSBdsc not defined

#14 Post by Th3W3i » 06 Feb 2012 04:58

Hi there,

I have the same problem, I compiled definit.h , var.h , and USBdsc.c together and still getting the same error.

Any kind soul can assist.

Thank You.

User avatar
janko.kaljevic
Posts: 3565
Joined: 16 Jun 2011 13:48

Re: Error Routine InitUSBdsc not defined

#15 Post by janko.kaljevic » 07 Feb 2012 10:40

Hello,

Please can you post here your entire project so I can test it.
Also have you tested some of our examples for USB communication.

Best regards.

Post Reply

Return to “mikroC General”