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 CCS Technical Support

Help on CDC serial emulator and PIC18F46J50

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



Joined: 04 May 2010
Posts: 1

View user's profile Send private message

Help on CDC serial emulator and PIC18F46J50
PostPosted: Tue May 04, 2010 8:14 am     Reply with quote

Hi,

I need an example code for CDC serial emulator on PIC18F46J50.

My code works great on PIC18F4550, but the device is not recognized when I compile for PIC18F46J50.

Code:

#include <18F4550.h>

//configure a 8MHz crystal to operate at 48MHz
#fuses PLL2,CPUDIV1,USBDIV,HSPLL,NOFCMEN,NOIESO,BROWNOUT,BORV20,VREGEN,NOWDT,WDT32768,MCLR,NOLPT1OSC,NOPBADEN,CCP2C1,STVREN,NOPROTECT,NOCPB,NOCPD,NOWRT,NOWRTC,WRTB,NOWRTD
#use delay(clock=48000000)

#include <usb_cdc.h> 

int8 data,i=0;

void main()
{
   unsigned long int a;

   usb_cdc_init();      
   usb_init();      
   
   a=0;

   while(!usb_cdc_connected())
   {
    }

   do
   {
       usb_task();
   
      output_low(PIN_D0);
      delay_ms(500);
      output_high(PIN_D0);
      delay_ms(500);

      if (usb_enumerated()) 
      {
         if(usb_cdc_kbhit())      
         {
            data = usb_cdc_getc(); 
            output_low(PIN_D0);
            if(data == 0x00)
            {     
               usb_cdc_putc(0x00);      
            }
            else
            {
               usb_cdc_putc(0xFF);
            }
            delay_ms(50);
         }
      }
   } while (TRUE);
}


Thanks,

Alexandre
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