CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

USB CDC class does not work

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
pilar



Joined: 30 Jan 2008
Posts: 197

View user's profile Send private message

USB CDC class does not work
PostPosted: Wed Jan 30, 2008 9:40 am     Reply with quote

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?
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group