| alexandrecf80 
 
 
 Joined: 04 May 2010
 Posts: 1
 
 
 
			    
 
 | 
			
				| Help on CDC serial emulator and PIC18F46J50 |  
				|  Posted: Tue May 04, 2010 8:14 am |   |  
				| 
 |  
				| 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
 |  |