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

Support for 18f46j53 and 18f26j53 for USB

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



Joined: 24 Aug 2005
Posts: 9

View user's profile Send private message

Support for 18f46j53 and 18f26j53 for USB
PostPosted: Mon Dec 13, 2010 2:41 pm     Reply with quote

I am not able to run even an simple USB HID application. The host always complains that the device could not be enumerated.

Here is my code (I used 18f26j53 for the device, as this is the nearest one in the supported devices list).

Code:

#include <18F26J50.h>
#device adc=8

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES WDT128                   //Watch Dog Timer uses 1:128 Postscale
#FUSES HSPLL                    //High Speed Crystal/Resonator with PLL enabled
#FUSES NODEBUG                  //No Debug mode for ICD
#FUSES NOXINST                  //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#FUSES STVREN                   //Stack full/underflow will cause reset
#FUSES NOPROTECT                //Code not protected from reading
#FUSES FCMEN                    //Fail-safe clock monitor enabled
#FUSES IESO                     //Internal External Switch Over mode enabled
#FUSES IOL1WAY                  //Allows only one reconfiguration of peripheral pins
#FUSES NOWPCFG               
#FUSES WPBEG                 
#FUSES WPDIS                 
#FUSES NOCPUDIV             
#FUSES LPT1OSC                  //Timer1 configured for low-power operation
#FUSES T1DIG                 
#FUSES MSSPMSK7             
#FUSES PLL5                     //Divide By 5(20MHz oscillator input)
#FUSES DSWDT2147483648       
#FUSES DSWDT                 
#FUSES DSBOR                 
#FUSES RTCOSC_T1             
#FUSES DSWDTOSC_INT         
#FUSES WPFP
#use delay(clock=48000000)

#define USB_CONFIG_HID_TX_SIZE   2
#define USB_CONFIG_HID_RX_SIZE   2

#include <pic18_usb.h>   //Microchip PIC18Fxx5x hardware layer for usb.c
#include <usb_desc_hid.h>   //USB Configuration and Device descriptors for this UBS device
#include <usb.c>   

int8 out_data[2];
int8 in_data[2];
int8 send_timer=0;
   
void main()
{

   setup_adc_ports(ALL_ANALOG|VSS_VDD);
   setup_adc(ADC_CLOCK_DIV_2|ADC_TAD_MUL_0);
   setup_spi(SPI_SS_DISABLED);
   setup_spi2(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_timer_3(T3_DISABLED|T3_DIV_BY_1);
   setup_timer_4(T4_DISABLED,0,1);
   setup_ccp1(CCP_OFF);
   setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard

   usb_init_cs();

   while(1)
   {
      usb_task();
      if (usb_enumerated())
      {
         if (!send_timer)
         {
            send_timer=250;
             usb_put_packet(1, out_data, 2, USB_DTS_TOGGLE);
         }
         if (usb_kbhit(1))
         {
            usb_get_packet(1, in_data, 2);
         }
         send_timer--;
         delay_ms(1);
      }
     
   }
}
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