Hola a todos, estoy intentando comunicar un PIC18F4550 con una PC mediante USB pero resulta que al conectar el microcontrolador en la PC me sale el mensaje "NO SE RECONOCE EL DISPOSITIVO USB" y no se a que se deba esto, ya verifique que la conexión de D+ y D- sea correcta pero no logro que la computadora reconosca el PIC.
El código que utilizo epara la comunicación es el siguiente:
#include <18F4550.h>
#fuses HSPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,PLL5,CPUDIV1,VREGEN,MCLR,NOPBADEN
#use delay(clock=48000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#use i2c(Master,Fast=400000,sda=PIN_B0,scl=PIN_B1,force_hw)
#define USB_HID_DEVICE FALSE //deshabilitamos el uso de las directivas HID
#define USB_EP1_TX_ENABLE USB_ENABLE_BULK //turn on EP1(EndPoint1) for IN bulk/interrupt transfers
#define USB_EP1_RX_ENABLE USB_ENABLE_BULK //turn on EP1(EndPoint1) for OUT bulk/interrupt transfers
#define USB_EP1_TX_SIZE 64 //size to allocate for the tx endpoint 1 buffer
#define USB_EP1_RX_SIZE 64 //size to allocate for the rx endpoint 1 buffer
#include <pic18_usb.h> //Microchip PIC18Fxx5x Hardware layer for CCS's PIC USB driver
#include "usb_desc_scope.h" //descriptors del Pic USB
#include <usb.c> //handles usb setup tokens and get descriptor reports
#include <usb_bootloader.h>
#define LEDV PIN_B6
#define LEDR PIN_B7
#define LED_ON output_high
#define LED_OFF output_low
#define SLAVE1_WRT_ADDR 0x12
#define SLAVE1_READ_ADDR 0x13
#define SLAVE2_WRT_ADDR 0x16
#define SLAVE2_READ_ADDR 0x17
#define SLAVE3_WRT_ADDR 0x20
#define SLAVE3_READ_ADDR 0x21
#define SLAVE4_WRT_ADDR 0x24
#define SLAVE4_READ_ADDR 0x25
// Direcciones de memoria válidas para PIC18F2455/2550/4455/4550 (no olvide que son la misma familia)
// Esto es con el fin de poder escribir directamente en ellos sin usar instrucciones como intermediarios.
#BYTE TRISA = 0x0F92 // Registro de control de E/S del puerto A
#BYTE TRISB = 0x0F93 // Registro de control de E/S del puerto B
#BYTE PORTA = 0x0F80 // Registro del puerto A
#BYTE PORTB = 0x0F81 // Registro del puerto B
#BYTE ADCON0 = 0x0FC2 // Registro de control del ADC
#BYTE ADCON1 = 0x0FC1 // Registro de control del ADC
#BYTE CMCON = 0x0FB4 // Registro del modulo comparador
int8 dato[64];
int pos, pos1, pos2, pos3, pos4;
int dpos1, dpos2, dpos3, dpos4;
void send_i2c(int vel, int dir);
void read_i2c(int dir2);
void com_usb(int dato2, int dato3, int dato4);
void main(void) {
LED_ON(LEDV); //encendemos led en RB6 para indicar presencia de energia
LED_OFF(LEDR);
usb_init(); // inicializamos el USB
usb_task(); // habilita periferico usb e interrupciones
usb_wait_for_enumeration(); // esperamos hasta que el PicUSB sea configurado por el host
LED_OFF(LEDV);
LED_ON(LEDR); // encendemos led en RB7 al establecer contacto con la PC
Despúes de esa sección sigue el programa pero es en el comando usb_wait_for_enumeration(); donde se queda ciclado el PIC. También modifique la libreria usb_desc_scope.h para que reconociera al PIC y aun así no lo hace, el descriptor que modifique es el siguiente:
//device descriptor
char const USB_DEVICE_DESC[] ={
USB_DESC_DEVICE_LEN, //the length of this report
0x01, //constant DEVICE (0x01)
0x10,0x01, //usb version in bcd
0x00, //class code (if 0, interface defines class. FF is vendor defined)
0x00, //subclass code
0x00, //protocol code
USB_MAX_EP0_PACKET_LENGTH, //max packet size for endpoint 0. (SLOW SPEED SPECIFIES
0xD8,0x04, //vendor id (0x04D8 is Microchip)
0x0B,0x00, //product id
0x00,0x01, //device release number
0x01, //index of string description of manufacturer. therefore we point to string_1 array (see below)
0x02, //index of string descriptor of the product
0x00, //index of string descriptor of serial number
USB_NUM_CONFIGURATIONS //number of possible configurations
};
Lo que modifique en esta sección fue el vendor id, el product id y el device release number.
Realmente espero me puedan ayudar porque necesito terminar esta aplicación, MUCHAS GRACIAS A TODOS.