Autor Tema: ¿USB con compilador XC?  (Leído 12276 veces)

0 Usuarios y 1 Visitante están viendo este tema.

Desconectado calavia

  • PIC10
  • *
  • Mensajes: 14
Re: ¿USB con compilador XC?
« Respuesta #15 en: 23 de Enero de 2014, 20:40:18 »
AngelGris, veras soy algo nuevo en esto y necesito ayuda en este tema.

¿Tu usas MPLAB X? esque a la hora de la configuración de donde tiene que buscar los archivos el compilador cambia. Yo también uso el compilador XC8 de ahí que me interese este tema.

Por otro lado... estoy intentando hacer un CDC, tenía un FTDI para la conversión RS232 USB, pero es demasiado caro tener que conseguir uno cada vez que utilizo un pic para un proyecto nuevo. Y he intentado como tienes puesto ahí arriba, pero no tengo manera de conseguir que me compile... me va sacando fallos por todos lados.

¿Cómo configuras en este caso el PIC para que te reconozca la interrupción del USB y para leer los datos que se han mandado?

Desconectado AngelGris

  • Colaborador
  • PIC24H
  • *****
  • Mensajes: 2480
Re: ¿USB con compilador XC?
« Respuesta #16 en: 23 de Enero de 2014, 21:06:18 »
Hola AngelGris

voy a bajarlo y le pongo un ojo,
luego te cuento,...

hola..
 estoy en la lectura aun, la verdad es que hay mucha info, casi 40 hojas
es estoy en la lectura comprensiva..aun estoy en la hoja 10.. :D

luego te preguntare algunas cosas,...

AngelGris cuantos dias llevas con este estudio..?

si montaramos un circuito de pic 18F2550

¿cual seria el primer paso a realizar despues de leer el pdf?


un Saludo.



  Hola pajaro, no recuerdo haber tenido una notificación de tu mensaje. Te pido disculpas si no te contesté anteriormente, te aseguro que no fue mala voluntad.

  De estudio te diría que fueron muchísimos, porque primeramente había leido algo pero me mareaba un poco tanta información y no poder hacer funcionar nada y lo dejé de lado. Luego lo volvía a agarrar y lo empecé a leer mas detenidamente y como había encontrado la forma de que funcionen con XC las librerías de microchip me entusiasmé y prestaba más atención a algunas cosas. Pero ciertamente no dejo de pensar que es bastante complejo el tema del USB.

  En cuanto a montar un circuito, supongo que dependerá un poco que lo que quieras armar... como mencioné en otro mensaje, logré simular tanto CDC como un joystick HID. Supongo que se podría experimentar con una clase propia.... pero todavía no llegué a ese punto
De vez en cuando la vida
nos besa en la boca
y a colores se despliega
como un atlas

Desconectado AngelGris

  • Colaborador
  • PIC24H
  • *****
  • Mensajes: 2480
Re: ¿USB con compilador XC?
« Respuesta #17 en: 23 de Enero de 2014, 21:11:26 »
AngelGris, veras soy algo nuevo en esto y necesito ayuda en este tema.

¿Tu usas MPLAB X? esque a la hora de la configuración de donde tiene que buscar los archivos el compilador cambia. Yo también uso el compilador XC8 de ahí que me interese este tema.

Por otro lado... estoy intentando hacer un CDC, tenía un FTDI para la conversión RS232 USB, pero es demasiado caro tener que conseguir uno cada vez que utilizo un pic para un proyecto nuevo. Y he intentado como tienes puesto ahí arriba, pero no tengo manera de conseguir que me compile... me va sacando fallos por todos lados.

¿Cómo configuras en este caso el PIC para que te reconozca la interrupción del USB y para leer los datos que se han mandado?

  Sí, utilizo MPLABX desde debian.
  Luego te subo el ejemplo que tengo compilado para CDC. Te recomiendo la lectura del post de jfmateos2 Dicho ejemplo es simplemente un echo... el pic recibe un dato por el puerto RS232 virtual y lo devuelve y aparece en el terminal.
De vez en cuando la vida
nos besa en la boca
y a colores se despliega
como un atlas

Desconectado calavia

  • PIC10
  • *
  • Mensajes: 14
Re: ¿USB con compilador XC?
« Respuesta #18 en: 23 de Enero de 2014, 21:19:16 »
  Sí, utilizo MPLABX desde debian.
  Luego te subo el ejemplo que tengo compilado para CDC. Te recomiendo la lectura del post de jfmateos2 Dicho ejemplo es simplemente un echo... el pic recibe un dato por el puerto RS232 virtual y lo devuelve y aparece en el terminal.

He leido lo que has subido ahí, pero el problema lo tengo a la hora de incluir al compilador la ruta donde están los demás archivos
« Última modificación: 23 de Enero de 2014, 21:28:46 por calavia »

Desconectado AngelGris

  • Colaborador
  • PIC24H
  • *****
  • Mensajes: 2480
Re: ¿USB con compilador XC?
« Respuesta #19 en: 23 de Enero de 2014, 23:46:28 »
  En el stack de microchip hay distintos archivos ya sea .C o .H, según lo que se quiera armar. Por ejemplo para un dispositivo HID, el archivo .C a utilizar es usb_function_hid.c, para CDC es usb_function_cdc.c. Lo que hago es tomar el archivo que necesite y copiarlo en la carpeta de mi proyecto. También copio en la carpeta del proyecto el archivo usb_device.c

  Además en la carpeta del proyecto debe existir un archivo llamado usb_descriptor.c, otro llamado usb_config.h y otro llamado HardwareProfile.h

  También hay que configurar en el proyecto los PATH para que apunten a un par de carpetas del stack USB..

  Los archivos .C que están dentro de la carpeta del proyecto los agrego al mismo en la opción Sources Files

  Te adjunto una captura de pantalla donde se aprecia los archivos agregados a Sources Files, y los PAHT agregados en la opción del compilador
De vez en cuando la vida
nos besa en la boca
y a colores se despliega
como un atlas

Desconectado calavia

  • PIC10
  • *
  • Mensajes: 14
Re: ¿USB con compilador XC?
« Respuesta #20 en: 24 de Enero de 2014, 05:48:06 »
He hecho lo que tienes ahí puesto, vaya me da ahora menos errores, pero sigo con problemas en el archivo "usb_function_cdc.h"

