• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

usb problem using 18f4550

Status
Not open for further replies.

dodonet

New Member
simply I need my computer to detect a usb connection in proteus

my sch as shown


the crystal is 20Mhz and i setup usb drivers


my simple code is the example at the mikroc projects usb read and write

Code:
unsigned char k;
unsigned char userWR_buffer[64], userRD_buffer[64];

const char *text = "MIKROElektronika Compilers ER \r\n";

//**************************************************************************************************
// Main Interrupt Routine
//**************************************************************************************************
void interrupt()
{
  HID_InterruptProc();

}
//**************************************************************************************************

//**************************************************************************************************
// Initialization Routine
//**************************************************************************************************

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

        ADCON1 |= 0x0F;                         // Configure all ports with analog function as digital
        CMCON  |= 7;                            // Disable comparators
        //--------------------------------------
        // Ports Configuration
        //--------------------------------------
        TRISA = 0xFF;
        TRISB = 0xFF;
        TRISC = 0xFF;
        TRISD = 0;
        TRISE = 0x07;

        LATA = 0;
        LATB = 0;
        LATC = 0;
        LATD = 0;
        LATE = 0;
        //--------------------------------------
        // Clear user RAM
        // Banks [00 .. 07] ( 8 x 256 = 2048 Bytes )
        //--------------------------------------

        
}
//**************************************************************************************************





//**************************************************************************************************
// Main Program Routine
//**************************************************************************************************

void main() {
  unsigned char i, ch;
  
  Init_Main();

  HID_Enable(&userRD_buffer, &userWR_buffer);
  Delay_ms(1000); Delay_ms(1000);

  while (1) {
    k = HID_Read();
    i = 0;
    while (i < k) {
      ch = userRD_buffer[i];
      userWR_buffer[0] = ch;
      while (!HID_Write(&userWR_buffer, 1)) ;
      i++;
      }

    }
  HID_Disable();
}

and i added the USBdsc.c file while creating hex file






why proteus cannot detect a new hardware with this examples although it detects at any samples project in the proteus which have only their hex file only?

if there is a problem plz tell me :confused:
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top