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 application with 18f4550 is not enumerating.

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



Joined: 31 Mar 2011
Posts: 2

View user's profile Send private message

USB application with 18f4550 is not enumerating.
PostPosted: Thu Mar 31, 2011 9:50 am     Reply with quote

Firstly, I would like to thank all the contributors and moderators of "ccsinfo.com/forum" for this great website.

I am a beginner at USB communication and I want to make a simple led application with 18f4550. But I can not make it work. When I plug the USB cable, I can not get any response from the computer. Its not loading the driver.

My aim is:

When the USB cable connected, LED1(yellow) on
When its enumerated, LED2(green) on,
else LED3(red) on.

I am using 20 Mhz Crystal oscillator with two 15pf capacitors. I use the B2 pin for connection sense and I use VUSB pin with 470nF.

Here is the code, that I wrote:

Code:


#include <18F4550.h>
#fuses HSPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,PLL5,CPUDIV1,VREGEN,NOPBADEN
#use delay (clock=48000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#DEFINE USB_HID_DEVICE  true

#define USB_EP1_TX_ENABLE  USB_ENABLE_INTERRUPT   //turn on EP1 for IN bulk/interrupt transfers
#define USB_EP1_TX_SIZE    255  //allocate 8 bytes in the hardware for transmission

//the following defines needed for the CCS USB PIC driver to enable the RX endpoint 1
// and allocate buffer space on the peripheral
#define USB_EP1_RX_ENABLE  USB_ENABLE_INTERRUPT   //turn on EP1 for OUT bulk/interrupt transfers
#define USB_EP1_RX_SIZE    255  //allocate 8 bytes in the hardware for reception

#include <pic18_usb.h>
#include <USB.H>
#include <usb_desc_hid.h>
#include <usb.c>
#define USB_CON_SENSE_PIN PIN_B2
#define usb_attached() input(USB_CON_SENSE_PIN)


#use fast_io(d)
int8 x;


void main()
{

   setup_adc_ports(NO_ANALOGS|VSS_VDD);
   setup_adc(ADC_OFF);
   setup_psp(PSP_DISABLED);
   setup_spi(SPI_SS_DISABLED);
   setup_wdt(WDT_OFF);
   setup_timer_0(RTCC_INTERNAL);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);
//Setup_Oscillator parameter not selected from Intr Oscillotar Config tab

   // TODO: USER CODE!!
   set_tris_d(0x00);
   output_d(0x00);
   usb_init();
   x=0;
     
   while(1)
   {
   
     usb_task(); 
   
      if(usb_attached() && usb_enumerated())
     {
        output_d(0x01);
       
     }
           
     else if(usb_attached() && !usb_enumerated())
     {
        output_d(0x04);
       
     }
     else if(!usb_attached())
     {
        output_d(0x02);   
     
     } 
         
   
   }
   
   
   
   

}


Please help me.Crying or Very sad

Thanks
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Mar 31, 2011 11:43 am     Reply with quote

Try it by using the CCS example file, ex_usb_hid.c.
This thread explains all the little changes that need to do, to make it
work with your hardware:
http://www.ccsinfo.com/forum/viewtopic.php?t=38897
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