Mọi người có thể xem code bị lỗi gì sao không set được địa chỉ VIP , PID

Collapse
X
 
  • Giờ
  • Show
Clear All
new posts
  • tth64
    Nhập môn đệ tử
    • Jul 2013
    • 1

    #1

    Mọi người có thể xem code bị lỗi gì sao không set được địa chỉ VIP , PID

    #include <18f14k50.h>

    #fuses HS, NOFCMEN, NOBROWNOUT, WDT128, NOWDT, BORV19, NOPUT,\
    NOCPD, NOSTVREN, NODEBUG, NOXINST, NOWRTD, NOWRTC,\
    NOIESO, NOEBTR, NOEBTRB, NOMCLR, NOCPB, NOWRTB,\
    BROWNOUT_NOSL, NOLVP, HFOFST, NOWRT0, NOWRT1,USBDIV2,PLLEN,\
    CPUDIV3, NOPCLKEN
    #use delay(clock=48000000)

    #define USB_CONFIG_PID 0x0102 //Chnage Vendor Id and Product Id
    #define USB_CONFIG_VID 0x04D8 //So that they will work with my Application
    #define USB_CONFIG_HID_TX_SIZE 2
    #define USB_CONFIG_HID_RX_SIZE 3

    #include <pic18_usb.h>

    #include <usb_desc_hid.h> //USB Configuration and Device descriptors for this UBS device
    #include <usb.c>



    int8 outbuffer[3];
    int8 inbuffer[2];
    int8 red;
    int8 green;
    void main() {
    Set_Tris_c(0);
    usb_init();
    while(1) {
    usb_task();
    if (usb_enumerated()) {
    if(usb_kbhit(1)) {
    //lay ve du lieu
    usb_get_packet(1, outbuffer, 3);



    // Voi outbuffer[0] = 1, se cap nhat trang thai cac LED

    if (outbuffer[0] == 1) {

    green = outbuffer[1]; // Cap nhat trang thai LED

    red = outbuffer[2];

    output_bit(PIN_C6, green);

    output_bit(PIN_C7, red);

    }
    }
    }
    }
    }
Working...