NeoTO
Joined: 24 Aug 2005 Posts: 9
|
Support for 18f46j53 and 18f26j53 for USB |
Posted: Mon Dec 13, 2010 2:41 pm |
|
|
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);
}
}
} |
|
|