EDITO: he conseguido que compile, pero no me reconoce el dispositivo en el ISIS en el ejemplo que has dicho al principio. Problema del ISIS no es, porque si ejecuto ese mismo ejemplo me reconoce un nuevo dispositivo :(
« Última modificación: 24 de Enero de 2014, 07:55:10 por calavia »

Desconectado AngelGris

  • Colaborador
  • PIC24H
  • *****
  • Mensajes: 2480
Re: ¿USB con compilador XC?
« Respuesta #21 en: 24 de Enero de 2014, 09:55:35 »

EDITO: he conseguido que compile, pero no me reconoce el dispositivo en el ISIS en el ejemplo que has dicho al principio. Problema del ISIS no es, porque si ejecuto ese mismo ejemplo me reconoce un nuevo dispositivo :(

  No entiendo.  :oops: ¿Cuál ejemplo es el que funciona, el que trae el propio ISIS?

  Estos son los archivos que utilicé para la simulación...

  main.c
Código: C
  1. #include <xc.h>
  2.  
  3.  
  4. // CONFIG1L
  5. #pragma config PLLDIV = 5       // PLL Prescaler Selection bits (Divide by 5 (20 MHz oscillator input))
  6. #pragma config CPUDIV = OSC1_PLL2// System Clock Postscaler Selection bits ([Primary Oscillator Src: /1][96 MHz PLL Src: /2])
  7. #pragma config USBDIV = 2       // USB Clock Selection bit (used in Full-Speed USB mode only; UCFG:FSEN = 1) (USB clock source comes from the 96 MHz PLL divided by 2)
  8.  
  9. // CONFIG1H
  10. #pragma config FOSC = HSPLL_HS  // Oscillator Selection bits (HS oscillator, PLL enabled (HSPLL))
  11. #pragma config FCMEN = OFF      // Fail-Safe Clock Monitor Enable bit (Fail-Safe Clock Monitor disabled)
  12. #pragma config IESO = OFF       // Internal/External Oscillator Switchover bit (Oscillator Switchover mode disabled)
  13.  
  14. // CONFIG2L
  15. #pragma config PWRT = OFF       // Power-up Timer Enable bit (PWRT disabled)
  16. #pragma config BOR = ON         // Brown-out Reset Enable bits (Brown-out Reset enabled in hardware only (SBOREN is disabled))
  17. #pragma config BORV = 3         // Brown-out Reset Voltage bits (Minimum setting)
  18. #pragma config VREGEN = ON      // USB Voltage Regulator Enable bit (USB voltage regulator enabled)
  19.  
  20. // CONFIG2H
  21. #pragma config WDT = OFF        // Watchdog Timer Enable bit (WDT disabled (control is placed on the SWDTEN bit))
  22. #pragma config WDTPS = 32768    // Watchdog Timer Postscale Select bits (1:32768)
  23.  
  24. // CONFIG3H
  25. #pragma config CCP2MX = ON      // CCP2 MUX bit (CCP2 input/output is multiplexed with RC1)
  26. #pragma config PBADEN = OFF     // PORTB A/D Enable bit (PORTB<4:0> pins are configured as digital I/O on Reset)
  27. #pragma config LPT1OSC = OFF    // Low-Power Timer 1 Oscillator Enable bit (Timer1 configured for higher power operation)
  28. #pragma config MCLRE = ON       // MCLR Pin Enable bit (MCLR pin enabled; RE3 input pin disabled)
  29.  
  30. // CONFIG4L
  31. #pragma config STVREN = ON      // Stack Full/Underflow Reset Enable bit (Stack full/underflow will cause Reset)
  32. #pragma config LVP = OFF        // Single-Supply ICSP Enable bit (Single-Supply ICSP disabled)
  33. #pragma config XINST = OFF      // Extended Instruction Set Enable bit (Instruction set extension and Indexed Addressing mode disabled (Legacy mode))
  34.  
  35. // CONFIG5L
  36. #pragma config CP0 = OFF        // Code Protection bit (Block 0 (000800-001FFFh) is not code-protected)
  37. #pragma config CP1 = OFF        // Code Protection bit (Block 1 (002000-003FFFh) is not code-protected)
  38. #pragma config CP2 = OFF        // Code Protection bit (Block 2 (004000-005FFFh) is not code-protected)
  39. #pragma config CP3 = OFF        // Code Protection bit (Block 3 (006000-007FFFh) is not code-protected)
  40.  
  41. // CONFIG5H
  42. #pragma config CPB = OFF        // Boot Block Code Protection bit (Boot block (000000-0007FFh) is not code-protected)
  43. #pragma config CPD = OFF        // Data EEPROM Code Protection bit (Data EEPROM is not code-protected)
  44.  
  45. // CONFIG6L
  46. #pragma config WRT0 = OFF       // Write Protection bit (Block 0 (000800-001FFFh) is not write-protected)
  47. #pragma config WRT1 = OFF       // Write Protection bit (Block 1 (002000-003FFFh) is not write-protected)
  48. #pragma config WRT2 = OFF       // Write Protection bit (Block 2 (004000-005FFFh) is not write-protected)
  49. #pragma config WRT3 = OFF       // Write Protection bit (Block 3 (006000-007FFFh) is not write-protected)
  50.  
  51. // CONFIG6H
  52. #pragma config WRTC = OFF       // Configuration Register Write Protection bit (Configuration registers (300000-3000FFh) are not write-protected)
  53. #pragma config WRTB = OFF       // Boot Block Write Protection bit (Boot block (000000-0007FFh) is not write-protected)
  54. #pragma config WRTD = OFF       // Data EEPROM Write Protection bit (Data EEPROM is not write-protected)
  55.  
  56. // CONFIG7L
  57. #pragma config EBTR0 = OFF      // Table Read Protection bit (Block 0 (000800-001FFFh) is not protected from table reads executed in other blocks)
  58. #pragma config EBTR1 = OFF      // Table Read Protection bit (Block 1 (002000-003FFFh) is not protected from table reads executed in other blocks)
  59. #pragma config EBTR2 = OFF      // Table Read Protection bit (Block 2 (004000-005FFFh) is not protected from table reads executed in other blocks)
  60. #pragma config EBTR3 = OFF      // Table Read Protection bit (Block 3 (006000-007FFFh) is not protected from table reads executed in other blocks)
  61.  
  62. // CONFIG7H
  63. #pragma config EBTRB = OFF      // Boot Block Table Read Protection bit (Boot block (000000-0007FFh) is not protected from table reads executed in other blocks)
  64.  
  65.  
  66.  
  67.  
  68. //#include <stdio.h>
  69. //#include <string.h>
  70. /** I N C L U D E S **********************************************************/
  71. #include "usb_config.h"
  72. #include "HardwareProfile.h"
  73. #include "./USB/usb.h"
  74. #include "./USB/usb_function_cdc.h"
  75.  
  76.  
  77. /** V A R I A B L E S ********************************************************/
  78. char USB_Out_Buffer[64];
  79. char buffer[64];
  80.  
  81.  
  82.  
  83. /** P R I V A T E  P R O T O T Y P E S ***************************************/
  84. void ProcessIO(void);
  85.  
  86.  
  87. void interrupt high_priority isr(void)
  88. {
  89.     USBDeviceTasks();
  90. }
  91.  
  92.  
  93. /** DECLARATIONS ***************************************************/
  94. void main(void)
  95. {
  96.     TRISA = 0xFF;
  97.     ADCON1 = 0x0F;      // entradas digitales
  98.  
  99.  
  100.     USBDeviceInit();    //usb_device.c.  Initializes USB module SFRs and firmware
  101.                                         //variables to known states.
  102.  
  103.     while(1)
  104.     {
  105.         //USBDeviceTasks();
  106.         #if defined(USB_INTERRUPT)
  107.             if(USB_BUS_SENSE && (USBGetDeviceState() == DETACHED_STATE))
  108.             {
  109.                 USBDeviceAttach();
  110.             }
  111.         #endif
  112.         ProcessIO();
  113.     }//end while
  114. }//end main
  115.  
  116.  
  117.  
  118. /********************************************************************
  119.  * Function:        void ProcessIO(void)
  120.  *
  121.  * PreCondition:    None
  122.  *
  123.  * Input:           None
  124.  *
  125.  * Output:          None
  126.  *
  127.  * Side Effects:    None
  128.  *
  129.  * Overview:        This function is a place holder for other user
  130.  *                  routines. It is a mixture of both USB and
  131.  *                  non-USB tasks.
  132.  *
  133.  * Note:            None
  134.  *******************************************************************/
  135. void ProcessIO(void)
  136. {
  137.     BYTE numBytesRead;
  138.  
  139.     // User Application USB tasks
  140.     if((USBDeviceState < CONFIGURED_STATE)||(USBSuspendControl==1)) return;
  141.  
  142.     if(USBUSARTIsTxTrfReady())
  143.     {
  144.                 numBytesRead = getsUSBUSART(USB_Out_Buffer,64);
  145.                 if(numBytesRead != 0)
  146.                 {
  147.                         strcpypgm2ram(buffer,(const rom far char *)"Ha pulsado: ");
  148.                         strncat(buffer,USB_Out_Buffer,numBytesRead);
  149.                         strcatpgm2ram(buffer,(const rom far char *)"\r\n");
  150.                         putsUSBUSART(buffer);
  151.                 }
  152.         }
  153.     CDCTxService();
  154. }               //end ProcessIO
  155.  
  156.  
  157.  
  158.  
  159.  
  160. // ******************************************************************************************************
  161. // ************** USB Callback Functions ****************************************************************
  162. // ******************************************************************************************************
  163. // The USB firmware stack will call the callback functions USBCBxxx() in response to certain USB related
  164. // events.  For example, if the host PC is powering down, it will stop sending out Start of Frame (SOF)
  165. // packets to your device.  In response to this, all USB devices are supposed to decrease their power
  166. // consumption from the USB Vbus to <2.5mA each.  The USB module detects this condition (which according
  167. // to the USB specifications is 3+ms of no bus activity/SOF packets) and then calls the USBCBSuspend()
  168. // function.  You should modify these callback functions to take appropriate actions for each of these
  169. // conditions.  For example, in the USBCBSuspend(), you may wish to add code that will decrease power
  170. // consumption from Vbus to <2.5mA (such as by clock switching, turning off LEDs, putting the
  171. // microcontroller to sleep, etc.).  Then, in the USBCBWakeFromSuspend() function, you may then wish to
  172. // add code that undoes the power saving things done in the USBCBSuspend() function.
  173.  
  174. // The USBCBSendResume() function is special, in that the USB stack will not automatically call this
  175. // function.  This function is meant to be called from the application firmware instead.  See the
  176. // additional comments near the function.
  177.  
  178.  
  179. /*******************************************************************
  180.  * Function:        void USBCBCheckOtherReq(void)
  181.  *
  182.  * PreCondition:    None
  183.  *
  184.  * Input:           None
  185.  *
  186.  * Output:          None
  187.  *
  188.  * Side Effects:    None
  189.  *
  190.  * Overview:        When SETUP packets arrive from the host, some
  191.  *                                      firmware must process the request and respond
  192.  *                                      appropriately to fulfill the request.  Some of
  193.  *                                      the SETUP packets will be for standard
  194.  *                                      USB "chapter 9" (as in, fulfilling chapter 9 of
  195.  *                                      the official USB specifications) requests, while
  196.  *                                      others may be specific to the USB device class
  197.  *                                      that is being implemented.  For example, a HID
  198.  *                                      class device needs to be able to respond to
  199.  *                                      "GET REPORT" type of requests.  This
  200.  *                                      is not a standard USB chapter 9 request, and
  201.  *                                      therefore not handled by usb_device.c.  Instead
  202.  *                                      this request should be handled by class specific
  203.  *                                      firmware, such as that contained in usb_function_hid.c.
  204.  *
  205.  * Note:            None
  206.  *******************************************************************/
  207. void USBCBCheckOtherReq(void)
  208. {
  209.     USBCheckCDCRequest();
  210. }//end
  211.  
  212.  
  213.  
  214. /*******************************************************************
  215.  * Function:        void USBCBInitEP(void)
  216.  *
  217.  * PreCondition:    None
  218.  *
  219.  * Input:           None
  220.  *
  221.  * Output:          None
  222.  *
  223.  * Side Effects:    None
  224.  *
  225.  * Overview:        This function is called when the device becomes
  226.  *                  initialized, which occurs after the host sends a
  227.  *                                      SET_CONFIGURATION (wValue not = 0) request.  This
  228.  *                                      callback function should initialize the endpoints
  229.  *                                      for the device's usage according to the current
  230.  *                                      configuration.
  231.  *
  232.  * Note:            None
  233.  *******************************************************************/
  234. void USBCBInitEP(void)
  235. {
  236.     CDCInitEP();
  237. }
  238.  
  239.  
  240.  
  241. /*******************************************************************
  242.  * Function:        BOOL USER_USB_CALLBACK_EVENT_HANDLER(
  243.  *                        USB_EVENT event, void *pdata, WORD size)
  244.  *
  245.  * PreCondition:    None
  246.  *
  247.  * Input:           USB_EVENT event - the type of event
  248.  *                  void *pdata - pointer to the event data
  249.  *                  WORD size - size of the event data
  250.  *
  251.  * Output:          None
  252.  *
  253.  * Side Effects:    None
  254.  *
  255.  * Overview:        This function is called from the USB stack to
  256.  *                  notify a user application that a USB event
  257.  *                  occured.  This callback is in interrupt context
  258.  *                  when the USB_INTERRUPT option is selected.
  259.  *
  260.  * Note:            None
  261.  *******************************************************************/
  262. BOOL USER_USB_CALLBACK_EVENT_HANDLER(USB_EVENT event, void *pdata, WORD size)
  263. {
  264.     switch(event)
  265.     {
  266.         case EVENT_CONFIGURED:
  267.             USBCBInitEP();
  268.             break;
  269.         case EVENT_EP0_REQUEST:
  270.             USBCBCheckOtherReq();
  271.             break;
  272.         default:
  273.             break;
  274.     }
  275.     return TRUE;
  276. }
  277.  
  278.  
  279. /** EOF main.c *************************************************/

usb_descriptor.c
Código: C
  1. /********************************************************************
  2.  FileName:      usb_descriptors.c
  3.  Dependencies:  See INCLUDES section
  4.  Processor:             PIC18 or PIC24 USB Microcontrollers
  5.  Hardware:              The code is natively intended to be used on the following
  6.                                 hardware platforms: PICDEM™ FS USB Demo Board,
  7.                                 PIC18F87J50 FS USB Plug-In Module, or
  8.                                 Explorer 16 + PIC24 USB PIM.  The firmware may be
  9.                                 modified for use on other USB platforms by editing the
  10.                                 HardwareProfile.h file.
  11.  Complier:      Microchip C18 (for PIC18) or C30 (for PIC24)
  12.  Company:               Microchip Technology, Inc.
  13.  
  14.  Software License Agreement:
  15.  
  16.  The software supplied herewith by Microchip Technology Incorporated
  17.  (the “Company”) for its PIC® Microcontroller is intended and
  18.  supplied to you, the Company’s customer, for use solely and
  19.  exclusively on Microchip PIC Microcontroller products. The
  20.  software is owned by the Company and/or its supplier, and is
  21.  protected under applicable copyright laws. All rights are reserved.
  22.  Any use in violation of the foregoing restrictions may subject the
  23.  user to criminal sanctions under applicable laws, as well as to
  24.  civil liability for the breach of the terms and conditions of this
  25.  license.
  26.  
  27.  THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES,
  28.  WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
  29.  TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
  30.  PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
  31.  IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
  32.  CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
  33.  
  34. *********************************************************************
  35. -usb_descriptors.c-
  36. -------------------------------------------------------------------
  37. Filling in the descriptor values in the usb_descriptors.c file:
  38. -------------------------------------------------------------------
  39.  
  40. [Device Descriptors]
  41. The device descriptor is defined as a USB_DEVICE_DESCRIPTOR type.  
  42. This type is defined in usb_ch9.h  Each entry into this structure
  43. needs to be the correct length for the data type of the entry.
  44.  
  45. [Configuration Descriptors]
  46. The configuration descriptor was changed in v2.x from a structure
  47. to a BYTE array.  Given that the configuration is now a byte array
  48. each byte of multi-byte fields must be listed individually.  This
  49. means that for fields like the total size of the configuration where
  50. the field is a 16-bit value "64,0," is the correct entry for a
  51. configuration that is only 64 bytes long and not "64," which is one
  52. too few bytes.
  53.  
  54. The configuration attribute must always have the _DEFAULT
  55. definition at the minimum. Additional options can be ORed
  56. to the _DEFAULT attribute. Available options are _SELF and _RWU.
  57. These definitions are defined in the usb_device.h file. The
  58. _SELF tells the USB host that this device is self-powered. The
  59. _RWU tells the USB host that this device supports Remote Wakeup.
  60.  
  61. [Endpoint Descriptors]
  62. Like the configuration descriptor, the endpoint descriptors were
  63. changed in v2.x of the stack from a structure to a BYTE array.  As
  64. endpoint descriptors also has a field that are multi-byte entities,
  65. please be sure to specify both bytes of the field.  For example, for
  66. the endpoint size an endpoint that is 64 bytes needs to have the size
  67. defined as "64,0," instead of "64,"
  68.  
  69. Take the following example:
  70.     // Endpoint Descriptor //
  71.     0x07,                       //the size of this descriptor //
  72.     USB_DESCRIPTOR_ENDPOINT,    //Endpoint Descriptor
  73.     _EP02_IN,                   //EndpointAddress
  74.     _INT,                       //Attributes
  75.     0x08,0x00,                  //size (note: 2 bytes)
  76.     0x02,                       //Interval
  77.  
  78. The first two parameters are self-explanatory. They specify the
  79. length of this endpoint descriptor (7) and the descriptor type.
  80. The next parameter identifies the endpoint, the definitions are
  81. defined in usb_device.h and has the following naming
  82. convention:
  83. _EP<##>_<dir>
  84. where ## is the endpoint number and dir is the direction of
  85. transfer. The dir has the value of either 'OUT' or 'IN'.
  86. The next parameter identifies the type of the endpoint. Available
  87. options are _BULK, _INT, _ISO, and _CTRL. The _CTRL is not
  88. typically used because the default control transfer endpoint is
  89. not defined in the USB descriptors. When _ISO option is used,
  90. addition options can be ORed to _ISO. Example:
  91. _ISO|_AD|_FE
  92. This describes the endpoint as an isochronous pipe with adaptive
  93. and feedback attributes. See usb_device.h and the USB
  94. specification for details. The next parameter defines the size of
  95. the endpoint. The last parameter in the polling interval.
  96.  
  97. -------------------------------------------------------------------
  98. Adding a USB String
  99. -------------------------------------------------------------------
  100. A string descriptor array should have the following format:
  101.  
  102. rom struct{byte bLength;byte bDscType;word string[size];}sdxxx={
  103. sizeof(sdxxx),DSC_STR,<text>};
  104.  
  105. The above structure provides a means for the C compiler to
  106. calculate the length of string descriptor sdxxx, where xxx is the
  107. index number. The first two bytes of the descriptor are descriptor
  108. length and type. The rest <text> are string texts which must be
  109. in the unicode format. The unicode format is achieved by declaring
  110. each character as a word type. The whole text string is declared
  111. as a word array with the number of characters equals to <size>.
  112. <size> has to be manually counted and entered into the array
  113. declaration. Let's study this through an example:
  114. if the string is "USB" , then the string descriptor should be:
  115. (Using index 02)
  116. rom struct{byte bLength;byte bDscType;word string[3];}sd002={
  117. sizeof(sd002),DSC_STR,'U','S','B'};
  118.  
  119. A USB project may have multiple strings and the firmware supports
  120. the management of multiple strings through a look-up table.
  121. The look-up table is defined as:
  122. rom const unsigned char *rom USB_SD_Ptr[]={&sd000,&sd001,&sd002};
  123.  
  124. The above declaration has 3 strings, sd000, sd001, and sd002.
  125. Strings can be removed or added. sd000 is a specialized string
  126. descriptor. It defines the language code, usually this is
  127. US English (0x0409). The index of the string must match the index
  128. position of the USB_SD_Ptr array, &sd000 must be in position
  129. USB_SD_Ptr[0], &sd001 must be in position USB_SD_Ptr[1] and so on.
  130. The look-up table USB_SD_Ptr is used by the get string handler
  131. function.
  132.  
  133. -------------------------------------------------------------------
  134.  
  135. The look-up table scheme also applies to the configuration
  136. descriptor. A USB device may have multiple configuration
  137. descriptors, i.e. CFG01, CFG02, etc. To add a configuration
  138. descriptor, user must implement a structure similar to CFG01.
  139. The next step is to add the configuration descriptor name, i.e.
  140. cfg01, cfg02,.., to the look-up table USB_CD_Ptr. USB_CD_Ptr[0]
  141. is a dummy place holder since configuration 0 is the un-configured
  142. state according to the definition in the USB specification.
  143.  
  144. ********************************************************************/
  145.  
  146. /*********************************************************************
  147.  * Descriptor specific type definitions are defined in:
  148.  * usb_device.h
  149.  *
  150.  * Configuration options are defined in:
  151.  * usb_config.h
  152.  ********************************************************************/
  153. #ifndef __USB_DESCRIPTORS_C
  154. #define __USB_DESCRIPTORS_C
  155.  
  156. /** INCLUDES *******************************************************/
  157. #include "./USB/usb.h"
  158. #include "./USB/usb_function_cdc.h"
  159.  
  160. /** CONSTANTS ******************************************************/
  161.  
  162. /*
  163. #if defined(__18CXX)
  164. #pragma romdata
  165. #endif
  166. */
  167.  
  168. /* Device Descriptor */
  169. ROM USB_DEVICE_DESCRIPTOR device_dsc=
  170. {
  171.     0x12,                   // Size of this descriptor in bytes
  172.     USB_DESCRIPTOR_DEVICE,  // DEVICE descriptor type
  173.     0x0200,                 // USB Spec Release Number in BCD format
  174.     CDC_DEVICE,             // Class Code
  175.     0x00,                   // Subclass code
  176.     0x00,                   // Protocol code
  177.     USB_EP0_BUFF_SIZE,      // Max packet size for EP0, see usb_config.h
  178.     0x04D8,                 // Vendor ID
  179.     0x000A,                 // Product ID: CDC RS-232 Emulation Demo
  180.     0x0100,                 // Device release number in BCD format
  181.     0x01,                   // Manufacturer string index
  182.     0x02,                   // Product string index
  183.     0x00,                   // Device serial number string index
  184.     0x01                    // Number of possible configurations
  185. };
  186.  
  187. /* Configuration 1 Descriptor */
  188. ROM BYTE configDescriptor1[]={
  189.     /* Configuration Descriptor */
  190.     0x09,//sizeof(USB_CFG_DSC),    // Size of this descriptor in bytes
  191.     USB_DESCRIPTOR_CONFIGURATION,                // CONFIGURATION descriptor type
  192.     67,0,                   // Total length of data for this cfg
  193.     2,                      // Number of interfaces in this cfg
  194.     1,                      // Index value of this configuration
  195.     0,                      // Configuration string index
  196.     _DEFAULT | _SELF,               // Attributes, see usb_device.h
  197.     50,                     // Max power consumption (2X mA)
  198.                                                        
  199.     /* Interface Descriptor */
  200.     9,//sizeof(USB_INTF_DSC),   // Size of this descriptor in bytes
  201.     USB_DESCRIPTOR_INTERFACE,               // INTERFACE descriptor type
  202.     0,                      // Interface Number
  203.     0,                      // Alternate Setting Number
  204.     1,                      // Number of endpoints in this intf
  205.     COMM_INTF,              // Class code
  206.     ABSTRACT_CONTROL_MODEL, // Subclass code
  207.     V25TER,                 // Protocol code
  208.     0,                      // Interface string index
  209.  
  210.     /* CDC Class-Specific Descriptors */
  211.     sizeof(USB_CDC_HEADER_FN_DSC),
  212.     CS_INTERFACE,
  213.     DSC_FN_HEADER,
  214.     0x10,0x01,
  215.  
  216.     sizeof(USB_CDC_ACM_FN_DSC),
  217.     CS_INTERFACE,
  218.     DSC_FN_ACM,
  219.     USB_CDC_ACM_FN_DSC_VAL,
  220.  
  221.     sizeof(USB_CDC_UNION_FN_DSC),
  222.     CS_INTERFACE,
  223.     DSC_FN_UNION,
  224.     CDC_COMM_INTF_ID,
  225.     CDC_DATA_INTF_ID,
  226.  
  227.     sizeof(USB_CDC_CALL_MGT_FN_DSC),
  228.     CS_INTERFACE,
  229.     DSC_FN_CALL_MGT,
  230.     0x00,
  231.     CDC_DATA_INTF_ID,
  232.  
  233.     /* Endpoint Descriptor */
  234.     //sizeof(USB_EP_DSC),DSC_EP,_EP02_IN,_INT,CDC_INT_EP_SIZE,0x02,
  235.     0x07,/*sizeof(USB_EP_DSC)*/
  236.     USB_DESCRIPTOR_ENDPOINT,    //Endpoint Descriptor
  237.     _EP01_IN,            //EndpointAddress
  238.     _INTERRUPT,                       //Attributes
  239.     0x08,0x00,                  //size
  240.     0x02,                       //Interval
  241.  
  242.     /* Interface Descriptor */
  243.     9,//sizeof(USB_INTF_DSC),   // Size of this descriptor in bytes
  244.     USB_DESCRIPTOR_INTERFACE,               // INTERFACE descriptor type
  245.     1,                      // Interface Number
  246.     0,                      // Alternate Setting Number
  247.     2,                      // Number of endpoints in this intf
  248.     DATA_INTF,              // Class code
  249.     0,                      // Subclass code
  250.     NO_PROTOCOL,            // Protocol code
  251.     0,                      // Interface string index
  252.    
  253.     /* Endpoint Descriptor */
  254.     //sizeof(USB_EP_DSC),DSC_EP,_EP03_OUT,_BULK,CDC_BULK_OUT_EP_SIZE,0x00,
  255.     0x07,/*sizeof(USB_EP_DSC)*/
  256.     USB_DESCRIPTOR_ENDPOINT,    //Endpoint Descriptor
  257.     _EP02_OUT,            //EndpointAddress
  258.     _BULK,                       //Attributes
  259.     0x40,0x00,                  //size
  260.     0x00,                       //Interval
  261.  
  262.     /* Endpoint Descriptor */
  263.     //sizeof(USB_EP_DSC),DSC_EP,_EP03_IN,_BULK,CDC_BULK_IN_EP_SIZE,0x00
  264.     0x07,/*sizeof(USB_EP_DSC)*/
  265.     USB_DESCRIPTOR_ENDPOINT,    //Endpoint Descriptor
  266.     _EP02_IN,            //EndpointAddress
  267.     _BULK,                       //Attributes
  268.     0x40,0x00,                  //size
  269.     0x00,                       //Interval
  270. };
  271.  
  272.  
  273. //Language code string descriptor
  274. ROM struct{BYTE bLength;BYTE bDscType;WORD string[1];}sd000={
  275. sizeof(sd000),USB_DESCRIPTOR_STRING,{0x0409}};
  276.  
  277. //Manufacturer string descriptor
  278. ROM struct{BYTE bLength;BYTE bDscType;WORD string[25];}sd001={
  279. sizeof(sd001),USB_DESCRIPTOR_STRING,
  280. {'M','i','c','r','o','c','h','i','p',' ',
  281. 'T','e','c','h','n','o','l','o','g','y',' ','I','n','c','.'
  282. }};
  283.  
  284. //Product string descriptor
  285. ROM struct{BYTE bLength;BYTE bDscType;WORD string[25];}sd002={
  286. sizeof(sd002),USB_DESCRIPTOR_STRING,
  287. {'C','D','C',' ','R','S','-','2','3','2',' ',
  288. 'E','m','u','l','a','t','i','o','n',' ','D','e','m','o'}
  289. };
  290.  
  291. //Array of configuration descriptors
  292. ROM BYTE *ROM USB_CD_Ptr[]=
  293. {
  294.     (ROM BYTE *ROM)&configDescriptor1
  295. };
  296. //Array of string descriptors
  297. ROM BYTE *ROM USB_SD_Ptr[USB_NUM_STRING_DESCRIPTORS]=
  298. {
  299.     (ROM BYTE *ROM)&sd000,
  300.     (ROM BYTE *ROM)&sd001,
  301.     (ROM BYTE *ROM)&sd002
  302. };
  303.  
  304. /*
  305. #if defined(__18CXX)
  306.     #pragma code
  307. #endif
  308. */
  309.  
  310. #endif
  311. /** EOF usb_descriptors.c ****************************************************/
De vez en cuando la vida
nos besa en la boca
y a colores se despliega
como un atlas

Desconectado AngelGris

  • Colaborador
  • PIC24H
  • *****
  • Mensajes: 2480
Re: ¿USB con compilador XC?
« Respuesta #22 en: 24 de Enero de 2014, 09:58:44 »
usb_config.h
Código: C
  1. /********************************************************************
  2.  FileName:      usb_config.h
  3.  Dependencies:  Always: GenericTypeDefs.h, usb_device.h
  4.                 Situational: usb_function_hid.h, usb_function_cdc.h, usb_function_msd.h, etc.
  5.  Processor:             PIC18 or PIC24 USB Microcontrollers
  6.  Hardware:              The code is natively intended to be used on the following
  7.                                 hardware platforms: PICDEM™ FS USB Demo Board,
  8.                                 PIC18F87J50 FS USB Plug-In Module, or
  9.                                 Explorer 16 + PIC24 USB PIM.  The firmware may be
  10.                                 modified for use on other USB platforms by editing the
  11.                                 HardwareProfile.h file.
  12.  Complier:      Microchip C18 (for PIC18) or C30 (for PIC24)
  13.  Company:               Microchip Technology, Inc.
  14.  
  15.  Software License Agreement:
  16.  
  17.  The software supplied herewith by Microchip Technology Incorporated
  18.  (the “Company”) for its PIC® Microcontroller is intended and
  19.  supplied to you, the Company’s customer, for use solely and
  20.  exclusively on Microchip PIC Microcontroller products. The
  21.  software is owned by the Company and/or its supplier, and is
  22.  protected under applicable copyright laws. All rights are reserved.
  23.  Any use in violation of the foregoing restrictions may subject the
  24.  user to criminal sanctions under applicable laws, as well as to
  25.  civil liability for the breach of the terms and conditions of this
  26.  license.
  27.  
  28.  THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES,
  29.  WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
  30.  TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
  31.  PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
  32.  IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
  33.  CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
  34.  
  35. ********************************************************************
  36.  File Description:
  37.  
  38.  Change History:
  39.   Rev   Date         Description
  40.   2.8   8 Oct 2010   Added definitions for supporting new
  41.                      USB_ENABLE_STATUS_STAGE_TIMEOUTS feature.
  42.                      Changed the CDC comm EP and data EP from 2,3
  43.                      (respectively) to 1,2 respectively, so as to
  44.                      save RAM.
  45.  *******************************************************************/
  46.  
  47. /*********************************************************************
  48.  * Descriptor specific type definitions are defined in: usbd.h
  49.  ********************************************************************/
  50.  
  51. #ifndef USBCFG_H
  52. #define USBCFG_H
  53.  
  54. /** DEFINITIONS ****************************************************/
  55. #define USB_EP0_BUFF_SIZE               8       // Valid Options: 8, 16, 32, or 64 bytes.
  56.                                                                 // Using larger options take more SRAM, but
  57.                                                                 // does not provide much advantage in most types
  58.                                                                 // of applications.  Exceptions to this, are applications
  59.                                                                 // that use EP0 IN or OUT for sending large amounts of
  60.                                                                 // application related data.
  61.                                                                        
  62. #define USB_MAX_NUM_INT         2   // For tracking Alternate Setting
  63.  
  64. //Device descriptor - if these two definitions are not defined then
  65. //  a ROM USB_DEVICE_DESCRIPTOR variable by the exact name of device_dsc
  66. //  must exist.
  67. #define USB_USER_DEVICE_DESCRIPTOR &device_dsc
  68. #define USB_USER_DEVICE_DESCRIPTOR_INCLUDE extern ROM USB_DEVICE_DESCRIPTOR device_dsc
  69.  
  70. //Configuration descriptors - if these two definitions do not exist then
  71. //  a ROM BYTE *ROM variable named exactly USB_CD_Ptr[] must exist.
  72. #define USB_USER_CONFIG_DESCRIPTOR USB_CD_Ptr
  73. #define USB_USER_CONFIG_DESCRIPTOR_INCLUDE extern ROM BYTE *ROM USB_CD_Ptr[]
  74.  
  75. //Make sure only one of the below "#define USB_PING_PONG_MODE"
  76. //is uncommented.
  77. //#define USB_PING_PONG_MODE USB_PING_PONG__NO_PING_PONG
  78. #define USB_PING_PONG_MODE USB_PING_PONG__FULL_PING_PONG
  79. //#define USB_PING_PONG_MODE USB_PING_PONG__EP0_OUT_ONLY
  80. //#define USB_PING_PONG_MODE USB_PING_PONG__ALL_BUT_EP0         //NOTE: This mode is not supported in PIC18F4550 family rev A3 devices
  81.  
  82.  
  83. //#define USB_POLLING
  84. #define USB_INTERRUPT
  85.  
  86. /* Parameter definitions are defined in usb_device.h */
  87. #define USB_PULLUP_OPTION USB_PULLUP_ENABLE
  88. //#define USB_PULLUP_OPTION USB_PULLUP_DISABLED
  89.  
  90. #define USB_TRANSCEIVER_OPTION USB_INTERNAL_TRANSCEIVER
  91. //External Transceiver support is not available on all product families.  Please
  92. //  refer to the product family datasheet for more information if this feature
  93. //  is available on the target processor.
  94. //#define USB_TRANSCEIVER_OPTION USB_EXTERNAL_TRANSCEIVER
  95.  
  96. #define USB_SPEED_OPTION USB_FULL_SPEED
  97. //#define USB_SPEED_OPTION USB_LOW_SPEED //(not valid option for PIC24F devices)
  98.  
  99. //------------------------------------------------------------------------------------------------------------------
  100. //Option to enable auto-arming of the status stage of control transfers, if no
  101. //"progress" has been made for the USB_STATUS_STAGE_TIMEOUT value.
  102. //If progress is made (any successful transactions completing on EP0 IN or OUT)
  103. //the timeout counter gets reset to the USB_STATUS_STAGE_TIMEOUT value.
  104. //
  105. //During normal control transfer processing, the USB stack or the application
  106. //firmware will call USBCtrlEPAllowStatusStage() as soon as the firmware is finished
  107. //processing the control transfer.  Therefore, the status stage completes as
  108. //quickly as is physically possible.  The USB_ENABLE_STATUS_STAGE_TIMEOUTS
  109. //feature, and the USB_STATUS_STAGE_TIMEOUT value are only relevant, when:
  110. //1.  The application uses the USBDeferStatusStage() API function, but never calls
  111. //      USBCtrlEPAllowStatusStage().  Or:
  112. //2.  The application uses host to device (OUT) control transfers with data stage,
  113. //      and some abnormal error occurs, where the host might try to abort the control
  114. //      transfer, before it has sent all of the data it claimed it was going to send.
  115. //
  116. //If the application firmware never uses the USBDeferStatusStage() API function,
  117. //and it never uses host to device control transfers with data stage, then
  118. //it is not required to enable the USB_ENABLE_STATUS_STAGE_TIMEOUTS feature.
  119.  
  120. #define USB_ENABLE_STATUS_STAGE_TIMEOUTS    //Comment this out to disable this feature.  
  121.  
  122. //Section 9.2.6 of the USB 2.0 specifications indicate that:
  123. //1.  Control transfers with no data stage: Status stage must complete within
  124. //      50ms of the start of the control transfer.
  125. //2.  Control transfers with (IN) data stage: Status stage must complete within
  126. //      50ms of sending the last IN data packet in fullfilment of the data stage.
  127. //3.  Control transfers with (OUT) data stage: No specific status stage timing
  128. //      requirement.  However, the total time of the entire control transfer (ex:
  129. //      including the OUT data stage and IN status stage) must not exceed 5 seconds.
  130. //
  131. //Therefore, if the USB_ENABLE_STATUS_STAGE_TIMEOUTS feature is used, it is suggested
  132. //to set the USB_STATUS_STAGE_TIMEOUT value to timeout in less than 50ms.  If the
  133. //USB_ENABLE_STATUS_STAGE_TIMEOUTS feature is not enabled, then the USB_STATUS_STAGE_TIMEOUT
  134. //parameter is not relevant.
  135.  
  136. #define USB_STATUS_STAGE_TIMEOUT     (BYTE)45   //Approximate timeout in milliseconds, except when
  137.                                                 //USB_POLLING mode is used, and USBDeviceTasks() is called at < 1kHz
  138.                                                 //In this special case, the timeout becomes approximately:
  139. //Timeout(in milliseconds) = ((1000 * (USB_STATUS_STAGE_TIMEOUT - 1)) / (USBDeviceTasks() polling frequency in Hz))
  140. //------------------------------------------------------------------------------------------------------------------
  141.  
  142. #define USB_SUPPORT_DEVICE
  143.  
  144. #define USB_NUM_STRING_DESCRIPTORS 3
  145.  
  146. //#define USB_INTERRUPT_LEGACY_CALLBACKS
  147. #define USB_ENABLE_ALL_HANDLERS
  148. //#define USB_ENABLE_SUSPEND_HANDLER
  149. //#define USB_ENABLE_WAKEUP_FROM_SUSPEND_HANDLER
  150. //#define USB_ENABLE_SOF_HANDLER
  151. //#define USB_ENABLE_ERROR_HANDLER
  152. //#define USB_ENABLE_OTHER_REQUEST_HANDLER
  153. //#define USB_ENABLE_SET_DESCRIPTOR_HANDLER
  154. //#define USB_ENABLE_INIT_EP_HANDLER
  155. //#define USB_ENABLE_EP0_DATA_HANDLER
  156. //#define USB_ENABLE_TRANSFER_COMPLETE_HANDLER
  157.  
  158. /** DEVICE CLASS USAGE *********************************************/
  159. #define USB_USE_CDC
  160.  
  161. /** ENDPOINTS ALLOCATION *******************************************/
  162. #define USB_MAX_EP_NUMBER           2
  163.  
  164. /* CDC */
  165. #define CDC_COMM_INTF_ID        0x0
  166. #define CDC_COMM_EP              1
  167. #define CDC_COMM_IN_EP_SIZE      10
  168.  
  169. #define CDC_DATA_INTF_ID        0x01
  170. #define CDC_DATA_EP             2
  171. #define CDC_DATA_OUT_EP_SIZE    64
  172. #define CDC_DATA_IN_EP_SIZE     64
  173.  
  174. //#define USB_CDC_SUPPORT_ABSTRACT_CONTROL_MANAGEMENT_CAPABILITIES_D2 //Send_Break command
  175. #define USB_CDC_SUPPORT_ABSTRACT_CONTROL_MANAGEMENT_CAPABILITIES_D1 //Set_Line_Coding, Set_Control_Line_State, Get_Line_Coding, and Serial_State commands
  176. /** DEFINITIONS ****************************************************/
  177.  
  178. #endif //USBCFG_H

HardwareProfile.h
Código: C
  1. /*
  2.  * File:   HardWareProfile.h
  3.  * Author: sebastian
  4.  *
  5.  * Created on 12 de noviembre de 2013, 15:46
  6.  */
  7.  
  8. #ifndef HARDWAREPROFILE_H
  9. #define HARDWAREPROFILE_H
  10.  
  11. #define DEMO_BOARD USER_DEFINED_BOARD
  12. #define self_power          1
  13. #define USE_USB_BUS_SENSE_IO
  14. #define USB_BUS_SENSE       PORTAbits.RA1
  15.  
  16. #endif  /* HARDWAREPROFILE_H */
De vez en cuando la vida
nos besa en la boca
y a colores se despliega
como un atlas

Desconectado calavia

  • PIC10
  • *
  • Mensajes: 14
Re: ¿USB con compilador XC?
« Respuesta #23 en: 24 de Enero de 2014, 10:22:32 »
Pues yo no se que estoy haciendo mal, porque tengo todo igual que tu, la unica diferencia es que uso el PIC18F4550 y no me lo detecta.
Mira la imagen

Desconectado AngelGris

  • Colaborador
  • PIC24H
  • *****
  • Mensajes: 2480
Re: ¿USB con compilador XC?
« Respuesta #24 en: 24 de Enero de 2014, 10:32:30 »
  Yo estoy utilizando la versión 1.12 del compilador, tal vez esté allí la diferencia. Intenta compilar el ejemplo con los archivos que subí en un 18f2550 para ver que ocurre.
De vez en cuando la vida
nos besa en la boca
y a colores se despliega
como un atlas

Desconectado AngelGris

  • Colaborador
  • PIC24H
  • *****
  • Mensajes: 2480
Re: ¿USB con compilador XC?
« Respuesta #25 en: 24 de Enero de 2014, 10:49:03 »
  Acabo de compilar el mismo ejemplo sin modificar nada, para un PIC18f4550 y funcionó bien. En estos ejemplos el PIC debe trabajar a 48MHz, por lo tanto configuro esa velocidad en ISIS.
De vez en cuando la vida
nos besa en la boca
y a colores se despliega
como un atlas

Desconectado calavia

  • PIC10
  • *
  • Mensajes: 14
Re: ¿USB con compilador XC?
« Respuesta #26 en: 24 de Enero de 2014, 10:53:25 »
No funciona no se porque... bueno voy a intentar a ver como va la cosa.
Muchas gracias por la ayuda

Desconectado AngelGris

  • Colaborador
  • PIC24H
  • *****
  • Mensajes: 2480
Re: ¿USB con compilador XC?
« Respuesta #27 en: 24 de Enero de 2014, 11:34:40 »
¿Estás utilizando exactamente el mismo código que yo he utilizado?

¿Qué pasa si intentas compilar y simular el ejemplo de joystick HID? El botón va del pin RB7 a vcc, dicho pin lleva una resistencia de pulldown (10K a gnd).

Aquí el archivo HardwareProfile.h para el joystick
Código: C
  1. /*
  2.  * File:   HardwareProfile.h
  3.  * Author: sebastian
  4.  *
  5.  * Created on 13 de noviembre de 2013, 18:05
  6.  */
  7.  
  8. #ifndef HARDWAREPROFILE_H
  9. #define HARDWAREPROFILE_H
  10.  
  11. #define DEMO_BOARD USER_DEFINED_BOARD
  12.  
  13. #define self_power 0
  14. #define USB_SENSE
  15.  
  16. #endif  /* HARDWAREPROFILE_H */
« Última modificación: 24 de Enero de 2014, 11:39:19 por AngelGris »
De vez en cuando la vida
nos besa en la boca
y a colores se despliega
como un atlas

Desconectado calavia

  • PIC10
  • *
  • Mensajes: 14
Re: ¿USB con compilador XC?
« Respuesta #28 en: 24 de Enero de 2014, 14:56:49 »
Si si, si lo tengo todo montado pero usando un FTDI para realizar la conversión, pero preferiría que la hiciese el PIC. Pero bueno q no importa q si no puedo da igual.

Muchas gracias por todo

Desconectado chapoton

  • PIC10
  • *
  • Mensajes: 2
Re: ¿USB con compilador XC?
« Respuesta #29 en: 21 de Febrero de 2014, 14:42:51 »
Hola. He intentado seguir el hilo y todavía no he podido compilar ningun proyecto con USB con las librearías mla. ¿Existe alguna posibilidad que suban algun proyecto realizado en mplabx así puedo compilarlo? Estoy tratando de realizar una comunicación con un PIC18F4550.
Como aporte he encontrado que no se tienen que compilar con la versión de XC8 1.3 sino con la versión 1.12.

Saludos


 

anything