pilar
Joined: 30 Jan 2008 Posts: 197
|
USB CDC class does not work |
Posted: Wed Jan 30, 2008 9:40 am |
|
|
Hi,
I am trying to implement an interface using the USB in CDC class , this is my code:
Code: | #include <18f2550.h>
#fuses HSPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,PLL5,CPUDIV1,VREGEN
#use delay(clock=20000000)
#use rs232(baud=19200, xmit=PIN_C6, rcv=PIN_C7)
#define SELECTOR PIN_A0
#define LEDV PIN_B6
#define LEDR PIN_B7
#define LED_ON output_high
#define LED_OFF output_low
#include <usb_cdc.h>
char c=0x00;
char rec=0x00;
void menu (void);
//******************************************************************************************
void menu (void){
printf(usb_cdc_putc,"\r\n");
printf(usb_cdc_putc,"Menu:\r\n");
printf(usb_cdc_putc," [R] Leer DATO\r\n");
printf(usb_cdc_putc," [C] Configurar Canal\r\n");
printf(usb_cdc_putc," [X] Salir\r\n\n");
printf(usb_cdc_putc,"\r\n");
printf(usb_cdc_putc,"\r\n");
printf(usb_cdc_putc,"Comando: ");
rec=toupper(usb_cdc_getc());
}
//********************************************************************************************
void main() {
LED_OFF(LEDV);
LED_ON(LEDR);
usb_cdc_init();
usb_init();
while (TRUE) {
usb_task();
// if(usb_enumerated()){
if (input (SELECTOR)){
LED_ON(LEDR);
LED_OFF(LEDV);
printf(usb_cdc_putc,"Prendio el Led ROJO \r\n");
Delay_ms(300);
}
else{
LED_OFF(LEDR);
LED_ON(LEDV);
printf(usb_cdc_putc,"Prendio el Led VERDE \r\n");
Delay_ms(300);
menu();
// }
}
}
} |
The problem is: When I disable ( //rec=toupper(usb_cdc_getc());) all work ok, and I can receive information over the Hyperterminal, but when enable ( rec=toupper(usb_cdc_getc());) I can not receive anything through the Hyperterminal, someone could tell me what the problem? |
|